aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/decl.c2
-rw-r--r--gcc/testsuite/gfortran.dg/pr95342.f9020
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 93a155c..c85ae0d 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -7408,6 +7408,7 @@ gfc_match_function_decl (void)
procedure interface body. */
if (sym->attr.is_bind_c && sym->attr.module_procedure && sym->old_symbol
&& strcmp (sym->name, sym->old_symbol->name) == 0
+ && sym->binding_label && sym->old_symbol->binding_label
&& strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0)
{
const char *null = "NULL", *s1, *s2;
@@ -7923,6 +7924,7 @@ gfc_match_subroutine (void)
procedure interface body. */
if (sym->attr.module_procedure && sym->old_symbol
&& strcmp (sym->name, sym->old_symbol->name) == 0
+ && sym->binding_label && sym->old_symbol->binding_label
&& strcmp (sym->binding_label, sym->old_symbol->binding_label) != 0)
{
const char *null = "NULL", *s1, *s2;
diff --git a/gcc/testsuite/gfortran.dg/pr95342.f90 b/gcc/testsuite/gfortran.dg/pr95342.f90
new file mode 100644
index 0000000..41c987d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95342.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/95342 - ICE in gfc_match_subroutine, at fortran/decl.c:7913
+
+module m1
+ interface
+ module subroutine s()
+ end
+ subroutine s() bind(c) ! { dg-error "EXTERNAL attribute conflicts" }
+ end ! { dg-error "END INTERFACE" }
+ end interface
+end
+
+module m2
+ interface
+ module function f()
+ end
+ function f() bind(c)
+ end ! { dg-error "Duplicate EXTERNAL attribute" }
+ end interface
+end