From 5f0feb1c16271dee895aff1e8db022c6aea295f0 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 21 Nov 2019 20:32:51 +0000 Subject: gcc/cp/ * module.cc (trees_out::decl_node): Don't strip_template checking instantiation consistency. (depset::hash::add_{dependency,specializations}): Likewise. (get_originating_module_decl): Cope with template friends. Get to the template_decl. (get_instantiating_module_decl): Cope with template friends. Keep the template_decl. gcc/testsuite/ * g++.dg/modules/pl-spec-[1245]_[abcd].C: Adjust scans. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/c++-modules@278600 138bc75d-0d04-0410-961f-82ee72b054a4 --- ChangeLog.modules | 13 +++++- gcc/cp/module.cc | 72 ++++++++++++++--------------- gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C | 2 +- gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C | 2 +- 11 files changed, 57 insertions(+), 46 deletions(-) diff --git a/ChangeLog.modules b/ChangeLog.modules index 879ea9f5a34..926b347a2d4 100644 --- a/ChangeLog.modules +++ b/ChangeLog.modules @@ -1,12 +1,23 @@ 2019-11-21 Nathan Sidwell + gcc/cp/ + * module.cc (trees_out::decl_node): Don't strip_template checking + instantiation consistency. + (depset::hash::add_{dependency,specializations}): Likewise. + (get_originating_module_decl): Cope with template friends. Get to + the template_decl. + (get_instantiating_module_decl): Cope with template friends. Keep + the template_decl. + gcc/testsuite/ + * g++.dg/modules/pl-spec-[1245]_[abcd].C: Adjust scans. + gcc/cp/ * name-lookup.c (check_local_shadow): Bail out for clones. gcc/cp/ * module.cc (dumper::impl:nested_name): Obnly show module on imports. gcc/testsuite/ - * g++dg.modules: Anjust many scans. + * g++dg/modules: Anjust many scans. 2019-11-20 Nathan Sidwell diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 8f73f2e50c5..3af7a4e7f05 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -8113,8 +8113,7 @@ trees_out::decl_node (tree decl, walk_kind ref) them out if we did it. */ if (!streaming_p ()) { - gcc_checking_assert (STRIP_TEMPLATE (decl) - == get_instantiating_module_decl (decl)); + gcc_checking_assert (decl == get_instantiating_module_decl (decl)); dep = dep_hash->add_dependency (decl, depset::EK_MAYBE_SPEC); /* We should always insert or find something. */ gcc_assert (dep && dep->is_import () == (origin != 0)); @@ -11016,8 +11015,7 @@ depset::hash::add_dependency (tree decl, entity_kind ek) if (ek != EK_USING) /* We should only be given instantiating decls, except for voldemorts, where we should only get non-instantiating decls. */ - gcc_checking_assert ((STRIP_TEMPLATE (decl) - == get_instantiating_module_decl (decl)) + gcc_checking_assert ((decl == get_instantiating_module_decl (decl)) == (ek != EK_UNNAMED)); depset **slot = entity_slot (decl, true); @@ -11556,8 +11554,7 @@ depset::hash::add_specializations (bool decl_p) } } - gcc_checking_assert (STRIP_TEMPLATE (spec) - == get_instantiating_module_decl (spec)); + gcc_checking_assert (spec == get_instantiating_module_decl (spec)); bool needs_reaching = false; if (use_tpl == 1) @@ -17082,40 +17079,37 @@ get_originating_module_decl (tree decl) || TREE_CODE (decl) == CONCEPT_DECL || TREE_CODE (decl) == NAMESPACE_DECL); - for (tree ctx;; decl = ctx) + for (;;) { - ctx = CP_DECL_CONTEXT (decl); - if (TREE_CODE (ctx) == NAMESPACE_DECL) - break; + /* Uninstantiated template friends are owned by the befriending + class -- not their context. */ + if (TREE_CODE (decl) == TEMPLATE_DECL + && DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (decl)) + decl = TYPE_NAME (DECL_CHAIN (decl)); - if (TYPE_P (ctx)) + int use; + if (tree ti = node_template_info (decl, use)) + decl = TI_TEMPLATE (ti); + else { - ctx = TYPE_NAME (ctx); - if (!ctx) + tree ctx = CP_DECL_CONTEXT (decl); + if (TREE_CODE (ctx) == NAMESPACE_DECL) + break; + + if (TYPE_P (ctx)) { - /* Some kind of internal type. */ - gcc_checking_assert (DECL_ARTIFICIAL (decl)); - return global_namespace; + ctx = TYPE_NAME (ctx); + if (!ctx) + { + /* Some kind of internal type. */ + gcc_checking_assert (DECL_ARTIFICIAL (decl)); + return global_namespace; + } } + decl = ctx; } } - int use; - if (tree ti = node_template_info (decl, use)) - { - decl = TI_TEMPLATE (ti); - /* It could be a partial specialization, so look again. */ - ti = node_template_info (decl, use); - if (use > 0) - { - decl = TI_TEMPLATE (ti); - gcc_checking_assert ((node_template_info (decl, use), use <= 0)); - } - } - - if (TREE_CODE (decl) == TEMPLATE_DECL) - decl = DECL_TEMPLATE_RESULT (decl); - return decl; } @@ -17148,9 +17142,15 @@ get_instantiating_module_decl (tree decl) || TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == NAMESPACE_DECL); - for (tree ctx;; decl = ctx) + for (;;) { - ctx = CP_DECL_CONTEXT (decl); + /* Uninstantiated template friends are owned by the befriending + class -- not their context. */ + if (TREE_CODE (decl) == TEMPLATE_DECL + && DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (decl)) + decl = TYPE_NAME (DECL_CHAIN (decl)); + + tree ctx = CP_DECL_CONTEXT (decl); if (TREE_CODE (ctx) == NAMESPACE_DECL) break; @@ -17168,9 +17168,9 @@ get_instantiating_module_decl (tree decl) non-owning decl. */ return global_namespace; } - } - decl = STRIP_TEMPLATE (decl); + decl = ctx; + } return decl; } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C b/gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C index 90623079e76..4754bc8e9ff 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C @@ -17,6 +17,6 @@ template <> int foo (int y) // { dg-final { scan-lang-dump {Dependencies of specialization function_decl:'::foo'} module } } // { dg-final { scan-lang-dump-not {Depending definition function_decl:'::foo'} module } } // { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization declaration '::foo'} module } } -// { dg-final { scan-lang-dump {Specialization '::foo' entity:[0-9]* keyed to '::foo' \(2\)} module } } +// { dg-final { scan-lang-dump {Specialization '::foo' entity:[0-9]* keyed to '::foo' \(2\)} module } } // { dg-final { scan-assembler {_Z3fooIiEiT_:} } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C b/gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C index 68f3fd80a42..964732ffd67 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C @@ -13,7 +13,7 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } +// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } // { dg-final { scan-lang-dump-not {Reading definition function_decl '::foo@TPL:.'} module } } // { dg-final { scan-assembler-not {_Z3fooIiEiT_:} } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C b/gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C index d7f42510ed7..fbbe9cf15ff 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C @@ -13,6 +13,6 @@ template <> int foo (int y) // { dg-final { scan-lang-dump {Dependencies of specialization function_decl:'::foo'} module } } // { dg-final { scan-lang-dump-not {Depending definition function_decl:'::foo'} module } } // { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization declaration '::foo'} module } } -// { dg-final { scan-lang-dump {Specialization '::foo' entity:[0-9]* keyed to '::foo@TPL:.' \(2\)} module } } +// { dg-final { scan-lang-dump {Specialization '::foo' entity:[0-9]* keyed to '::foo@TPL:.' \(2\)} module } } // { dg-final { scan-assembler {_Z3fooIiEiT_:} } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C b/gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C index 229bd2a45e9..043f9388498 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C @@ -13,7 +13,7 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } +// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } // { dg-final { scan-lang-dump-not {Reading definition function_decl '::foo@TPL:.'} module } } // { dg-final { scan-assembler-not {_Z3fooIiEiT_:} } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C b/gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C index 47c2c986186..c5317852796 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C @@ -20,7 +20,7 @@ int two () return 0; } -// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } +// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::foo@TPL:.'} module } } // { dg-final { scan-lang-dump-not {Reading definition function_decl '::foo@TPL:.'} module } } // { dg-final { scan-assembler-not {_Z3fooIiEiT_:} } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C b/gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C index 730fa1afd4e..2d03e908a3f 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C @@ -16,4 +16,4 @@ template<> struct X // { dg-final { scan-lang-dump {Dependencies of specialization type_decl:'::X'} module } } // { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::X'} module } } -// { dg-final { scan-lang-dump {Specialization '::X' entity:[0-9]* keyed to '::X' \(2\)} module } } +// { dg-final { scan-lang-dump {Specialization '::X' entity:[0-9]* keyed to '::X' \(2\)} module } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C b/gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C index 5310e0ca3cb..27fd99ec824 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C @@ -14,4 +14,4 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::X@TPL:.'} module } } +// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::X@TPL:.'} module } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C b/gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C index 90fa7c1f804..77d7f657f0a 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C @@ -16,4 +16,4 @@ template struct X // { dg-final { scan-lang-dump {Dependency on specialization template_decl:'::X' added} module } } // { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::X'} module } } -// { dg-final { scan-lang-dump {Specialization '::X' entity:[0-9]* keyed to '::X' \(2\)} module } } +// { dg-final { scan-lang-dump {Specialization '::X' entity:[0-9]* keyed to '::X' \(2\)} module } } diff --git a/gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C b/gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C index ec201240328..bb396b1924a 100644 --- a/gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C +++ b/gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C @@ -14,5 +14,5 @@ int main () return 0; } -// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::X@TPL:.'} module } } +// { dg-final { scan-lang-dump {Reading 1 pending specializations keyed to '::X@TPL:.'} module } } // { dg-final { scan-lang-dump {Adding partial specialization '::X@TPL:.' to '::X@TPL:.'} module } } -- cgit v1.2.3