From 64300da748c4b945cd384d20c4ac85a8db4caaba Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 16 Mar 2018 02:56:34 +0000 Subject: [PATCH] re PR fortran/78741 (ICE in gfc_get_symbol_decl, at fortran/trans-decl.c:1534) 2018-03-15 Steven G. Kargl PR fortran/78741 * decl.c (get_proc_name): Check for clash of entry name with subroutine name. 2018-03-15 Steven G. Kargl PR fortran/78741 * gfortran.dg/pr78741.f90: New test. From-SVN: r258581 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 7 ++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr78741.f90 | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr78741.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6e1af909a5a..818c50f9a19 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-03-15 Steven G. Kargl + + PR fortran/78741 + * decl.c (get_proc_name): Check for clash of entry name with + subroutine name. + 2018-03-15 Steven G. Kargl PR fortran/69395 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f5e6b31557c..64199a96094 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1209,11 +1209,16 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) accessible names. */ if (sym->attr.flavor != 0 && sym->attr.proc != 0 - && (sym->attr.subroutine || sym->attr.function) + && (sym->attr.subroutine || sym->attr.function || sym->attr.entry) && sym->attr.if_source != IFSRC_UNKNOWN) gfc_error_now ("Procedure %qs at %C is already defined at %L", name, &sym->declared_at); + if (sym->attr.flavor != 0 + && sym->attr.entry && sym->attr.if_source != IFSRC_UNKNOWN) + gfc_error_now ("Procedure %qs at %C is already defined at %L", + name, &sym->declared_at); + /* Trap a procedure with a name the same as interface in the encompassing scope. */ if (sym->attr.generic != 0 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9db78cd5d12..a07069f1acd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-15 Steven G. Kargl + + PR fortran/78741 + * gfortran.dg/pr78741.f90: New test. + 2018-03-15 Steven G. Kargl PR fortran/69395 diff --git a/gcc/testsuite/gfortran.dg/pr78741.f90 b/gcc/testsuite/gfortran.dg/pr78741.f90 new file mode 100644 index 00000000000..6eb85789f94 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78741.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! PR fortran/78741 +! Contributed by Gerhard Steinmetz +subroutine s(n, x) + integer :: n + character(n) :: x + character, pointer :: z(:) + x = 'a' + return +entry g(n, x) ! { dg-error "is already defined" } + x = 'b' +contains + subroutine g ! { dg-error "(1)" } + z(1) = x(1:1) + end +end -- 2.30.2