]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: fix dependency checks for inquiry refs [PR115039]
authorHarald Anlauf <anlauf@gmx.de>
Fri, 10 May 2024 19:18:03 +0000 (21:18 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Sat, 11 May 2024 17:40:21 +0000 (19:40 +0200)
gcc/fortran/ChangeLog:

PR fortran/115039
* expr.cc (gfc_traverse_expr): An inquiry ref does not constitute
a dependency and cannot collide with a symbol.

gcc/testsuite/ChangeLog:

PR fortran/115039
* gfortran.dg/statement_function_5.f90: New test.

gcc/fortran/expr.cc
gcc/testsuite/gfortran.dg/statement_function_5.f90 [new file with mode: 0644]

index 66edad58278a0b3a083014e0a01ccbac22c17910..c883966646cb01035636087d03266d226a61b9f9 100644 (file)
@@ -5500,7 +5500,7 @@ gfc_traverse_expr (gfc_expr *expr, gfc_symbol *sym,
          break;
 
        case REF_INQUIRY:
-         return true;
+         return false;
 
        default:
          gcc_unreachable ();
diff --git a/gcc/testsuite/gfortran.dg/statement_function_5.f90 b/gcc/testsuite/gfortran.dg/statement_function_5.f90
new file mode 100644 (file)
index 0000000..bc5a5db
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/115039
+!
+! Check that inquiry refs work with statement functions
+!
+! { dg-additional-options "-std=legacy -fdump-tree-optimized" }
+! { dg-prune-output " Obsolescent feature" }
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "optimized" } }
+
+program testit
+  implicit none
+  complex :: x
+  real    :: im
+  integer :: slen
+  character(5) :: s
+  im(x)   = x%im + x%re + x%kind
+  slen(s) = s%len
+  if (im((1.0,3.0) + (2.0,4.0)) /= 14.) stop 1
+  if (slen('abcdef') /= 5)              stop 2
+end program testit