From patchwork Sat Jul 11 17:24:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1327368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=wBMup47E; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B3xcQ1cNxz9sRR for ; Sun, 12 Jul 2020 03:24:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B4263857C69; Sat, 11 Jul 2020 17:24:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B4263857C69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594488287; bh=JDW3cLMCtzAFpvHc9pJSc6zEFBJg1X9I4WrE0MTmP4o=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wBMup47EDhAi0er3FaaF6Cv5Vnk0S0uC40rYf6denwzRlaeu8CXAsSflHO5RbjkaH x7mD93itOP/tieiapxVn2kTj5kIn/l04dSCG5+g/D2RP/anF070ElibATxqf41iLj1 6RnEoskhjRVmeqfoKKClp0+OH/UdSOmmGN3WCoiM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout1.netcologne.de (cc-smtpout1.netcologne.de [89.1.8.211]) by sourceware.org (Postfix) with ESMTPS id B6F523857C40; Sat, 11 Jul 2020 17:24:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B6F523857C40 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 4A26D1359D; Sat, 11 Jul 2020 19:24:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 3C2BB11ED7; Sat, 11 Jul 2020 19:24:43 +0200 (CEST) Received: from [2001:4dd7:45f4:0:b174:642:f4fa:3a17] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.11.6) (envelope-from ) id 5f09f5db-639b-7f0000012729-7f000001c0b4-1 for ; Sat, 11 Jul 2020 19:24:43 +0200 Received: from linux-p51k.fritz.box (2001-4dd7-45f4-0-b174-642-f4fa-3a17.ipv6dyn.netcologne.de [IPv6:2001:4dd7:45f4:0:b174:642:f4fa:3a17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sat, 11 Jul 2020 19:24:40 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran, committed] Fix PR 96073, ICE on new warning Message-ID: Date: Sat, 11 Jul 2020 19:24:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Language: de-DE X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thomas Koenig via Gcc-patches From: Thomas Koenig Reply-To: Thomas Koenig Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hello world, I have just committed the attached patch to master as obvious and simple. Explanation is in the ChangeLog below. Best regards Thomas Fix ICE on warning with new interface check (the patch for PR 27318). In the test case, there was a warning about INTENT where an EXTERNAL masked an interface in an outer scope, when the location of the symbol was not set, leading to an ICE. Two problems, two-part solution: It makes no sense to warn about INTENT for artificially generated formal argument lists, and the location should be set. gcc/fortran/ChangeLog: PR fortran/96073 * frontend-passes.c (check_externals_procedure): Add locus information for new_sym. * interface.c (gfc_check_dummy_characteristics): Do not warn about INTENT for artificially generated variables. gcc/testsuite/ChangeLog: PR fortran/96073 * gfortran.dg/interface_48.f90: New test diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 69f9ca64c97..7768fdc25ca 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -5441,6 +5441,7 @@ check_externals_procedure (gfc_symbol *sym, locus *loc, gfc_current_ns = gsym->ns; gfc_get_formal_from_actual_arglist (new_sym, actual); + new_sym->declared_at = *loc; gfc_current_ns = save_ns; return 0; diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 0cc504f4e04..e51820918b8 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1343,7 +1343,8 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, } /* Check INTENT. */ - if (s1->attr.intent != s2->attr.intent) + if (s1->attr.intent != s2->attr.intent && !s1->attr.artificial + && !s2->attr.artificial) { snprintf (errmsg, err_len, "INTENT mismatch in argument '%s'", s1->name); diff --git a/gcc/testsuite/gfortran.dg/interface_48.f90 b/gcc/testsuite/gfortran.dg/interface_48.f90 new file mode 100644 index 00000000000..f7513324172 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_48.f90 @@ -0,0 +1,31 @@ +! { dg-do compile } +! PR 96073 - this used to cause an ICE. +! Test case by Jürgen Reuter. + +module m + implicit none + private + + interface + subroutine GetXminM (set, xmin) + integer, intent(in) :: set + real, intent(out) :: xmin + end subroutine GetXminM + end interface + interface + subroutine foo(a) ! { dg-warning "Type mismatch" } + integer, intent(in) :: a + end subroutine foo + end interface + +contains + + subroutine s () + real :: xmin + integer :: set + external :: GetXminM, foo + call GetXminM (set, xmin) + call foo(1.0) ! { dg-warning "Type mismatch" } + end subroutine s + +end module m