aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2021-04-02 06:28:29 -0700
committerNathan Sidwell <nathan@acm.org>2021-04-02 09:08:28 -0700
commitf4e05eebd6aac6118cbd9e0a04c011b6ed682826 (patch)
treee82ecaf9f225b216826cd364e56cd899ea7001cf /gcc/cp/module.cc
parentc84491827990e4f2746442c23294fc17923b265d (diff)
downloadgcc-f4e05eebd6aac6118cbd9e0a04c011b6ed682826.zip
gcc-f4e05eebd6aac6118cbd9e0a04c011b6ed682826.tar.gz
gcc-f4e05eebd6aac6118cbd9e0a04c011b6ed682826.tar.bz2
c++: header unit purview [PR 99283]
This case occurs due to some equivocation about module_purview. Header-unit building is treated as a module-purview, but we should not treat entities imported from that as module purview. (header units were not a thing when I started). The testcase didn't understand we had a local textual definition, but it was (incorrectly) marked as module-purview, because we'd read in a declaration from a header unit too. gcc/cp/ * cp-tree.h (lang_decl_base): Correct module flag comment. * module.cc (trees_in::assert_definition): Break out not_tmpl var. (trees_out::lang_decl_bools): Do not write purview for header units. gcc/testsuite/ * g++.dg/modules/pr99283-6_d.H: New. * g++.dg/modules/pr99283-7-swap.h: New. * g++.dg/modules/pr99283-7-traits.h: New. * g++.dg/modules/pr99283-7_a.H: New. * g++.dg/modules/pr99283-7_b.H: New. * g++.dg/modules/pr99283-7_c.C: New. * g++.dg/modules/pr99283-7_d.H: New.
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index c87ddd1..d5b7d28 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4477,6 +4477,7 @@ trees_in::assert_definition (tree decl ATTRIBUTE_UNUSED,
{
#if CHECKING_P
tree *slot = note_defs->find_slot (decl, installing ? INSERT : NO_INSERT);
+ tree not_tmpl = STRIP_TEMPLATE (decl);
if (installing)
{
/* We must be inserting for the first time. */
@@ -4492,13 +4493,13 @@ trees_in::assert_definition (tree decl ATTRIBUTE_UNUSED,
gcc_assert (!is_duplicate (decl)
? !slot
: (slot
- || !DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
- || !DECL_MODULE_PURVIEW_P (STRIP_TEMPLATE (decl))
- || (!DECL_MODULE_IMPORT_P (STRIP_TEMPLATE (decl))
+ || !DECL_LANG_SPECIFIC (not_tmpl)
+ || !DECL_MODULE_PURVIEW_P (not_tmpl)
+ || (!DECL_MODULE_IMPORT_P (not_tmpl)
&& header_module_p ())));
- if (TREE_CODE (decl) == TEMPLATE_DECL)
- gcc_assert (!note_defs->find_slot (DECL_TEMPLATE_RESULT (decl), NO_INSERT));
+ if (not_tmpl != decl)
+ gcc_assert (!note_defs->find_slot (not_tmpl, NO_INSERT));
#endif
}
@@ -5519,7 +5520,9 @@ trees_out::lang_decl_bools (tree t)
WB (lang->u.base.concept_p);
WB (lang->u.base.var_declared_inline_p);
WB (lang->u.base.dependent_init_p);
- WB (lang->u.base.module_purview_p);
+ /* When building a header unit, everthing is marked as purview, but
+ that's the GM purview, so not what the importer will mean */
+ WB (lang->u.base.module_purview_p && !header_module_p ());
if (VAR_OR_FUNCTION_DECL_P (t))
WB (lang->u.base.module_attached_p);
switch (lang->u.base.selector)
@@ -11304,7 +11307,7 @@ trees_in::register_duplicate (tree decl, tree existing)
/* We've read a definition of MAYBE_EXISTING. If not a duplicate,
return MAYBE_EXISTING (into which the definition should be
installed). Otherwise return NULL if already known bad, or the
- duplicate we read (for ODR checking, or extracting addtional merge
+ duplicate we read (for ODR checking, or extracting additional merge
information). */
tree