From patchwork Mon Jan 20 14:55:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1226010 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517793-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=a8/SDDrj; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 481ZVG66Fpz9sP6 for ; Tue, 21 Jan 2020 01:55:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=kqxtgj/nMhFIgi+1Pk9Z890plvoGPGvtVAljrjUBW8pl3BScHD NB6j+/jNWd9GUmW215n55Uturi4GcEKdnK4ehPSK94WHRBuiYhK6fVa2rjdVWl2r hoga9y+CQSECrwHJ89hJVkBUE0GsyJLRbZqz9ZLuPkcpKtbEpyC3H5ZoE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=kCXLrcioCvT6bha3ze7lhKwm5oY=; b=a8/SDDrjBV3g5ilXl0wH CaycFALcqmRLfionYSMBcq9tRhRmzUOT2zUnq6KDiE2JJEsUPjAHuClbu5cnQ1N2 UdD4P43vRda/yNo88WvfCd6Papt6B8PpjSfwVyNU68L/lMbv793B/uheWKQJkqAN tN/nDW6/7FMkTyZgEAFQ+AQ= Received: (qmail 131046 invoked by alias); 20 Jan 2020 14:55:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 131030 invoked by uid 89); 20 Jan 2020 14:55:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.7 required=5.0 tests=AWL, BAYES_00, GARBLED_SUBJECT, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=IMPLICIT X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Jan 2020 14:55:30 +0000 IronPort-SDR: fwG8ImFUnjeOtccKKQ31j14+/szMVYYe+znefWXAG1joJ62uDiPdyeTj+QhCnKFqKUFaspMWXT f0b3dNsO3cb6sWP1c1S9Re6tpcBpUilnedcQ81KcSQKDioeMmrvRopjfx1se4YYEHbdMIHM6fP dzvs8Fs4zEzQMeGoTaNYGJWfwW07IM7jZ50FKjljWEf47sJrcSavKSc4hXdM2K1B8dHeVJK8vP iZiW2tbrm+GPzScgG3uxfIkqh26oQl1O42jQWQO0IsZB0//qA04p++HekCFoHXPsj+PxUYmqbX W+s= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 20 Jan 2020 06:55:28 -0800 IronPort-SDR: E4beEl5jDWqqVnTsgI3JnolocKULlL6lFO/873buGYDKBYzVh74EH+lhADshXvLRoNfxgHcYUx 6el1u3T6V/GQ== To: gcc-patches , fortran From: Tobias Burnus Subject: =?utf-8?q?=5BPatch=2CFortran=5D_PR93309_=E2=80=93_permit_repeate?= =?utf-8?q?d_=27implicit_none=28external=29=27_in_sub-scoping_unit?= Message-ID: <08a3b3f3-1803-001a-4c72-94e3baf15181@codesourcery.com> Date: Mon, 20 Jan 2020 15:55:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 X-IsSubscribed: yes Using "implicit none" multiple times in a scoping unit is not permitted – and checked for. However, using one in the parent name space and re-confirming it in the current name space is permitted – but was before rejected. OK for the trunk? Tobias PR fortran/93309 * interface.c (gfc_procedure_use): Also check parent namespace for 'implict none (external)'. * symbol.c (gfc_get_namespace): Don't set has_implicit_none_export to parent namespace's setting. PR fortran/93309 * gfortran.dg/external_implicit_none_2.f90: New. diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index c4a6882533b..5193ac4a314 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -3798,8 +3798,13 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where) explicitly declared at all if requested. */ if (sym->attr.if_source == IFSRC_UNKNOWN && !sym->attr.is_iso_c) { + bool has_implicit_none_export = false; implicit = true; - if (sym->ns->has_implicit_none_export && sym->attr.proc == PROC_UNKNOWN) + if (sym->attr.proc == PROC_UNKNOWN) + for (gfc_namespace *ns = sym->ns; ns; ns = ns->parent) + if (ns->has_implicit_none_export) + has_implicit_none_export = true; + if (has_implicit_none_export) { const char *guessed = gfc_lookup_function_fuzzy (sym->name, sym->ns->sym_root); diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 526f6c466b3..47b716454f2 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -2898,9 +2898,6 @@ gfc_get_namespace (gfc_namespace *parent, int parent_types) } } - if (parent_types && ns->parent != NULL) - ns->has_implicit_none_export = ns->parent->has_implicit_none_export; - ns->refs = 1; return ns; diff --git a/gcc/testsuite/gfortran.dg/external_implicit_none_2.f90 b/gcc/testsuite/gfortran.dg/external_implicit_none_2.f90 new file mode 100644 index 00000000000..b2b1dd1e6d7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/external_implicit_none_2.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! +! PR fortran/93309 +! +module m + implicit none(external) +contains + subroutine s + implicit none(external) ! OK + end subroutine +end module + +module m2 + implicit none(external) +contains + subroutine s + call foo(1) ! { dg-error "not explicitly declared" } + end subroutine +end module + +module m3 + implicit none(external) +contains + subroutine s + implicit none(external) ! OK + implicit none(external) ! { dg-error "Duplicate IMPLICIT NONE statement" } + end subroutine +end module