From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH] PR fortran/65453 -- procedure statement vs subprogram name clash
Date: Sat, 17 Mar 2018 00:30:00 -0000 [thread overview]
Message-ID: <20180317003024.GA71071@troutmask.apl.washington.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 440 bytes --]
The attached patch fixes an ICE by detecting a name
clash between a procedure statement and a contained
subprogram. Regression tested on x86_64-*-freebsd.
2018-03-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/65453
* decl.c (get_proc_name): Catch clash between a procedure statement
and a contained subprogram
2018-03-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/65453
* gfortran.dg/pr65453.f90: New test.
--
Steve
[-- Attachment #2: pr65453.diff --]
[-- Type: text/x-diff, Size: 1185 bytes --]
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 258607)
+++ gcc/fortran/decl.c (working copy)
@@ -1219,6 +1219,12 @@ get_proc_name (const char *name, gfc_symbol **result,
gfc_error_now ("Procedure %qs at %C is already defined at %L",
name, &sym->declared_at);
+ if (sym->attr.external && sym->attr.procedure
+ && gfc_current_state () == COMP_CONTAINS)
+ gfc_error_now ("Contained procedure %qs at %C clashes with "
+ "procedure 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
Index: gcc/testsuite/gfortran.dg/pr65453.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr65453.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr65453.f90 (working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/65453
+! Contributed by Tobias Burnus <burnus at gcc.gnu.org>
+procedure() :: foo ! { dg-error "(1)" }
+ contains
+ subroutine foo() ! { dg-error "clashes with procedure" }
+ end
+end
next reply other threads:[~2018-03-17 0:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-17 0:30 Steve Kargl [this message]
2018-03-18 15:25 ` Thomas König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180317003024.GA71071@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).