From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122903 invoked by alias); 17 Mar 2018 00:30:43 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 122772 invoked by uid 89); 17 Mar 2018 00:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=encompassing X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 17 Mar 2018 00:30:26 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w2H0UOdl071125 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 16 Mar 2018 17:30:24 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w2H0UOHR071124; Fri, 16 Mar 2018 17:30:24 -0700 (PDT) (envelope-from sgk) Date: Sat, 17 Mar 2018 00:30:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/65453 -- procedure statement vs subprogram name clash Message-ID: <20180317003024.GA71071@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="82I3+IH0IqGh5yIs" Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00092.txt.bz2 --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 440 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 PR fortran/65453 * decl.c (get_proc_name): Catch clash between a procedure statement and a contained subprogram 2018-03-16 Steven G. Kargl PR fortran/65453 * gfortran.dg/pr65453.f90: New test. -- Steve --82I3+IH0IqGh5yIs Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr65453.diff" Content-length: 1185 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 +procedure() :: foo ! { dg-error "(1)" } + contains + subroutine foo() ! { dg-error "clashes with procedure" } + end +end --82I3+IH0IqGh5yIs--