Now same_type_p rejects argument packs, we need to be more careful
calling it with template argument vector contents.
The mangler needs to do some comparisons to find the special
substitutions. While that code looks a little ugly, this seems the
smallest fix.
nathan
--
Nathan Sidwell
2020-03-06 Nathan Sidwell <nat...@acm.org>
PR c++/94027
* mangle.c (find_substitution): Don't call same_type_p on template
args that cannot match.
diff --git c/gcc/cp/mangle.c w/gcc/cp/mangle.c
index a0e888fde62..1fc78bfa753 100644
--- c/gcc/cp/mangle.c
+++ w/gcc/cp/mangle.c
@@ -628,6 +628,8 @@ find_substitution (tree node)
{
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 3
+ && (TREE_CODE (TREE_VEC_ELT (args, 0))
+ == TREE_CODE (char_type_node))
&& same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS)
@@ -652,7 +654,7 @@ find_substitution (tree node)
args <char, std::char_traits<char> > . */
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 2
- && TYPE_P (TREE_VEC_ELT (args, 0))
+ && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_CODE (char_type_node)
&& same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS))
diff --git c/gcc/testsuite/g++.dg/pr94027.C w/gcc/testsuite/g++.dg/pr94027.C
new file mode 100644
index 00000000000..03cd68f1b0f
--- /dev/null
+++ w/gcc/testsuite/g++.dg/pr94027.C
@@ -0,0 +1,22 @@
+// { dg-do compile { target c++11 } }
+// PR 94027 ICE mangling
+
+class a {
+public:
+ a (char);
+};
+struct b {
+ b (a);
+};
+template <typename... aw, int...>
+void ax (int)
+{
+ struct c : b {
+ c () : b {sizeof...(aw)}
+ {}
+ };
+}
+
+void az() {
+ ax ({});
+}