public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-11208] Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107] Date: Sat, 11 Feb 2023 18:16:54 +0000 (GMT) [thread overview] Message-ID: <20230211181654.77B54385B517@sourceware.org> (raw) https://gcc.gnu.org/g:2db200ea8a63dd580b47002d9464afc7a7b5e90e commit r10-11208-g2db200ea8a63dd580b47002d9464afc7a7b5e90e Author: Harald Anlauf <anlauf@gmx.de> Date: Mon Feb 6 20:59:51 2023 +0100 Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107] gcc/fortran/ChangeLog: PR fortran/95107 * trans-decl.c (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. (cherry picked from commit c36f3da534e7f411c5bc48c5b6b660e238167480) Diff: --- gcc/fortran/trans-decl.c | 1 + gcc/testsuite/gfortran.dg/save_7.f90 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index bb72eb6731d..b616db34c3f 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -737,6 +737,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
reply other threads:[~2023-02-11 18:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230211181654.77B54385B517@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).