aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-11-21 20:32:51 +0000
committerNathan Sidwell <nathan@acm.org>2019-11-21 20:32:51 +0000
commit5f0feb1c16271dee895aff1e8db022c6aea295f0 (patch)
tree0981e0541bf7e92056681e07db81068ca741ba46
parent4c17df23817166f2066ddac5ba8e64b1bee84bf8 (diff)
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
-rw-r--r--ChangeLog.modules13
-rw-r--r--gcc/cp/module.cc72
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-1_a.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-1_b.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-2_b.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-2_c.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-2_d.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-4_a.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-4_b.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-5_a.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-spec-5_b.C2
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 <nathan@acm.org>
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 <nathan@acm.org>
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> (int y)
// { dg-final { scan-lang-dump {Dependencies of specialization function_decl:'::foo<int>'} module } }
// { dg-final { scan-lang-dump-not {Depending definition function_decl:'::foo<int>'} module } }
// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization declaration '::foo<int>'} module } }
-// { dg-final { scan-lang-dump {Specialization '::foo<int>' entity:[0-9]* keyed to '::foo<T>' \(2\)} module } }
+// { dg-final { scan-lang-dump {Specialization '::foo<int>' 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:.<T>'} 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:.<int>'} 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> (int y)
// { dg-final { scan-lang-dump {Dependencies of specialization function_decl:'::foo<int>'} module } }
// { dg-final { scan-lang-dump-not {Depending definition function_decl:'::foo<int>'} module } }
// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization declaration '::foo<int>'} module } }
-// { dg-final { scan-lang-dump {Specialization '::foo<int>' entity:[0-9]* keyed to '::foo@TPL:.<T>' \(2\)} module } }
+// { dg-final { scan-lang-dump {Specialization '::foo<int>' 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:.<T>'} 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:.<int>'} 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:.<T>'} 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:.<int>'} 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<int>
// { dg-final { scan-lang-dump {Dependencies of specialization type_decl:'::X<int>'} module } }
// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::X<int>'} module } }
-// { dg-final { scan-lang-dump {Specialization '::X<int>' entity:[0-9]* keyed to '::X<T>' \(2\)} module } }
+// { dg-final { scan-lang-dump {Specialization '::X<int>' 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:.<T>'} 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<typename T> struct X<T,1>
// { dg-final { scan-lang-dump {Dependency on specialization template_decl:'::X<T,0x1>' added} module } }
// { dg-final { scan-lang-dump {Cluster members:\n \[0\]=specialization definition '::X<T,0x1>'} module } }
-// { dg-final { scan-lang-dump {Specialization '::X<T,0x1>' entity:[0-9]* keyed to '::X<T,#unnamed#>' \(2\)} module } }
+// { dg-final { scan-lang-dump {Specialization '::X<T,0x1>' 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:.<T,#unnamed#>'} 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:.<T,0x1>' to '::X@TPL:.<T,#unnamed#>'} module } }