From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7948) id 3D34F385840C; Thu, 25 Jan 2024 03:20:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D34F385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706152807; bh=UgJtWrpTWXrRPwJTXbpouLqhfeik/+85JqNnEeusSJs=; h=From:To:Subject:Date:From; b=YWfKUXskvirrGa+N+uRhYvLep7PTf6u/DDlmoQIi58X0xZheDfwpTpHWw6NjRGzJZ jF/JZIVL0Y5pt8fQk6ik1B7J1ZbCn0TT8L1OqBMYKkxNEtRo/2FSasnNVS2rOZjYNh Mhb2E/fm/IFAEaJ+Q1TgMyhG8XYYdhXmbXwqzVgk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathaniel Shead To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8408] c++: Handle partial specialisations in GMF [PR113405] X-Act-Checkin: gcc X-Git-Author: Nathaniel Shead X-Git-Refname: refs/heads/master X-Git-Oldrev: b433a6f5a0617dcbb28f2462b31198f86aadecaa X-Git-Newrev: 6ff54cc0be8dfa9d9bd5922ec65e86c9eb644711 Message-Id: <20240125032007.3D34F385840C@sourceware.org> Date: Thu, 25 Jan 2024 03:20:07 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6ff54cc0be8dfa9d9bd5922ec65e86c9eb644711 commit r14-8408-g6ff54cc0be8dfa9d9bd5922ec65e86c9eb644711 Author: Nathaniel Shead Date: Fri Jan 19 22:24:18 2024 +1100 c++: Handle partial specialisations in GMF [PR113405] Currently, when exporting names from the GMF, or within header modules, for a set of constrained partial specialisations we only emit the first one. This is because the 'type_specialization' list only includes a single specialization per template+argument list; constraints are not considered here. The existing code uses a separate 'partial_specializations' list to track this instead, but currently it's only used for declarations in the module purview. This patch makes use of this list for all declarations. PR c++/113405 gcc/cp/ChangeLog: * module.cc (set_defining_module): Track partial specialisations for all declarations. gcc/testsuite/ChangeLog: * g++.dg/modules/concept-9.h: New test. * g++.dg/modules/concept-9_a.C: New test. * g++.dg/modules/concept-9_b.C: New test. * g++.dg/modules/concept-10_a.H: New test. * g++.dg/modules/concept-10_b.C: New test. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/module.cc | 5 ++++- gcc/testsuite/g++.dg/modules/concept-10_a.H | 25 +++++++++++++++++++++++++ gcc/testsuite/g++.dg/modules/concept-10_b.C | 8 ++++++++ gcc/testsuite/g++.dg/modules/concept-9.h | 18 ++++++++++++++++++ gcc/testsuite/g++.dg/modules/concept-9_a.C | 13 +++++++++++++ gcc/testsuite/g++.dg/modules/concept-9_b.C | 8 ++++++++ 6 files changed, 76 insertions(+), 1 deletion(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 70785493561..f26b2265bce 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -18865,8 +18865,11 @@ set_defining_module (tree decl) gcc_checking_assert (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_IMPORT_P (decl)); - if (module_has_cmi_p ()) + if (module_p ()) { + /* We need to track all declarations within a module, not just those + in the module purview, because we don't necessarily know yet if + this module will require a CMI while in the global fragment. */ tree ctx = DECL_CONTEXT (decl); if (ctx && (TREE_CODE (ctx) == RECORD_TYPE || TREE_CODE (ctx) == UNION_TYPE) diff --git a/gcc/testsuite/g++.dg/modules/concept-10_a.H b/gcc/testsuite/g++.dg/modules/concept-10_a.H new file mode 100644 index 00000000000..c3a5fa727a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-10_a.H @@ -0,0 +1,25 @@ +// Also test header modules +// PR c++/113405 +// { dg-additional-options "-fmodule-header" } +// { dg-require-effective-target c++20 } +// { dg-module-cmi {} } + +template +concept foo = false; + +template +concept bar = true; + +template +struct corge {}; + +template +struct corge {}; + +template +struct corge { + using alias = int; +}; + +template +using corge_alias = corge::alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-10_b.C b/gcc/testsuite/g++.dg/modules/concept-10_b.C new file mode 100644 index 00000000000..67be13d5995 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-10_b.C @@ -0,0 +1,8 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } + +import "concept-10_a.H"; + +struct test {}; +using quux = corge_alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-9.h b/gcc/testsuite/g++.dg/modules/concept-9.h new file mode 100644 index 00000000000..1c7f003228c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9.h @@ -0,0 +1,18 @@ +// PR c++/113405 + +template +concept foo = false; + +template +concept bar = true; + +template +struct corge {}; + +template +struct corge {}; + +template +struct corge { + using alias = int; +}; diff --git a/gcc/testsuite/g++.dg/modules/concept-9_a.C b/gcc/testsuite/g++.dg/modules/concept-9_a.C new file mode 100644 index 00000000000..9a055b6dcc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9_a.C @@ -0,0 +1,13 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } +// { dg-module-cmi M } + +module; + +#include "concept-9.h" + +export module M; + +export template +using corge_alias = corge::alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-9_b.C b/gcc/testsuite/g++.dg/modules/concept-9_b.C new file mode 100644 index 00000000000..55a64a9a413 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9_b.C @@ -0,0 +1,8 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } + +import M; + +struct test {}; +using quux = corge_alias;