public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-11208] Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107]
@ 2023-02-11 18:16 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-02-11 18:16 UTC (permalink / raw)
  To: gcc-cvs

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-11 18:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 18:16 [gcc r10-11208] Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107] Harald Anlauf

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).