From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CF9983882108 for ; Thu, 13 Jun 2024 15:06:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF9983882108 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CF9983882108 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718291176; cv=none; b=Aa696l4HYEq/9GlU5BApx5s5QMdekGAPX1wleVtVuP1p5WWLKPr+XNg5vBDfHl7OhaUcFPP6Py5BCmBtpogyX0be+tzJJtBtSq02Vocl8Tq19RmYp6O9rOvHuz4brpOvoEmxc9a/ljeqmcVaanGuS7c3v/9+aOJKr2vQwFuZcmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718291176; c=relaxed/simple; bh=nC0ED72eh2gruJO4M2PpIuecOCMZem5q2sagoxUkTyE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WBIBnCpCOQEG7KqzAXeA0nJFbdS0D/HcO4UNr8UMxYdtk+1jgKTyKctkwOGOz8RlHGRlgfvrNjm7lFT7Z+R+kl/+nZTEnCIpGcsCVxId4RwxGmqu+u7drEfJjNxbYj46XSFbzYgVji4/DZWSX2SXjlynDFzyCohHkmROLs5DhdM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718291173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GqTUOHh7PPZkpqBHGSSfciRP7WCG63asGNq86CQJEi8=; b=KYJEtwZ8dL755RARewlzQpMP9Qf/fVZy6gVupmD6jDfadhPegVFY1FOMY5XQGa0kNiMThp vGSc1ElAuBbqPoIN5Im8boraPwYCI4uHhFquJ/hT0My+BMvgLc2j71GlB5F7vlsJBjLJO4 4iqJbmD+b0OnHXYpX0EBaptySsonJ3w= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-qJoQCvpUN6m2PQ0PLrYnSQ-1; Thu, 13 Jun 2024 11:06:09 -0400 X-MC-Unique: qJoQCvpUN6m2PQ0PLrYnSQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-797d167a402so103391985a.2 for ; Thu, 13 Jun 2024 08:06:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718291168; x=1718895968; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GqTUOHh7PPZkpqBHGSSfciRP7WCG63asGNq86CQJEi8=; b=eMjVZUegJZ+fUop8MLUn1AuPsbAcImylJ1/j8P00o/7tpSH2SXmK4iHHldF+ni05Zs C3Nq5+THep1tjlVzt41z+Y053WsX9rH6XtprOKmF1NgjA4Ni0g0OsqAAYFStfS6KGOOR /8o0FvZEBx+SoGb4eISX53mcq1g4xXKxh4aIX8BVM78ZHqTe1G3lKQ9WEpbZQt/S/WlX 3DQ9mWUSJuHUJlltw6LupOORRCUM57AdZMdAYdg/4Iy2dMh4OwK711qsIQQGsgc7cQsc eqe2mwxmYVQSVIE0eWJfg2AJayDaEgiCiCNJj6NHCaAjotUl1A/RRcgE94u2YKWuqt+D daEg== X-Gm-Message-State: AOJu0YwQwR/Fmhp9uEn3PytFpd9hb5kv5LsWjUBE35tElkk4olLE8cJ2 unnWSYeX4epjJ7oH09uctYfYfDJs6OzirVI3Xu6R6xJFyERWNKjwVYEhN4G1IdMAq/+LerxcJQ+ SnZ0DxkkvLdNoGLWKjd/1HX+HEQMGkcpUGUXnmNm/Jgj+3zVng/aDDzPFSKsU8x4w0qthDVaSr3 DJvQGJL6gkE5pCpfKqVZnRug1GlpRs5jpj3ak= X-Received: by 2002:a05:620a:24c7:b0:797:a72e:678a with SMTP id af79cd13be357-797f606dc3fmr586392585a.3.1718291167516; Thu, 13 Jun 2024 08:06:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvusEXmzWKDEY5LIj+TFIKn8ooUB776BsyqB2G0ppgjwgf7Uti0zt9f6wMEcD0mJ2yRZuAow== X-Received: by 2002:a05:620a:24c7:b0:797:a72e:678a with SMTP id af79cd13be357-797f606dc3fmr586388785a.3.1718291166996; Thu, 13 Jun 2024 08:06:06 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc03812sm59059385a.93.2024.06.13.08.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:06:06 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: Nathaniel Shead Subject: [pushed] c++/modules: export using across namespace [PR114683] Date: Thu, 13 Jun 2024 11:05:01 -0400 Message-ID: <20240613150605.2715877-1-jason@redhat.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Currently we represent a non-function using-declaration by inserting the named declaration into the target scope. In general this works fine, but in the case of an exported using-declaration we have nowhere to mark the using-declaration as exported, so we mark the original declaration as exported instead, and then treat all using-declarations that name it as exported as well. We were doing this only if there was also a previous non-exported using, so for this testcase the export got lost; this patch broadens the workaround to also apply to the using that first brings the declaration into the current scope. This does not fully resolve 114683, but replaces a missing exports bug with an extra exports bug, which should be a significant usability improvement. The testcase has xfails for extra exports. I imagine a complete fix should involve inserting a USING_DECL. PR c++/114683 gcc/cp/ChangeLog: * name-lookup.cc (do_nonmember_using_decl): Allow exporting a newly inserted decl. gcc/testsuite/ChangeLog: * g++.dg/modules/using-22_a.C: New test. * g++.dg/modules/using-22_b.C: New test. --- gcc/cp/name-lookup.cc | 5 ++--- gcc/testsuite/g++.dg/modules/using-22_a.C | 24 +++++++++++++++++++++++ gcc/testsuite/g++.dg/modules/using-22_b.C | 13 ++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-22_a.C create mode 100644 gcc/testsuite/g++.dg/modules/using-22_b.C diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 71482db7b76..b57893116eb 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -5316,14 +5316,13 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, /* FIXME: Handle exporting declarations from a different scope without also marking those declarations as exported. This will require not just binding directly to the underlying - value; see c++/114863 and c++/114865. We allow this for purview - declarations for now as this doesn't (currently) cause ICEs + value; see c++/114683 and c++/114685. We allow the extra exports + for now as this doesn't (currently) cause ICEs later down the line, but this should be revisited. */ if (revealing_p) { if (module_exporting_p () && check_can_export_using_decl (lookup.value) - && lookup.value == value && !DECL_MODULE_EXPORT_P (lookup.value)) { /* We're redeclaring the same value, but this time as diff --git a/gcc/testsuite/g++.dg/modules/using-22_a.C b/gcc/testsuite/g++.dg/modules/using-22_a.C new file mode 100644 index 00000000000..9eca9dacb46 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-22_a.C @@ -0,0 +1,24 @@ +// PR c++/114683 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } + +module; + +namespace std +{ + inline namespace __cxx11 + { + template + struct basic_string{}; + } +} + +namespace foo { + using std::basic_string; +} + +export module std; + +export namespace std +{ + using std::basic_string; +} diff --git a/gcc/testsuite/g++.dg/modules/using-22_b.C b/gcc/testsuite/g++.dg/modules/using-22_b.C new file mode 100644 index 00000000000..0b66f4ad6b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-22_b.C @@ -0,0 +1,13 @@ +// { dg-additional-options "-fmodules-ts" } + +import std; + +int main() +{ + std::basic_string s; + + // The inline namespace should not be exported, only the 'using' in std. + std::__cxx11::basic_string s2; // { dg-error "has not been declared" "" { xfail *-*-* } } + // The non-exported using should also not be visible. + foo::basic_string s3; // { dg-error "has not been declared" "" { xfail *-*-* } } +} base-commit: 99e6cf404e37655be303e71f20df03c284c7989e -- 2.44.0