From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 8F35F3857C60; Tue, 13 Feb 2024 19:27:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F35F3857C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707852431; bh=VHgZqqTGpNhblwDzRE1hjxv189a0DDdfPzuin0qqyB8=; h=From:To:Subject:Date:From; b=QAvI0ukDslh/bi5egqHaLH7WAkW1l/F+1Svw5sWmatV7+SuSo6j3mJTfwo6CQGWx4 GeHooYW9AkY4+ydyl+FqosM+TcojIPuSR75M9VUpA+LP6on2blPkSQGrBrjMCr14ua f97JIvB6ompmATETNmpMstoTyyf5yey3jpzj5E1k= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8963] c++/modules: ICEs with modular fmtlib X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: ce67b75e918bcbd31ed32bc820f5233c72670feb X-Git-Newrev: cb76d7e47693364861e63ea3bb274b1b5295a943 Message-Id: <20240213192711.8F35F3857C60@sourceware.org> Date: Tue, 13 Feb 2024 19:27:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cb76d7e47693364861e63ea3bb274b1b5295a943 commit r14-8963-gcb76d7e47693364861e63ea3bb274b1b5295a943 Author: Patrick Palka Date: Tue Feb 13 14:26:40 2024 -0500 c++/modules: ICEs with modular fmtlib Building modular fmtlib triggered two small modules bugs in C++23 and C++26 mode respectively (due to libstdc++ header differences). The first is that a TEMPLATE_DECL having DECL_LANG_SPECIFIC doesn't necessarily imply that its DECL_TEMPLATE_RESULT has DECL_LANG_SPECIFIC. So in add_specializations we need to use STRIP_TEMPLATE consistently; this is a follow-up to r12-7187-gdb84f382ae3dc2. The second is that get_originating_module_decl was ICEing on class-scope enumerators injected via using-enum. I suppose we should handle them like a class-scope entity rather than a non-using-enum enumerator. gcc/cp/ChangeLog: * module.cc (depset::hash::add_specializations): Use STRIP_TEMPLATE consistently. (get_originating_module_decl): Handle class-scope CONST_DECL. gcc/testsuite/ChangeLog: * g++.dg/modules/friend-6_a.C: New test. * g++.dg/modules/using-enum-3_a.C: New test. * g++.dg/modules/using-enum-3_b.C: New test. Reviewed-by: Jason Merill Diff: --- gcc/cp/module.cc | 5 +++-- gcc/testsuite/g++.dg/modules/friend-6_a.C | 11 +++++++++++ gcc/testsuite/g++.dg/modules/using-enum-3_a.C | 11 +++++++++++ gcc/testsuite/g++.dg/modules/using-enum-3_b.C | 6 ++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 560d8f3b6142..34fafe7c9788 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13256,7 +13256,7 @@ depset::hash::add_specializations (bool decl_p) if (use_tpl == 1) /* Implicit instantiations only walked if we reach them. */ needs_reaching = true; - else if (!DECL_LANG_SPECIFIC (spec) + else if (!DECL_LANG_SPECIFIC (STRIP_TEMPLATE (spec)) || !DECL_MODULE_PURVIEW_P (STRIP_TEMPLATE (spec))) /* Likewise, GMF explicit or partial specializations. */ needs_reaching = true; @@ -18716,7 +18716,8 @@ get_originating_module_decl (tree decl) && (TREE_CODE (DECL_CONTEXT (decl)) == ENUMERAL_TYPE)) decl = TYPE_NAME (DECL_CONTEXT (decl)); else if (TREE_CODE (decl) == FIELD_DECL - || TREE_CODE (decl) == USING_DECL) + || TREE_CODE (decl) == USING_DECL + || CONST_DECL_USING_P (decl)) { decl = DECL_CONTEXT (decl); if (TREE_CODE (decl) != FUNCTION_DECL) diff --git a/gcc/testsuite/g++.dg/modules/friend-6_a.C b/gcc/testsuite/g++.dg/modules/friend-6_a.C new file mode 100644 index 000000000000..7493e8f262fc --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/friend-6_a.C @@ -0,0 +1,11 @@ +// { dg-additional-options "-fmodules-ts -Wno-pedantic" } +// { dg-module-cmi friend_6 } + +module; +# 1 "" 1 +template struct Trans_NS___cxx11_basic_string { + template friend class basic_stringbuf; +}; +template struct Trans_NS___cxx11_basic_string; +# 6 "" 2 +export module friend_6; diff --git a/gcc/testsuite/g++.dg/modules/using-enum-3_a.C b/gcc/testsuite/g++.dg/modules/using-enum-3_a.C new file mode 100644 index 000000000000..10671eeaad44 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-enum-3_a.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++20 } } +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi using_enum_3 } + +export module using_enum_3; + +export +struct text_encoding { + enum class id { CP50220 }; + using enum id; +}; diff --git a/gcc/testsuite/g++.dg/modules/using-enum-3_b.C b/gcc/testsuite/g++.dg/modules/using-enum-3_b.C new file mode 100644 index 000000000000..8ac6e398ee75 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-enum-3_b.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++20 } } +// { dg-additional-options "-fmodules-ts" } + +import using_enum_3; + +static_assert(text_encoding::id::CP50220 == text_encoding::CP50220);