]> gcc.gnu.org Git - gcc.git/commitdiff
PR fortran/95880 - ICE in gfc_add_type, at fortran/symbol.c:2030
authorHarald Anlauf <anlauf@gmx.de>
Sun, 28 Jun 2020 11:52:09 +0000 (13:52 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Sun, 28 Jun 2020 11:52:51 +0000 (13:52 +0200)
The fix for PR39695 did not properly distinguish between procedure names
and other symbols names in errors emitted for invalid code.  Fix that.

gcc/fortran/
PR fortran/95880
* symbol.c (gfc_add_type): If sym->ns->proc_name is set, use it,
otherwise fall back to sym->name.

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

index ba388ff598d3eb2acdb1e8926b9a9c7d8c82064b..96e4cee30401548f58e4be3c1eaaf676271ff39d 100644 (file)
@@ -2027,7 +2027,9 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
       || (flavor == FL_PROCEDURE && sym->attr.subroutine)
       || flavor == FL_DERIVED || flavor == FL_NAMELIST)
     {
-      gfc_error ("Symbol %qs at %L cannot have a type", sym->ns->proc_name->name, where);
+      gfc_error ("Symbol %qs at %L cannot have a type",
+                sym->ns->proc_name ? sym->ns->proc_name->name : sym->name,
+                where);
       return false;
     }
 
diff --git a/gcc/testsuite/gfortran.dg/pr95880.f90 b/gcc/testsuite/gfortran.dg/pr95880.f90
new file mode 100644 (file)
index 0000000..b7a573c
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/95880 - ICE in gfc_add_type, at fortran/symbol.c:2030 
+
+module m
+end
+block data
+   use m
+   integer m    ! { dg-error "cannot have a type" }
+end block data
This page took 0.079334 seconds and 5 git commands to generate.