[fortran] Fix PR 119078, putting a procedure in an abstract interface into global namespace
| Message ID | 19318f5a-fd0f-48db-9ec5-3eb661ecb252@netcologne.de |
|---|---|
| State | New |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA8773858D3C for <patchwork@sourceware.org>; Mon, 10 Mar 2025 20:03:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA8773858D3C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=netcologne.de header.i=@netcologne.de header.a=rsa-sha256 header.s=nc1116a header.b=NFWcTib6 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout3.netcologne.de (cc-smtpout3.netcologne.de [89.1.8.213]) by sourceware.org (Postfix) with ESMTPS id 759E23858D20; Mon, 10 Mar 2025 20:01:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 759E23858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=netcologne.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=netcologne.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 759E23858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.1.8.213 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741636900; cv=none; b=oEqTYobXaXgCMYL60aBAFEPfD6Jz1kN9fYGOc20nwgwXvM32eM5UoUhu8d9f6zQ4TwUk78BSbkO8KVM6U4hn9H3UkolDwnQofW8ncxV98Vhb3yULGOjWajTbYGGxqAql7b7EE3nVoIeHOXO95qvK74mlsh8DP1MV2xJUPCV1mB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741636900; c=relaxed/simple; bh=tQPc5FTgCiEi5QVY2Wx1XFGBjDGPIDr1777UuqH8uJ0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=ns1BSke7Jc/3rYBY57zxGh0CSd+rHWCtX4xoj2z266XtuMpwxR5w02w04sT4xTBn8Dl0Q9ZZcz2yEYJxKq/UTJaS406JQgRdqioSTrPFZs8GV3YRyD9NGLzpPL7PvWpXHz4Xf4Dc5q2sRUR4YAP3zTbPMUFfOkQcSvLQZHuXa0E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 759E23858D20 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id D653811E57; Mon, 10 Mar 2025 21:01:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1741636898; bh=tQPc5FTgCiEi5QVY2Wx1XFGBjDGPIDr1777UuqH8uJ0=; h=Message-ID:Date:To:From:Subject:From; b=NFWcTib6b3h7Vt40rsQpSfwokzJ1aq3bjhF4T3BE2wk2VwKfMdtOzg0DHPE422/sQ RvNvlEhDBftdxvh6KNqdPDHsE+4t4h3Wqj4272wsWomoWefUU2ihbxmQQpqBk/8SGC Aplm6XsfFEWAyqIdJsPEnlOxGRQdR2nEY6mAzmE37aM9Qm7gNuYvU5PcxwkCNxlWeC 2dnyiu6cUU1hjTovQKAfbJlDEW9ICc0aRzyQFsLDdxtSbRmjliOrg2LdvMas0pPdKI W8/mRaKpNwkXsV8a0ZXBDD+o/XnXe4Hgf+3lRRxpMqMI6p9J0g214Z6LJWGokgDVY8 +SF7XfP90GAdA== Received: from [IPV6:2001:4dd6:318b:0:4fe0:bc6d:79ff:7821] (2001-4dd6-318b-0-4fe0-bc6d-79ff-7821.ipv6dyn.netcologne.de [IPv6:2001:4dd6:318b:0:4fe0:bc6d:79ff:7821]) (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 cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id 8FCFD11D5A; Mon, 10 Mar 2025 21:01:36 +0100 (CET) Content-Type: multipart/mixed; boundary="------------QeB0Siov91xIWowBrmRqBNni" Message-ID: <19318f5a-fd0f-48db-9ec5-3eb661ecb252@netcologne.de> Date: Mon, 10 Mar 2025 21:01:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org> From: Thomas Koenig <tkoenig@netcologne.de> Subject: [patch, fortran] Fix PR 119078, putting a procedure in an abstract interface into global namespace X-NetCologne-Spam: L X-Rspamd-Queue-Id: 8FCFD11D5A X-Spamd-Bar: -- X-Rspamd-Action: no action X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[fortran] Fix PR 119078, putting a procedure in an abstract interface into global namespace
|
|
Commit Message
Thomas Koenig
March 10, 2025, 8:01 p.m. UTC
Hello world, the attached patch makes sure that procedures from abstract interfaces and dummy arguments are not put into the global symbol table, and are not checked against global symbols. Regression-tested. OK for trunk? Best regards Thomas Abstract interfaces and dummy arguments are not global. gcc/fortran/ChangeLog: PR fortran/119078 * frontend-passes.cc (check_against_globals): Do not check for abstract interfaces or dummy arguments. * resolve.cc (gfc_verify_binding_labels): Adjust comment. Do not put abstract interfaces or dummy argument into global namespace. gcc/testsuite/ChangeLog: PR fortran/119078 * gfortran.dg/interface_58.f90: New test
Comments
Hi Thomas, Am 10.03.25 um 21:01 schrieb Thomas Koenig: > Hello world, > > the attached patch makes sure that procedures from abstract > interfaces and dummy arguments are not put into the global > symbol table, and are not checked against global symbols. > > Regression-tested. OK for trunk? > > Best regards > > Thomas > > Abstract interfaces and dummy arguments are not global. > > gcc/fortran/ChangeLog: > > PR fortran/119078 > * frontend-passes.cc (check_against_globals): Do not check > for abstract interfaces or dummy arguments. > * resolve.cc (gfc_verify_binding_labels): Adjust comment. > Do not put abstract interfaces or dummy argument into global > namespace. > > gcc/testsuite/ChangeLog: > > PR fortran/119078 > * gfortran.dg/interface_58.f90: New test the patch looks basically fine but I cannot find the testcase. Cheers, Harald
Am 10.03.25 um 22:34 schrieb Harald Anlauf:
> the patch looks basically fine but I cannot find the testcase.
You're right, here it is.
Best regards
Thomas
diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 20bf6e127ff..ef9c80147cc 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -5799,7 +5799,8 @@ check_against_globals (gfc_symbol *sym)
char buf [200];
if (sym->attr.if_source != IFSRC_IFBODY || sym->attr.flavor != FL_PROCEDURE
- || sym->attr.generic || sym->error)
+ || sym->attr.generic || sym->error || sym->attr.abstract
+ || sym->attr.dummy)
return;
if (sym->binding_label)
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index eda31ba8adc..027c99335d1 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -13883,7 +13883,8 @@ gfc_verify_DTIO_procedures (gfc_symbol *sym)
/* Verify that any binding labels used in a given namespace do not collide
with the names or binding labels of any global symbols. Multiple INTERFACE
- for the same procedure are permitted. */
+ for the same procedure are permitted. Abstract interfaces and dummy
+ arguments are not checked. */
static void
gfc_verify_binding_labels (gfc_symbol *sym)
@@ -13892,7 +13893,8 @@ gfc_verify_binding_labels (gfc_symbol *sym)
const char *module;
if (!sym || !sym->attr.is_bind_c || sym->attr.is_iso_c
- || sym->attr.flavor == FL_DERIVED || !sym->binding_label)
+ || sym->attr.flavor == FL_DERIVED || !sym->binding_label
+ || sym->attr.abstract || sym->attr.dummy)
return;
gsym = gfc_find_case_gsymbol (gfc_gsym_root, sym->binding_label);
diff --git a/gcc/testsuite/gfortran.dg/interface_58.f90 b/gcc/testsuite/gfortran.dg/interface_58.f90
new file mode 100644
index 00000000000..52f3651567f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_58.f90
@@ -0,0 +1,38 @@
+! { dg-do compile }
+! PR 119078 - there should be no warning for dummy arguments
+! or abstract interfaces.
+module x
+ implicit none
+ abstract interface
+ subroutine foo() bind(c)
+ end subroutine foo
+ end interface
+ interface
+ subroutine baz() bind(c) ! { dg-warning "wrong number of arguments" }
+ end subroutine baz
+ end interface
+contains
+ subroutine tescht(bar) bind(c)
+ interface
+ subroutine bar() bind(c)
+ end subroutine bar
+ end interface
+ end subroutine tescht
+ subroutine t2(bar) bind(c)
+ procedure(foo) :: bar
+ end subroutine t2
+end module x
+
+subroutine foo(a)
+ real :: a
+end subroutine foo
+
+subroutine bar(b)
+ real :: b
+end subroutine bar
+
+subroutine baz(a) bind(c) ! { dg-warning "wrong number of arguments" }
+ use iso_c_binding, only : c_int
+ integer(c_int) :: a
+end subroutine baz
+
Hi Thomas, looks good to me as well. Thanks for the patch. Regards, Andre On Tue, 11 Mar 2025 07:11:53 +0100 Thomas Koenig <tkoenig@netcologne.de> wrote: > Am 10.03.25 um 22:34 schrieb Harald Anlauf: > > > the patch looks basically fine but I cannot find the testcase. > > You're right, here it is. > > Best regards > > Thomas -- Andre Vehreschild * Email: vehre ad gmx dot de
Am 11.03.25 um 10:22 schrieb Andre Vehreschild: > Hi Thomas, > > looks good to me as well. Thanks for the patch. Committed as r15-7964. Thanks Harald and Andre! Best regards Thomas
Hi Thomas, I think this patch produced a regression: FAIL: gfortran.dg/binding_label_tests_26b.f90 -O (test for errors, line 8) FAIL: gfortran.dg/binding_label_tests_26b.f90 -O (test for errors, line 9) When I revert your patch and test again, above fails do not occur. Could you please investigate, if I am right? Regards, Andre On Tue, 11 Mar 2025 17:45:16 +0100 Thomas Koenig <tkoenig@netcologne.de> wrote: > Am 11.03.25 um 10:22 schrieb Andre Vehreschild: > > Hi Thomas, > > > > looks good to me as well. Thanks for the patch. > > Committed as r15-7964. > > Thanks Harald and Andre! > > Best regards > > Thomas > -- Andre Vehreschild * Email: vehre ad gmx dot de
Hi Andre, > FAIL: gfortran.dg/binding_label_tests_26b.f90 -O (test for errors, line 8) > FAIL: gfortran.dg/binding_label_tests_26b.f90 -O (test for errors, line 9) > > When I revert your patch and test again, above fails do not occur. Could you > please investigate, if I am right? Jep, I missed that. The warning in the test case is bogus. binding_label_tests_26a.f90 has module fg contains function fffi(f) interface function f() bind(c) end function end interface end function end module so f is a dummy argument, which is not a global entity. binding_label_tests_26b.f90 has module f ! { dg-error "uses the same global identifier" } use fg ! { dg-error "uses the same global identifier" } end module so it tests for that error. The test case should stay, but I will remove the dg-error directives. Best regards Thomas
Am 12.03.25 um 18:33 schrieb Thomas Koenig: > > The test case should stay, but I will remove the dg-error directives. Fix committed as obvious and simple as r15-8006 . Thanks for the heads-up! Best regards Thomas
diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 20bf6e127ff..ef9c80147cc 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -5799,7 +5799,8 @@ check_against_globals (gfc_symbol *sym) char buf [200]; if (sym->attr.if_source != IFSRC_IFBODY || sym->attr.flavor != FL_PROCEDURE - || sym->attr.generic || sym->error) + || sym->attr.generic || sym->error || sym->attr.abstract + || sym->attr.dummy) return; if (sym->binding_label) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index eda31ba8adc..027c99335d1 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -13883,7 +13883,8 @@ gfc_verify_DTIO_procedures (gfc_symbol *sym) /* Verify that any binding labels used in a given namespace do not collide with the names or binding labels of any global symbols. Multiple INTERFACE - for the same procedure are permitted. */ + for the same procedure are permitted. Abstract interfaces and dummy + arguments are not checked. */ static void gfc_verify_binding_labels (gfc_symbol *sym) @@ -13892,7 +13893,8 @@ gfc_verify_binding_labels (gfc_symbol *sym) const char *module; if (!sym || !sym->attr.is_bind_c || sym->attr.is_iso_c - || sym->attr.flavor == FL_DERIVED || !sym->binding_label) + || sym->attr.flavor == FL_DERIVED || !sym->binding_label + || sym->attr.abstract || sym->attr.dummy) return; gsym = gfc_find_case_gsymbol (gfc_gsym_root, sym->binding_label);