aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-16 11:49:41 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-16 11:57:31 -0800
commit8d8bb85b48693a8a8a26e03ea4469888a1170f01 (patch)
treeb38d3a2be52623f72cc2da0afabaa3c0cc8fadcd
parent3f78c8cb7f0e025a61734af8d9b9ad70e1b66e40 (diff)
downloadgcc-8d8bb85b48693a8a8a26e03ea4469888a1170f01.zip
gcc-8d8bb85b48693a8a8a26e03ea4469888a1170f01.tar.gz
gcc-8d8bb85b48693a8a8a26e03ea4469888a1170f01.tar.bz2
c++: Fix template parm ICE [PR 98297]
I think this is nonsense code, we seem to be naming an instantiation of a template template parm. But this fixes the ICE. Perhaps we should diagnose the issue earlier? gcc/cp/ * parser.c (cp_parser_elaborated_type_specifier): Test BOUND_TEMPLATE_TEMPLATE_PARM before checking for instantiation. gcc/testsuite/ * g++.dg/template/pr98297.C: New.
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/g++.dg/template/pr98297.C6
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7ea8c28..3883339 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19650,7 +19650,9 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
if (TREE_CODE (type) == TYPENAME_TYPE)
warning (OPT_Wattributes,
"attributes ignored on uninstantiated type");
- else if (tag_type != enum_type && CLASSTYPE_TEMPLATE_INSTANTIATION (type)
+ else if (tag_type != enum_type
+ && TREE_CODE (type) != BOUND_TEMPLATE_TEMPLATE_PARM
+ && CLASSTYPE_TEMPLATE_INSTANTIATION (type)
&& ! processing_explicit_instantiation)
warning (OPT_Wattributes,
"attributes ignored on template instantiation");
diff --git a/gcc/testsuite/g++.dg/template/pr98297.C b/gcc/testsuite/g++.dg/template/pr98297.C
new file mode 100644
index 0000000..0dd63a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr98297.C
@@ -0,0 +1,6 @@
+// PR 98297, ICE
+// { dg-do compile { target c++11 } }
+template <template <class> class a>
+struct [[b]]
+a <int>; // { dg-error "does not declare anything" }
+// { dg-warning "ignored" "" { target *-*-* } .-1 }