re PR fortran/61450 (ICE in gfc_global_used())
authorDominique d'Humieres <dominiq@lps.ens.fr>
Sun, 1 Oct 2017 09:49:48 +0000 (11:49 +0200)
committerDominique d'Humieres <dominiq@gcc.gnu.org>
Sun, 1 Oct 2017 09:49:48 +0000 (11:49 +0200)
2017-10-01  Dominique d'Humieres  <dominiq@lps.ens.fr>

PR fortran/61450
* parse.c (gfc_global_used): Replace the gfc_internal_error
with an error.

2017-10-01  Dominique d'Humieres  <dominiq@lps.ens.fr>

PR fortran/61450
* gfortran.dg/binding_label_tests_28.f90: New test.

From-SVN: r253328

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/binding_label_tests_28.f90 [new file with mode: 0644]

index b0c9c80..b5eea87 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-01  Dominique d'Humieres  <dominiq@lps.ens.fr>
+
+       PR fortran/61450
+       * parse.c (gfc_global_used): Replace the gfc_internal_error
+       with an error.
+
 2017-09-29  Dominique d'Humieres  <dominiq@lps.ens.fr>
 
        PR fortran/25071
index e958e6d..eb0f92e 100644 (file)
@@ -5742,16 +5742,28 @@ gfc_global_used (gfc_gsymbol *sym, locus *where)
       name = "MODULE";
       break;
     default:
-      gfc_internal_error ("gfc_global_used(): Bad type");
       name = NULL;
     }
 
-  if (sym->binding_label)
-    gfc_error ("Global binding name %qs at %L is already being used as a %s "
-              "at %L", sym->binding_label, where, name, &sym->where);
+  if (name)
+    {
+      if (sym->binding_label)
+       gfc_error ("Global binding name %qs at %L is already being used "
+                  "as a %s at %L", sym->binding_label, where, name,
+                  &sym->where);
+      else
+       gfc_error ("Global name %qs at %L is already being used as "
+                  "a %s at %L", sym->name, where, name, &sym->where);
+    }
   else
-    gfc_error ("Global name %qs at %L is already being used as a %s at %L",
-              sym->name, where, name, &sym->where);
+    {
+      if (sym->binding_label)
+       gfc_error ("Global binding name %qs at %L is already being used "
+                  "at %L", sym->binding_label, where, &sym->where);
+      else
+       gfc_error ("Global name %qs at %L is already being used at %L",
+                  sym->name, where, &sym->where);
+    }
 }
 
 
index fcf901a..40f5934 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-01  Dominique d'Humieres  <dominiq@lps.ens.fr>
+
+       PR fortran/61450
+       * gfortran.dg/binding_label_tests_28.f90: New test.
+
 2017-09-30  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/65949
diff --git a/gcc/testsuite/gfortran.dg/binding_label_tests_28.f90 b/gcc/testsuite/gfortran.dg/binding_label_tests_28.f90
new file mode 100644 (file)
index 0000000..0066a4a
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/61450
+! Contributed by Francois-Xavier Coudert  <fxcoudert@gmail.com>
+!
+module p
+  integer i1 ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+  bind(c,name="foo") :: i1
+end module
+
+subroutine truc() bind(c,name="foo") ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+end