From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 807243858016; Wed, 9 Feb 2022 15:41:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 807243858016 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7133] c++: modules and explicit(bool) [PR103752] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: 8f8f8c68b434eb32756284dd8e80cfbdff524a20 X-Git-Newrev: 1ce5395977f37e8d0c03394f7b932a584ce85cc7 Message-Id: <20220209154123.807243858016@sourceware.org> Date: Wed, 9 Feb 2022 15:41:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Feb 2022 15:41:23 -0000 https://gcc.gnu.org/g:1ce5395977f37e8d0c03394f7b932a584ce85cc7 commit r12-7133-g1ce5395977f37e8d0c03394f7b932a584ce85cc7 Author: Jason Merrill Date: Wed Feb 9 00:31:12 2022 -0500 c++: modules and explicit(bool) [PR103752] We weren't streaming a C++20 dependent explicit-specifier. PR c++/103752 gcc/cp/ChangeLog: * module.cc (trees_out::core_vals): Stream explicit specifier. (trees_in::core_vals): Likewise. * pt.cc (store_explicit_specifier): No longer static. (tsubst_function_decl): Clear DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P. * cp-tree.h (lookup_explicit_specifier): Declare. gcc/testsuite/ChangeLog: * g++.dg/modules/explicit-bool-1_b.C: New test. * g++.dg/modules/explicit-bool-1_a.H: New test. Diff: --- gcc/cp/cp-tree.h | 1 + gcc/cp/module.cc | 10 ++++++++++ gcc/cp/pt.cc | 10 ++++++++-- gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C | 6 ++++++ gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H | 23 +++++++++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f09055e4852..f253b32c3f2 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7420,6 +7420,7 @@ extern bool copy_guide_p (const_tree); extern bool template_guide_p (const_tree); extern bool builtin_guide_p (const_tree); extern void store_explicit_specifier (tree, tree); +extern tree lookup_explicit_specifier (tree); extern void walk_specializations (bool, void (*)(bool, spec_entry *, void *), diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 81ceef92df3..3cf0af10bc0 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -6034,6 +6034,9 @@ trees_out::core_vals (tree t) WT (t->function_decl.function_specific_target); WT (t->function_decl.function_specific_optimization); WT (t->function_decl.vindex); + + if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) + WT (lookup_explicit_specifier (t)); break; case USING_DECL: @@ -6531,6 +6534,13 @@ trees_in::core_vals (tree t) RT (t->function_decl.function_specific_target); RT (t->function_decl.function_specific_optimization); RT (t->function_decl.vindex); + + if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) + { + tree spec; + RT (spec); + store_explicit_specifier (t, spec); + } } break; diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 862f337886c..5c995da62c6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13870,7 +13870,7 @@ store_explicit_specifier (tree v, tree t) /* Lookup an element in EXPLICIT_SPECIFIER_MAP. */ -static tree +tree lookup_explicit_specifier (tree v) { return *explicit_specifier_map->get (v); @@ -14103,7 +14103,13 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, /*function_p=*/false, /*i_c_e_p=*/true); spec = build_explicit_specifier (spec, complain); - DECL_NONCONVERTING_P (r) = (spec == boolean_true_node); + if (instantiation_dependent_expression_p (spec)) + store_explicit_specifier (r, spec); + else + { + DECL_NONCONVERTING_P (r) = (spec == boolean_true_node); + DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (r) = false; + } } /* OpenMP UDRs have the only argument a reference to the declared diff --git a/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C b/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C new file mode 100644 index 00000000000..27bfdee1a65 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/explicit-bool-1_b.C @@ -0,0 +1,6 @@ +// { dg-additional-options -fmodules-ts } +// { dg-require-effective-target c++20 } + +export module x; +import "explicit-bool-1_a.H"; +pair environment; diff --git a/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H b/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H new file mode 100644 index 00000000000..db4972139c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/explicit-bool-1_a.H @@ -0,0 +1,23 @@ +// PR c++/103752 +// { dg-additional-options -fmodule-header } +// { dg-require-effective-target c++20 } + +template +struct pair +{ + constexpr + explicit(__is_same(_T1, _T2)) + pair() + { } + + _T1 first; + _T2 second; +}; + +struct string +{ + string() { } + string(const char* s) : s(s) { } + + const char* s = ""; +};