diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-03-06 10:51:26 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-03-06 10:51:26 -0800 |
commit | 191bcd0f30dd37dec773efb0125afdcae9bd90ef (patch) | |
tree | 283aa99d8c6229b01375dcb502ea8f155365f9dc /gcc | |
parent | 0b8393221177617f19e7c5c5c692b8c59f85fffb (diff) | |
download | gcc-191bcd0f30dd37dec773efb0125afdcae9bd90ef.zip gcc-191bcd0f30dd37dec773efb0125afdcae9bd90ef.tar.gz gcc-191bcd0f30dd37dec773efb0125afdcae9bd90ef.tar.bz2 |
Fix mangling ICE [PR94027]
PR c++/94027
* mangle.c (find_substitution): Don't call same_type_p on template
args that cannot match.
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr94027.C | 22 |
3 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f01563e..98640a6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-06 Nathan Sidwell <nathan@acm.org> + + PR c++/94027 + * mangle.c (find_substitution): Don't call same_type_p on template + args that cannot match. + 2020-03-04 Martin Sebor <msebor@redhat.com> PR c++/90938 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index a0e888f..1fc78bf 100644 --- a/gcc/cp/mangle.c +++ b/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 a/gcc/testsuite/g++.dg/pr94027.C b/gcc/testsuite/g++.dg/pr94027.C new file mode 100644 index 0000000..03cd68f --- /dev/null +++ b/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 ({}); +} |