]> gcc.gnu.org Git - gcc.git/commitdiff
PR fortran/97491 - Wrong restriction for VALUE arguments of pure procedures
authorHarald Anlauf <anlauf@gmx.de>
Tue, 27 Oct 2020 19:25:23 +0000 (20:25 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Tue, 27 Oct 2020 19:26:44 +0000 (20:26 +0100)
A dummy argument with the VALUE attribute may be redefined in a PURE or
ELEMENTAL procedure.  Adjust the associated purity check.

gcc/fortran/ChangeLog:

* resolve.c (gfc_impure_variable): A dummy argument with the VALUE
attribute may be redefined without making a procedure impure.

gcc/testsuite/ChangeLog:

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

gcc/fortran/resolve.c
gcc/testsuite/gfortran.dg/value_8.f90 [new file with mode: 0644]

index a210f9aad43e8245f3bb8348bba29e2bf82b5428..93b918b30777e88e040a00e4d74c48d02c6b7a21 100644 (file)
@@ -16476,6 +16476,7 @@ gfc_impure_variable (gfc_symbol *sym)
 
   proc = sym->ns->proc_name;
   if (sym->attr.dummy
+      && !sym->attr.value
       && ((proc->attr.subroutine && sym->attr.intent == INTENT_IN)
          || proc->attr.function))
     return 1;
diff --git a/gcc/testsuite/gfortran.dg/value_8.f90 b/gcc/testsuite/gfortran.dg/value_8.f90
new file mode 100644 (file)
index 0000000..8273fe8
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! PR97491 - Wrong restriction for VALUE arguments of pure procedures
+
+pure function foo (x) result (ret)
+  integer        :: ret
+  integer, value :: x
+  x = x / 2
+  ret = x
+end function foo
+
+elemental function foo1 (x)
+  integer        :: foo1
+  integer, value :: x
+  x = x / 2
+  foo1 = x
+end function foo1
This page took 0.092658 seconds and 5 git commands to generate.