]> gcc.gnu.org Git - gcc.git/commitdiff
Fortran: error recovery in frontend optimization [PR103715]
authorHarald Anlauf <anlauf@gmx.de>
Mon, 18 Mar 2024 18:36:59 +0000 (19:36 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Mon, 18 Mar 2024 18:36:59 +0000 (19:36 +0100)
gcc/fortran/ChangeLog:

PR fortran/103715
* frontend-passes.cc (check_externals_expr): Prevent invalid read
in case of mismatch of external subroutine with function.

gcc/testsuite/ChangeLog:

PR fortran/103715
* gfortran.dg/pr103715.f90: New test.

gcc/fortran/frontend-passes.cc
gcc/testsuite/gfortran.dg/pr103715.f90 [new file with mode: 0644]

index 06dfa1a32321b3b4c6a6ad38902fb705002c2fdd..3c06018fdbbff62a7405ddfd60733027538d6458 100644 (file)
@@ -5807,6 +5807,9 @@ check_externals_expr (gfc_expr **ep, int *walk_subtrees ATTRIBUTE_UNUSED,
   if (e->expr_type != EXPR_FUNCTION)
     return 0;
 
+  if (e->symtree && e->symtree->n.sym->attr.subroutine)
+    return 0;
+
   sym = e->value.function.esym;
   if (sym == NULL)
     return 0;
diff --git a/gcc/testsuite/gfortran.dg/pr103715.f90 b/gcc/testsuite/gfortran.dg/pr103715.f90
new file mode 100644 (file)
index 0000000..72c5a31
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/103715 - ICE in gfc_find_gsymbol
+!
+! valgrind did report an invalid read in check_externals_procedure
+
+program p
+  select type (y => g()) ! { dg-error "Selector shall be polymorphic" }
+  end select
+  call g()
+end
+
+! { dg-prune-output "already being used as a FUNCTION" }
This page took 0.083057 seconds and 5 git commands to generate.