Apologies, 2nd attempt:
gcc/fortran/ChangeLog:
Steven G. Kargl <ka...@gcc.gnu.org>
PR fortran/93814
* resolve.c (gfc_verify_binding_labels): Handle symbols with
the subroutine attribute separately from symbols with the
function attribute.
gcc/testsuite/ChanheLog:
Mark Eggleston <mark.eggles...@codethink.com>
PR fortran/93814
* gfortran.dg/pr93814.f90: New test.
OK to commit?
On 22/03/2020 17:46, Thomas Koenig wrote:
Hi Mark,
Please find attached Steve Kargl's fix for PR93814.
The attached patch does not match the ChangeLog; it seems to
be for PR93484.
Regards
Thomas
--
https://www.codethink.co.uk/privacy.html
>From 743b915bfef6c798e3b001ff8759739e9fc52ec1 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggles...@gcc.gnu.org>
Date: Fri, 21 Feb 2020 10:52:52 +0000
Subject: [PATCH] fortran: ICE in build_entry_thunks PR93814
Patch provided by Steve Kargl. Test case provided by G. Steinmetz.
gcc/fortran/ChangeLog:
PR fortran/93814
* resolve.c (gfc_verify_binding_labels): Handle symbols with
the subroutine attribute separately from symbols with the
function attribute.
gcc/testsuite/ChanheLog:
PR fortran/93814
* gfortran.dg/pr93814.f90: New test.
---
gcc/fortran/resolve.c | 23 ++++++++++++++++++++---
gcc/testsuite/gfortran.dg/pr93814.f90 | 8 ++++++++
2 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr93814.f90
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 8f5267fde05..81d855eaa54 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -12236,9 +12236,26 @@ gfc_verify_binding_labels (gfc_symbol *sym)
return;
}
- if ((sym->attr.function || sym->attr.subroutine)
- && ((gsym->type != GSYM_SUBROUTINE && gsym->type != GSYM_FUNCTION)
- || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY))
+ if (sym->attr.function
+ && (gsym->type != GSYM_FUNCTION
+ || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY))
+ && (sym != gsym->ns->proc_name)
+ && (module != gsym->mod_name
+ || strcmp (gsym->sym_name, sym->name) != 0
+ || (module && strcmp (module, gsym->mod_name) != 0)))
+ {
+ /* Print an error if the procedure is defined multiple times; we have to
+ exclude references to the same procedure via module association or
+ multiple checks for the same procedure. */
+ gfc_error ("Procedure %qs with binding label %qs at %L uses the same "
+ "global identifier as entity at %L", sym->name,
+ sym->binding_label, &sym->declared_at, &gsym->where);
+ sym->binding_label = NULL;
+ }
+
+ if (sym->attr.subroutine
+ && (gsym->type != GSYM_SUBROUTINE
+ || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY))
&& (sym != gsym->ns->proc_name && sym->attr.entry == 0)
&& (module != gsym->mod_name
|| strcmp (gsym->sym_name, sym->name) != 0
diff --git a/gcc/testsuite/gfortran.dg/pr93814.f90 b/gcc/testsuite/gfortran.dg/pr93814.f90
new file mode 100644
index 00000000000..9eb818ca478
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93814.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! Test case by G. Steinmetz
+
+function f() bind(c)
+character :: f, g ! { dg-error "1" }
+entry g() bind(c) ! { dg-error "Procedure 'g' with binding label 'g'" }
+end
+
--
2.11.0