From patchwork Mon Feb 6 20:10:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 53482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2437586wrn; Mon, 6 Feb 2023 12:11:30 -0800 (PST) X-Google-Smtp-Source: AK7set+jZnMEq6C6I9APKI8O32/QlOj+nwRPLe0hcZI5Qa/K46qRQvB9XSsXsNISRxlxttV14CbC X-Received: by 2002:a17:906:2898:b0:886:9b85:ac5d with SMTP id o24-20020a170906289800b008869b85ac5dmr451812ejd.44.1675714290304; Mon, 06 Feb 2023 12:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675714290; cv=none; d=google.com; s=arc-20160816; b=pBbZJ/uCiFkDDqge0xaQowEH6NWDgDDUxzLR4lDmnez7vH3+6lMPRqZ6EIOyL/rhJ4 oYqxFo72KLcPIFuHHpjHUxyJoxF7Tk+wpvaMOede5ixIVUqc8moIOuJr7HECtN0rrJma OigvRZOCMnZQ4gVwAkNi0u7cUhFssDO+viMBVcR3ADct2eHgkCEpBpJX7vbT7TGkup6O 71vKeiu0FJc/x70pIxwBPFY8+cBErvMaFIe0NxwVYbIYpr8J7rMzUpI5IzMhUySuu7Sx NlRhjMXYysecOmC3K+LYum9wwxrF8gYogWJceyti/xT0eynv/jbpZ8B8QJYJn3QaQKwf cTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=eNbJqZ2Fvx3jeNczeZbCVWkXlCqx0kh4gjuRj9qI17k=; b=DF3h5SFqnE6DgcIWVM35B09dBAm0UxYgBwP9Q/FzGRFxlO91rKa8YMBhjyvuzL4RHY 7F1Tkxg3QWzcSicVvQ4kftX2s+49U1s4oIg3zal8TMIupSqksQQvMakuM8iPyA/kIMYU nAfdaN96mGrpDEH2ywOHBP/u8uOhwLTtFCIA6+fPojqdEbTyIdwPyT7FAghSHhKjXb9+ 3nyt22Mdhk4/HfdjBnHiqw6VaOoCMjjCX/Io8XDkoommo4du6GxWTJAfX2eLHlDXMRMG qW1QN/NhxxSeED9F8nNl8bYu3xjVPa+wjm9Fo18ZSuiZnsKmBOgwP8k0vwUkbXE8Az5z +Jfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xYMTWnGm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bf19-20020a170906c51300b00877e0202816si13882344ejb.122.2023.02.06.12.11.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 12:11:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xYMTWnGm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20A28385841C for ; Mon, 6 Feb 2023 20:11:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20A28385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675714289; bh=eNbJqZ2Fvx3jeNczeZbCVWkXlCqx0kh4gjuRj9qI17k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xYMTWnGmZ8RZKUe9TO+Zkotx8Qx0XKk0PyVbClhWn4H2jhTDqxoc3Uq+71Gwu72FV XAv6u88SficRJg8HxYGsGOmiQthpm4aThJob3qbV5MQ5X8U68zAlKizaa9PAv707ek bCfoIvzVetkQwsFXVUE/OLuxgyEQLMPjHe1YZjXQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id AA74B3858D1E; Mon, 6 Feb 2023 20:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA74B3858D1E X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.89.127] ([93.207.89.127]) by web-mail.gmx.net (3c-app-gmx-bap04.server.lan [172.19.172.74]) (via HTTP); Mon, 6 Feb 2023 21:10:38 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107] Date: Mon, 6 Feb 2023 21:10:38 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:dLBsDlbC6N4QegSUhu/ZU9XCPZwBsQOhU8V60wEVqd4FmOqaXcc/UKP14QzHYN2rZQnTb vUzTc9UJZqjS4B/rYzNBj2CEFLxynnB1oLN3tM3ti6orr54qDRQa2xo7BvjfyB9xvpJN7MNaEq7r 69KN10l7hobwZ+WPnTVn/mGq3tkDSq/XFxBjtWg70S5ITe+I98odW1cZ4JnM2f2O61989lKKjbsG GGSHWryRN2kptO1r2SnvR8Oa1x03ER8SXobp2HHfks+CFslolH3f1RNkZDuoCuSHJn+PmzvxOm21 NU= UI-OutboundReport: notjunk:1;M01:P0:F4aq8fo8//k=;RNZ7dVa8m6LOEiFfSzBkZlsUyYc lmRX1KflJFiyWvPySCgQm4XMgKDgjfbgDAezJ6zqo1Jo9kbBQzcLHieAR+lUDuaHakxvYMGym IJb9OzeWNi18gonNU3loDMhAU+42QLVJiVvwZBapR6D+JLD8JBvB4Dwpp+iJMwG7jbFYbNox+ oh8VMskmc2JNNeaIF8wBFm0am46b2cr1nrtkeCejd3p2VmeHZCh91SAgZmN0y9bgXDqy7Q75q Wnif96TQvpsdhAlUJKf2wGk5o8waEIWMVeumUvC+xGFyFPbNV9ZVLzcOKafFYxkTbNua+yV5Y i9gRpK/USnelAOTj0Xfw6kLyvGPdR6TjsWductc6y3JJcoeQA97mHb3b9yaCa/xjsYrvkD49g HIa0SayrjMKYUEvt3ycnevCmzT4tOzzLaCsbU/5vVvwa/wnJ52+RJaQI8vkx+WEocGceeHDpY I8nXwSgtcKZbNiMlnqlO8B1eM+Svyf+MHFnwr2U3zYR5OqjzlIB5nmtL7RyDczg0oSDh0bjQM tQqfKUfl7mkeeXh0ZH3H+UNxwoE2XUolXDZBYGtKrdqWi8cvdDOvtaq72y7FdOl++Ye01IwMW UEetsguXTyCkTLZV9K7w/I+WGQKo0ZcA32fRQT7962WwPq6E0eQH9+xEHyn+UA7cN7ovPqf8k v7LY9XxiK0s6WL4hzTIJj47LcN9FeveMLNoNhZ6iAf7vpPKFM6XuJszQpi7tzrEITbZdGb1OS L4WsIVONFgn50ZveXcYzU/cO/cfh98JWJrzHC67DRvMRMboAQQ41/w7aM19jOM8sdPOBLyS1P /IqFwteM58biu3Jrjde3WUHBgSd3L/g9S/LwTo27SAlOk= X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757113787650776302?= X-GMAIL-MSGID: =?utf-8?q?1757113787650776302?= Dear all, as the PR shows, it is likely not a good idea to try to make an ASSOCIATE variable static when -fno-automatic is specified, so rather keep it on the stack. Attached patch regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From c29eb3dbe8c541ef83d5fdf12cafa015ed9447ee Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 6 Feb 2023 20:59:51 +0100 Subject: [PATCH] Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107] gcc/fortran/ChangeLog: PR fortran/95107 * trans-decl.cc (gfc_finish_var_decl): With -fno-automatic, do not make ASSOCIATE variables TREE_STATIC. gcc/testsuite/ChangeLog: PR fortran/95107 * gfortran.dg/save_7.f90: New test. --- gcc/fortran/trans-decl.cc | 1 + gcc/testsuite/gfortran.dg/save_7.f90 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/save_7.f90 diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 7a077801919..f7a7ff607cd 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -742,6 +742,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) /* Keep variables larger than max-stack-var-size off stack. */ if (!(sym->ns->proc_name && sym->ns->proc_name->attr.recursive) && !sym->attr.automatic + && !sym->attr.associate_var && sym->attr.save != SAVE_EXPLICIT && sym->attr.save != SAVE_IMPLICIT && INTEGER_CST_P (DECL_SIZE_UNIT (decl)) diff --git a/gcc/testsuite/gfortran.dg/save_7.f90 b/gcc/testsuite/gfortran.dg/save_7.f90 new file mode 100644 index 00000000000..dfbef12bec0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/save_7.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! { dg-options "-O2 -fno-automatic" } +! +! PR fortran/95107 - do not make associate variables TREE_STATIC +! Contributed by G.Steinmetz + +program p + type t + real, pointer :: a => null() + end type + type t2 + type(t) :: b(1) + end type + type(t2), save :: x + associate (y => x%b) + end associate +end -- 2.35.3