https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61450

            Bug ID: 61450
           Summary: ICE in gfc_global_used()
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org

$ cat w.f90 
module p
  integer i1
  bind(c,name="foo") :: i1
end module

subroutine truc() bind(c,name="foo")
end

$ gfortran w.f90
w.f90:6.36:

subroutine truc() bind(c,name="foo")
                                    1
Internal Error at (1):
gfc_global_used(): Bad type


I don't know exactly how this specific case arises, but as it's "only" a
diagnostics trying to be extra smart, I suggest to give it a more decent
fallback, e.g.:

Index: parse.c
===================================================================
--- parse.c    (revision 211315)
+++ parse.c    (working copy)
@@ -4313,33 +4313,32 @@ gfc_global_used (gfc_gsymbol *sym, locus
   switch(sym->type)
     {
     case GSYM_PROGRAM:
-      name = "PROGRAM";
+      name = "as a PROGRAM ";
       break;
     case GSYM_FUNCTION:
-      name = "FUNCTION";
+      name = "as a FUNCTION ";
       break;
     case GSYM_SUBROUTINE:
-      name = "SUBROUTINE";
+      name = "as a SUBROUTINE ";
       break;
     case GSYM_COMMON:
-      name = "COMMON";
+      name = "as a COMMON ";
       break;
     case GSYM_BLOCK_DATA:
-      name = "BLOCK DATA";
+      name = "as a BLOCK DATA ";
       break;
     case GSYM_MODULE:
-      name = "MODULE";
+      name = "as a MODULE ";
       break;
     default:
-      gfc_internal_error ("gfc_global_used(): Bad type");
-      name = NULL;
+      name = "";
     }

   if (sym->binding_label)
-    gfc_error ("Global binding name '%s' at %L is already being used as a %s "
+    gfc_error ("Global binding name '%s' at %L is already being used %s"
            "at %L", sym->binding_label, where, name, &sym->where);
   else
-    gfc_error ("Global name '%s' at %L is already being used as a %s at %L",
+    gfc_error ("Global name '%s' at %L is already being used %sat %L",
            sym->name, where, name, &sym->where);
 }

Reply via email to