re PR fortran/87397 (Clobbering intent(out) variables caused regression in OpenCoarra...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 24 Sep 2018 17:12:34 +0000 (17:12 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 24 Sep 2018 17:12:34 +0000 (17:12 +0000)
2018-09-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/87397
* gfc_conv_procedure_call: Do not add clobber on INTENT(OUT)
for variables in an associate statement.

2018-09-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/87401
* gfortran.dg/intent_out_12.f90: New test.

From-SVN: r264539

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/intent_out_12.f90 [new file with mode: 0644]

index 3901e2961a01304283c41cf81b78b39c71c1a972..5bc88566ed02cced6f6fe1c55c82e5250bba64dc 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-24  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/87397
+       * gfc_conv_procedure_call: Do not add clobber on INTENT(OUT)
+       for variables in an associate statement.
+
 2018-09-24  Bernhard Reuther-Fischer  <aldot@gcc.gnu.org>
            Cesar Philippidis  <cesar@codesourcery.com>
 
index b3808dfa0a04b1a20ca5fc74ef42d45434518db4..04210a4b6b137c9b7c9a5a70883afdc24f391718 100644 (file)
@@ -5282,6 +5282,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                        && !e->symtree->n.sym->attr.dummy
                        /* FIXME - PR 87395 and PR 41453  */
                        && e->symtree->n.sym->attr.save == SAVE_NONE 
+                       && !e->symtree->n.sym->attr.associate_var
                        && e->ts.type != BT_CHARACTER && e->ts.type != BT_DERIVED
                        && e->ts.type != BT_CLASS && !sym->attr.elemental;
 
index b344f502c77c84508690525f90fedb63bce5ee16..6e76e500c9d83d24f4a44c96aa65e63668f13090 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-24  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/87401
+       * gfortran.dg/intent_out_12.f90: New test.
+
 2018-09-24  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        PR testsuite/86952
diff --git a/gcc/testsuite/gfortran.dg/intent_out_12.f90 b/gcc/testsuite/gfortran.dg/intent_out_12.f90
new file mode 100644 (file)
index 0000000..e838bcb
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do  run }
+! PR fortran/87401 - this used to segfault at runtime.
+! Test case by Janus Weil.
+
+program assoc_intent_out
+
+   implicit none
+
+   real :: r
+
+   associate(o => r)
+      call sub(o)
+   end associate
+
+contains
+
+   subroutine sub(out)
+      real, intent(out) :: out
+      out = 0.0
+   end subroutine
+
+end
+