From patchwork Sat Jan 20 23:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 189781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1838567dyb; Sat, 20 Jan 2024 15:15:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtrL9uK2zY50K0IPdtI634YuFQZU4q2q0+4W8PQxw4yPFwleLrgz3t6EFu/WMV3tCtzygC X-Received: by 2002:a05:6214:262a:b0:681:7bb3:f4e8 with SMTP id gv10-20020a056214262a00b006817bb3f4e8mr5013137qvb.52.1705792500084; Sat, 20 Jan 2024 15:15:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705792500; cv=pass; d=google.com; s=arc-20160816; b=LJ3543lTtBfQttCfCnOw2DjfqtYVPDZwPFP9hIv9W7m6eW5bhLl8FJxlLxYhGWDg3z uIl5wVWABHJ8ixO3Unr3O3zUSp4mDxf/z0/YpqoyW/PF9A/7Rkjpj3lsAHZybWpvblzk 1Lshd4ImYdaw4+tRVrUwSEfvYQ/LcP1R3MLu1A+18mKwq85sgWwbFiv5MIUbpR7k65sq HmvCjVK6ZV9aqC5UP5bLDq2O7+n5M2moHTsmQJB4i2Iq3vh/VCO2IQzVDhNzdeEjOt7H Z3mPPd8ulq7He0D2YhPnkIOfIAMzkhLZDW6eUTFRZf4OtwZ7NJ21PbSQYxUkdyMLIq+m vFkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:subject:cc:to:from:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=gmUNrZrsXy5WcepyNe4jOQcsCe43P+5Sozppu8MMKwc=; fh=PSfnKtImOwcFiHTY31kD+1EEfyCGdToyJVXnD0Outng=; b=wTBuX0j5fXQvaWhconl200jiIkrxw4KJENqx7d2ztjXXQvQdekteu6D+0JaIQmYHna 13pkR5/cHTC+oLu1RtcDHUdUfxlfm1D7GfyWDDDAWseQKlFWbEzEB79w3jLn4AltZadS ssXSRcEpUSQy6RF92X76wwdM9rzrrX6aaFUWMqFe9Mlo42OTKk4hUSwOylcnqKF2eRN2 nCCVhNvzUOmUhCsd8qmyhRBvuvy5EhVjpS7/cR/uRInCUQfC4sN+JUFUOBCX1PCaOjoB tzM6C6DWURd/EpDaKin73g93qikjmZCAR542SgMlrIpyoa5wmEAddP34R4jH2cbMMImb X8hQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ds9iu+js; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v13-20020a0cdd8d000000b006849f471d12si2418992qvk.321.2024.01.20.15.14.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 15:15:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ds9iu+js; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4FD53858D3C for ; Sat, 20 Jan 2024 23:14:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 4396A3858D39 for ; Sat, 20 Jan 2024 23:14:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4396A3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4396A3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705792458; cv=none; b=OKyCOCf6DzrvKUGXmre3gMyMn2WJa2VbLt99Knoi+VDPpVnGDoOeTZi6USBwFm54M+eELSVvTYoYFsbtLdQe42BbVQAbWY6b/boeBnLdmFMYqLTmeUFc4vMCv8wzNZmRH/OlD5zff7KPi5YAND9Dr1/loIGY+Kc50SZFapC+ys0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705792458; c=relaxed/simple; bh=mJmeZzeBaHMvtlTJz/+mYkzbVQSysfbxjmXYj4NUhgI=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=NWbDEQU4ke4TQFd2t/sDCIf9r3UXJhtywoyHdTnytBgpPre5Tmv49itrRvrs5csSTRLz50SP3/ffc3wMsDuSrWdQMPOP5AwOGGfaLe9ylc4B5CI7xG1aHMqhF8ggXTPn0o2yMFn9a2qPeEWiWVUuaM1qNDLQ224HjElL5tub0Wc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d427518d52so14358795ad.0 for ; Sat, 20 Jan 2024 15:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705792452; x=1706397252; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=gmUNrZrsXy5WcepyNe4jOQcsCe43P+5Sozppu8MMKwc=; b=Ds9iu+jsZun7XnYbNlHbp7k2DlQ32H9E7emG8XAE4JFSvQfbro0DEB1LZ/CORvYQP+ SuEXVR9Q1rVYDumgD8P4YZLwR5pF0rgsfajg92iokvYuReGu8M6SbLZDxVAVIpplO7qh LM2tMEDxZppASWl0rhvBEgbHF/93IkwbTLGXw2UG3un5fAFG5wFbEEPqTVdHW5vgz2kB gL1mS9ZvSQy3a9sGzER/yEwM39MrBkQseKRwBVRFT6MV/GVhZRx8H1EwKKGDmXh/R2gD l6WtI01+uoISK+IGFg9++grNjIwNCeXBZg7030dpQAVzqjQ1XsxbxONgzlgOHQ/RVWdT bBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705792452; x=1706397252; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gmUNrZrsXy5WcepyNe4jOQcsCe43P+5Sozppu8MMKwc=; b=mnP+/ExEkzmnYXVSzoeLCwzAjMboTTbEwrStMAkrKl/4B+VAujHB46QkJTv9So+tAd BRoaNWQkjnILvxmSOYywssqmKvhNXwvNR94DKp6loS4ApdeOUDOLr5bSbG5SUCG9va5P wBHLv0z1u1e6Q0SVGZNtmmQd6gRbSVXBAiyibF9wSuZ1CVRqaZK+D8YeYucNHMek64qr tF0d+YpzcTOubwHYrO+I7RuGW9yEzElMRuXyifZjWOv3ViI0v33YBvdMteQTQsYX3LpZ c5bY76TsbUlt8+NjjcA4KlLmyqOnLfbULD9lQrcbyIQ3Qouxv4Lp4ZNwXoAurkiO+0EQ qMmw== X-Gm-Message-State: AOJu0Yz7eJPS5OQ9g00jRYb9XPVdRjje2s8JIS8cNV2AHulz1wm8VVLf kYfQplnCeOxHIzLgQbD65Pe0p2R+FWOCqmkJf/Nb9lVRyYLA0gVsAibXHiu/ X-Received: by 2002:a17:902:e9d4:b0:1d4:40f3:7ab9 with SMTP id 20-20020a170902e9d400b001d440f37ab9mr3694898plk.40.1705792451996; Sat, 20 Jan 2024 15:14:11 -0800 (PST) Received: from Thaum. (123-243-206-49.tpgi.com.au. [123.243.206.49]) by smtp.gmail.com with ESMTPSA id k17-20020a170902f29100b001d707a14316sm4717463plc.75.2024.01.20.15.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 15:14:11 -0800 (PST) Message-ID: <65ac53c3.170a0220.103a8.110b@mx.google.com> X-Google-Original-Message-ID: Date: Sun, 21 Jan 2024 10:14:06 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH] c++: Fix importing nested namespace declarations [PR100707] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788653076341281028 X-GMAIL-MSGID: 1788653076341281028 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- Currently, importing a namespace declarations marks it as imported, and so marks it as originating from the module that it was imported from. This is usually harmless, but causes problems with nested namespaces. In the linked PR, what happens is that the namespace 'A' imported from the module ends up not being considered when creating the 'A' namespace within its own TU, and thus it has its 'cp_binding_level' recreated. However, by this point 'A::B' has already been imported, and so the 'level_chain' member no longer correctly points at 'A's binding level, so the sanity check for this in 'resume_scope' ICEs. Since as far as I can tell there's no reason for imported namespaces to be attached to any specific module (namespace declarations with external linkage are always attached to the global module by [module.unit] p7.2), this patch just removes the 'imported' flag, which stops code from caring about its originating module. This patch also makes some minor adjustments to existing tests to cater for the new dumped name. PR c++/100707 gcc/cp/ChangeLog: * name-lookup.cc (add_imported_namespace): Don't mark namespaces as imported. gcc/testsuite/ChangeLog: * g++.dg/modules/indirect-1_b.C: Adjust to handle namespaces not being attached to the module they were imported from. * g++.dg/modules/indirect-1_c.C: Likewise. * g++.dg/modules/indirect-2_b.C: Likewise. * g++.dg/modules/indirect-2_c.C: Likewise. * g++.dg/modules/indirect-3_b.C: Likewise. * g++.dg/modules/indirect-3_c.C: Likewise. * g++.dg/modules/indirect-4_b.C: Likewise. * g++.dg/modules/indirect-4_c.C: Likewise. * g++.dg/modules/namespace-5_a.C: New test. * g++.dg/modules/namespace-5_b.C: New test. * g++.dg/modules/namespace-5_c.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/name-lookup.cc | 1 - gcc/testsuite/g++.dg/modules/indirect-1_b.C | 20 ++++++------- gcc/testsuite/g++.dg/modules/indirect-1_c.C | 30 ++++++++++---------- gcc/testsuite/g++.dg/modules/indirect-2_b.C | 20 ++++++------- gcc/testsuite/g++.dg/modules/indirect-2_c.C | 10 +++---- gcc/testsuite/g++.dg/modules/indirect-3_b.C | 16 +++++------ gcc/testsuite/g++.dg/modules/indirect-3_c.C | 10 +++---- gcc/testsuite/g++.dg/modules/indirect-4_b.C | 14 ++++----- gcc/testsuite/g++.dg/modules/indirect-4_c.C | 8 +++--- gcc/testsuite/g++.dg/modules/namespace-5_a.C | 6 ++++ gcc/testsuite/g++.dg/modules/namespace-5_b.C | 7 +++++ gcc/testsuite/g++.dg/modules/namespace-5_c.C | 5 ++++ 12 files changed, 82 insertions(+), 65 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/namespace-5_a.C create mode 100644 gcc/testsuite/g++.dg/modules/namespace-5_b.C create mode 100644 gcc/testsuite/g++.dg/modules/namespace-5_c.C diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 15b5fba6297..e58f3b5cb4d 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -9089,7 +9089,6 @@ add_imported_namespace (tree ctx, tree name, location_t loc, unsigned import, if (!decl) { decl = make_namespace (ctx, name, loc, inline_p); - DECL_MODULE_IMPORT_P (decl) = true; make_namespace_finish (decl, slot, true); } else if (DECL_NAMESPACE_INLINE_P (decl) != inline_p) diff --git a/gcc/testsuite/g++.dg/modules/indirect-1_b.C b/gcc/testsuite/g++.dg/modules/indirect-1_b.C index c450fa9481c..39e9d21ab76 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-1_b.C +++ b/gcc/testsuite/g++.dg/modules/indirect-1_b.C @@ -33,20 +33,20 @@ namespace bar export extern auto const Scoped_Const_Three = foo::Scoped::D; } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::frob'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::frob'@'foo' section:} module } } // { dg-final { scan-lang-dump-not {namespace:-[0-9]* namespace_decl:'::foo'} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* function_decl:'::foo@foo:.::frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* function_decl:'::foo::frob@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo@foo:.::X@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo::X@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::Y'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo@foo:.::Y@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::Y'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo::Y@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::B'@'foo' section:} module } } -// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::C@foo:.'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::Scoped'@'foo' section:} module } } -// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::Scoped@foo:.::[ABCD]'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::B'@'foo' section:} module } } +// { dg-final { scan-lang-dump-not {Lazily binding '::foo::C@foo:.'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::Scoped'@'foo' section:} module } } +// { dg-final { scan-lang-dump-not {Lazily binding '::foo::Scoped@foo:.::[ABCD]'@'foo' section:} module } } // { dg_final { scan-lang-dump {Wrote named import:-[0-9]* const_decl:'::foo::Plain@\(foo\)::C'@foo} module } } // { dg_final { scan-lang-dump {Wrote named import:-[0-9]* const_decl:'::foo::Plain@\(foo\)::B'@foo} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-1_c.C b/gcc/testsuite/g++.dg/modules/indirect-1_c.C index 73d5974c846..8ac0654a1eb 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-1_c.C +++ b/gcc/testsuite/g++.dg/modules/indirect-1_c.C @@ -23,27 +23,27 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::frob'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::frob'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[14\] section:4} module } } -// { dg-final { scan-lang-dump {Named:-[0-9]* namespace_decl:'::foo@foo:1'@foo} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo@foo:.::frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Named:-[0-9]* namespace_decl:'::foo'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo::frob@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[1\] section:1} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo@foo:.::X@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo::X@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Z'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::Z'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[8\] section:2} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo@foo:.::Y@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Read member:-[0-9]* field_decl:'::foo@foo:.::Y@foo:.::_vptr.Y'} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo@foo:.::Y@foo:.::frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo::Y@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Read member:-[0-9]* field_decl:'::foo::Y@foo:.::_vptr.Y'} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo::Y@foo:.::frob@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Plain_One'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::Plain_One'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[13\] section:3} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Scoped_One'@'bar' section} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::Scoped_One'@'bar' section} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[15\] section:5} module } } -// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::[ABC]'@'foo' section:} module } } -// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::Scoped@\(foo\)::[ABC]'@'foo' section:} module } } +// { dg-final { scan-lang-dump-not {Lazily binding '::foo::[ABC]'@'foo' section:} module } } +// { dg-final { scan-lang-dump-not {Lazily binding '::foo::Scoped@\(foo\)::[ABC]'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Plain_Const_Three'@'bar' section:} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Scoped_Const_Three'@'bar' section} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::Plain_Const_Three'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::Scoped_Const_Three'@'bar' section} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-2_b.C b/gcc/testsuite/g++.dg/modules/indirect-2_b.C index 16e060a2210..763899ed3e4 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-2_b.C +++ b/gcc/testsuite/g++.dg/modules/indirect-2_b.C @@ -17,15 +17,15 @@ namespace bar } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::frob'@'foo' section} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template frob@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::frob<0x0>'} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::frob'@'foo' section} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::frob<0x0>'} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template X@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template X@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo@foo:.::X<0x0>'\n \[1\]=specialization declaration '::foo@foo:.::X<0x0>::__conv_op <0x0>'\n \[2\]=specialization declaration '::foo@foo:.::X<0x0>::X<0x0>'\n( \[.\]=[^\n]* '\n)*} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::X<0x0>'} module } } -// { dg-final { scan-lang-dump {Depset:. specialization entity:. type_decl:'::foo@foo:.::X<0x0>'} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::X<0x0>'} module } } -// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo@foo:.::X<0x0>'} module } } +// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo::X<0x0>'\n \[1\]=specialization declaration '::foo::X<0x0>::__conv_op <0x0>'\n \[2\]=specialization declaration '::foo::X<0x0>::X<0x0>'\n( \[.\]=[^\n]* '\n)*} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::X<0x0>'} module } } +// { dg-final { scan-lang-dump {Depset:. specialization entity:. type_decl:'::foo::X<0x0>'} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::X<0x0>'} module } } +// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo::X<0x0>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-2_c.C b/gcc/testsuite/g++.dg/modules/indirect-2_c.C index a5cf44ba785..855c9d1f025 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-2_c.C +++ b/gcc/testsuite/g++.dg/modules/indirect-2_c.C @@ -13,13 +13,13 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::frob'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::frob'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[4\] section:2} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template frob@foo:.'@foo} module } } // { dg-final { scan-lang-dump-not {Wrote mergeable} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[1\] section:1} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template X@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Read:-[0-9]* function_decl:'::foo@foo:.::frob<0x0>'} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template X@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Read:-[0-9]* function_decl:'::foo::frob<0x0>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-3_b.C b/gcc/testsuite/g++.dg/modules/indirect-3_b.C index 038b01ecab7..a111bfbf11a 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-3_b.C +++ b/gcc/testsuite/g++.dg/modules/indirect-3_b.C @@ -17,14 +17,14 @@ namespace bar } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::X@foo:.::template frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::X@foo:.::template frob@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::TPL'@'foo' section} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::TPL'@'foo' section} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo@foo:.::TPL<0x0>'\n \[1\]=specialization definition '::foo@foo:.::TPL<0x0>::frob<0x0>'\n \[2\]=specialization declaration '::foo@foo:.::TPL<0x0>::TPL<0x0>'} module } } +// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo::TPL<0x0>'\n \[1\]=specialization definition '::foo::TPL<0x0>::frob<0x0>'\n \[2\]=specialization declaration '::foo::TPL<0x0>::TPL<0x0>'} module } } -// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo@foo:.::X@foo:.::frob<0x0>'} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::TPL<0x0>'} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::X@foo:.::frob<0x0>'} module } } +// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo::X@foo:.::frob<0x0>'} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::TPL<0x0>'} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::X@foo:.::frob<0x0>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-3_c.C b/gcc/testsuite/g++.dg/modules/indirect-3_c.C index ec2fc768373..0178ffb17f4 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-3_c.C +++ b/gcc/testsuite/g++.dg/modules/indirect-3_c.C @@ -13,12 +13,12 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[5\] section:2} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::X@foo:.::template frob@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::X@foo:.::template frob@foo:.'@foo} module } } // { dg-final { scan-lang-dump-not {Instantiation:-[0-9]* function_decl:'::foo::X@foo:.::frob@.()<0x0>'} module } } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::toto'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::toto'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[.\] section:1} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Reading definition type_decl '::foo@foo:.::TPL@bar:.<0x0>'} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Reading definition type_decl '::foo::TPL@bar:.<0x0>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-4_b.C b/gcc/testsuite/g++.dg/modules/indirect-4_b.C index 8c51ce8097b..702991d4d24 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-4_b.C +++ b/gcc/testsuite/g++.dg/modules/indirect-4_b.C @@ -12,11 +12,11 @@ namespace bar } } -// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::TPL'@'foo' section:} module } } -// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Lazily binding '::foo::TPL'@'foo' section:} module } } +// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo@foo:.::TPL<0x1>'\n \[1\]=specialization declaration '::foo@foo:.::TPL<0x1>::template frob<#unnamed#>'\n \[2\]=specialization declaration '::foo@foo:.::TPL<0x1>::TPL<0x1>'\n( \[.\]=[^\n]* '\n)*} module } } -// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo@foo:.::TPL<0x1>::frob<0x2>'} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::TPL<0x1>'} module } } -// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo@foo:.::TPL<0x1>'} module } } -// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::TPL<0x1>::frob<0x2>'} module } } +// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo::TPL<0x1>'\n \[1\]=specialization declaration '::foo::TPL<0x1>::template frob<#unnamed#>'\n \[2\]=specialization declaration '::foo::TPL<0x1>::TPL<0x1>'\n( \[.\]=[^\n]* '\n)*} module } } +// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::foo::TPL<0x1>::frob<0x2>'} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::TPL<0x1>'} module } } +// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo::TPL<0x1>'} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::TPL<0x1>::frob<0x2>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/indirect-4_c.C b/gcc/testsuite/g++.dg/modules/indirect-4_c.C index d55a2216fb3..206891fe07a 100644 --- a/gcc/testsuite/g++.dg/modules/indirect-4_c.C +++ b/gcc/testsuite/g++.dg/modules/indirect-4_c.C @@ -9,9 +9,9 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } } // { dg-final { scan-lang-dump {>Loading entity foo\[.\] section:1} module } } -// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } } +// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } } -// { dg-final { scan-lang-dump {Reading definition function_decl '::foo@foo:.::TPL@bar:.<0x1>::frob@bar:.<0x2>'} module } } -// { dg-final { scan-lang-dump {Reading definition type_decl '::foo@foo:.::TPL@bar:.<0x1>'} module } } +// { dg-final { scan-lang-dump {Reading definition function_decl '::foo::TPL@bar:.<0x1>::frob@bar:.<0x2>'} module } } +// { dg-final { scan-lang-dump {Reading definition type_decl '::foo::TPL@bar:.<0x1>'} module } } diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_a.C b/gcc/testsuite/g++.dg/modules/namespace-5_a.C new file mode 100644 index 00000000000..491eb1a1b45 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-5_a.C @@ -0,0 +1,6 @@ +// PR c++/100707 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi A } + +export module A; +export namespace A {} diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_b.C b/gcc/testsuite/g++.dg/modules/namespace-5_b.C new file mode 100644 index 00000000000..76a43bff207 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-5_b.C @@ -0,0 +1,7 @@ +// PR c++/100707 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi A.B } + +export module A.B; +import A; +export namespace A::B {} diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_c.C b/gcc/testsuite/g++.dg/modules/namespace-5_c.C new file mode 100644 index 00000000000..93ccbf0c3a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-5_c.C @@ -0,0 +1,5 @@ +// PR c++/100707 +// { dg-additional-options "-fmodules-ts" } + +import A.B; +namespace A::B {}