From patchwork Tue Oct 31 14:11:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 1857605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ljrZtrrI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SKXBL465sz1yQZ for ; Wed, 1 Nov 2023 01:11:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1A8A3857BB2 for ; Tue, 31 Oct 2023 14:11:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 86F223857704; Tue, 31 Oct 2023 14:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86F223857704 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86F223857704 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698761484; cv=none; b=LiMGiECS1L/ubMulq/Tl/kiG+xOBmfnKwbCJoFqqN6Hbo/G2J9HJUr7198X2rLy5DnWhIGZVeMr/RhaKA2SBPEUpYXSuEp6N0eDpSlTMu8PqeFtrf2W0SSgnTBWfGvHLuNS3PE/wBEYb5IJlQfm7XdkqhO9/M+A4URVpVfvKCAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698761484; c=relaxed/simple; bh=k3pmZtNHJEdr1nhQCtoPkBfbkIeNmv9cSPhzBOZqe/Q=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=XUeUXjd5WrO2kHZo3IpmkFln60xgiI8qWY4ueWVM2WiWmGf0oMCozP6cu3qxBqxsHg55P3Tj9vvk/yJkir9iGqD4AbUs8Oa8R0WZ8zA8S4dNDbD4Un+LJLA1PH6oSQSW+vLQYJIh1EVABQunmKgiutFyzGtaav7a2D/3ejZs1Pk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5a9d8f4388bso3359479a12.3; Tue, 31 Oct 2023 07:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698761480; x=1699366280; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=W7Pcs+qv8LIWN/L7Mqib1716A8MYu8txXrTqPaxqI7Y=; b=ljrZtrrIzE4oTzTgEYfDprRyakFh8myUem5hKzdJD3j9y8LxWAf3Xvzs/h3fZKZAuN +WoUImSsmILZ5gttAq5erdN8sS1UirlgMHP0KNNVxi9PLBuFdPPnECRYj3yJPLB+qqqo u34FR3rxeN2Ez37eBn53HGNbVGFfPi+x9Snd/TzQShPoGVi5GccZnj+JADJYGrY0kWkm eaB1+cpP698+UAQyFBNyJTyAmS681O85/k8GQJKTMGesz26KJ/JPcWJEpvozSikxwi6u bWqA2DulyYR71dxDn9A+rhFPTc5+9Fj03DV2/DGhoDvp5BNm098HAb3ORkk3k2F1ry9b nTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698761480; x=1699366280; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=W7Pcs+qv8LIWN/L7Mqib1716A8MYu8txXrTqPaxqI7Y=; b=tLkWaHuSvjjxUnJfdQpT9MCh8tSDfwHkWJpCBUXtvka3lmRKZDnP9r0pZu1OeSJTYm n0NP1i/FWV5gKHGpJCQMV+OzIxz0lOjERsvqPeJ7uw/gZRbsknewmuqi7zVuM/0u495+ urAS5XYPP0EsAYq1VQoCqIPXi1vyjW8YAoDEDsbiP/RB4jsWAuP3LtWw5kQnUkzuwANn V/t6TBjq8na+PFZqShtChRJxW75Hw1H6A0QSwTorw4meYakrxkOpcWddy7C5u8qiRvE6 SDq+rtJwlWke4SMMx9zvfXG4HZGgDbZYxgu5mrZZZND+gUjMY8or4U2uYBuKb2PNIU38 ax3Q== X-Gm-Message-State: AOJu0Yy0KMYprZr6RI3OowixBWhEXFBh65sYcDRBdZesCtTY4Oam0iQV VGQm4rzbSM85T21ETX0LpwRigIs/JJuIXxaM3CHmsObmTEY= X-Google-Smtp-Source: AGHT+IG+kGEkQRtjLvvwhPxFbXn1K3+yQCknYHSblhKFAa7YfsvsGD9wDk4tzUSWQmkunbO7RxlS2juR/OvoO3TLSew= X-Received: by 2002:a17:90a:72c7:b0:280:509:30c6 with SMTP id l7-20020a17090a72c700b00280050930c6mr10057630pjk.46.1698761479958; Tue, 31 Oct 2023 07:11:19 -0700 (PDT) MIME-Version: 1.0 From: Paul Richard Thomas Date: Tue, 31 Oct 2023 14:11:08 +0000 Message-ID: Subject: [Patch, fortran] PR64120 To: "fortran@gcc.gnu.org" , gcc-patches X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org I found this 'obvious' fix, while going through PRs assigned to me. Regtests. OK for mainline? Cheers Paul Fortran: Allocatable automatic charlen must not be saved [PR64120]. 2023-10-31 Paul Thomas gcc/fortran PR fortran/64120 * trans-decl.cc (gfc_trans_deferred_vars): Detect automatic character length and allow allocatable variants to be nullified on scope entry and freed on scope exit. Remove trailing white space. gcc/testsuite/ PR fortran/64120 * gfortran.dg/pr64120_2.f90: New test. diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index a3f037bd07b..5e0e78ace40 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -4689,9 +4689,14 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) && (sym->ts.u.derived->attr.alloc_comp || gfc_is_finalizable (sym->ts.u.derived, NULL)); + bool automatic_char_len; if (sym->assoc) continue; + automatic_char_len = sym->ts.type == BT_CHARACTER + && sym->ts.u.cl && sym->ts.u.cl->length + && sym->ts.u.cl->length->expr_type == EXPR_VARIABLE; + /* Set the vptr of unlimited polymorphic pointer variables so that they do not cause segfaults in select type, when the selector is an intrinsic type. */ @@ -4951,7 +4956,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.allocatable))) { - if (!sym->attr.save && flag_max_stack_var_size != 0) + if ((!sym->attr.save || automatic_char_len) + && flag_max_stack_var_size != 0) { tree descriptor = NULL_TREE; @@ -5210,8 +5216,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) tree tmp = lookup_attribute ("omp allocate", DECL_ATTRIBUTES (n->sym->backend_decl)); tmp = TREE_VALUE (tmp); - TREE_PURPOSE (tmp) = se.expr; - TREE_VALUE (tmp) = align; + TREE_PURPOSE (tmp) = se.expr; + TREE_VALUE (tmp) = align; TREE_PURPOSE (TREE_CHAIN (tmp)) = init_stmtlist; TREE_VALUE (TREE_CHAIN (tmp)) = cleanup_stmtlist; }