[gcc(refs/users/guojiufu/heads/personal-branch)] PR fortran/95880 - ICE in gfc_add_type, at fortran/symbol.c:2030

Jiu Fu Guo guojiufu@gcc.gnu.org
Mon Aug 10 06:26:58 GMT 2020


https://gcc.gnu.org/g:f3a8f66a83f8c94f6fbb0233cefba8032f2e4876

commit f3a8f66a83f8c94f6fbb0233cefba8032f2e4876
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jun 28 13:52:09 2020 +0200

    PR fortran/95880 - ICE in gfc_add_type, at fortran/symbol.c:2030
    
    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.

Diff:
---
 gcc/fortran/symbol.c                  | 4 +++-
 gcc/testsuite/gfortran.dg/pr95880.f90 | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index ba388ff598d..96e4cee3040 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -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
index 00000000000..b7a573cba05
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95880.f90
@@ -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


More information about the Gcc-cvs mailing list