]> gcc.gnu.org Git - gcc.git/commitdiff
PR fortran/99169 - Do not clobber allocatable intent(out) dummy argument
authorHarald Anlauf <anlauf@gmx.de>
Sun, 21 Feb 2021 20:44:24 +0000 (21:44 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Sun, 21 Feb 2021 20:44:24 +0000 (21:44 +0100)
gcc/fortran/ChangeLog:

* trans-expr.c (gfc_conv_procedure_call): Do not add clobber to
allocatable intent(out) argument.

gcc/testsuite/ChangeLog:

* gfortran.dg/intent_optimize_3.f90: New test.

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

index 103cb31c6643a94c3650c015d129d7badc4e2bc0..e61492485b82dab688a0ee31e47cfa27c8c562b2 100644 (file)
@@ -6077,6 +6077,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                        && !fsym->attr.allocatable && !fsym->attr.pointer
                        && !e->symtree->n.sym->attr.dimension
                        && !e->symtree->n.sym->attr.pointer
+                       && !e->symtree->n.sym->attr.allocatable
                        /* See PR 41453.  */
                        && !e->symtree->n.sym->attr.dummy
                        /* FIXME - PR 87395 and PR 41453  */
diff --git a/gcc/testsuite/gfortran.dg/intent_optimize_3.f90 b/gcc/testsuite/gfortran.dg/intent_optimize_3.f90
new file mode 100644 (file)
index 0000000..6ecd722
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }
+! { dg-options "-O2" }
+! PR99169 - Segfault passing allocatable scalar into intent(out) dummy argument
+
+program p
+  implicit none
+  integer, allocatable :: i
+  allocate (i)
+  call set (i)
+  if (i /= 5) stop 1
+contains
+  subroutine set (i)
+    integer, intent(out) :: i
+    i = 5
+  end subroutine set
+end program p
This page took 0.088142 seconds and 5 git commands to generate.