From 27a2ffea55852d3eb73bbec8bb610dd8c5b14f76 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 16 Dec 2020 11:49:41 -0800 Subject: [PATCH] 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. --- gcc/cp/parser.c | 4 +++- gcc/testsuite/g++.dg/template/pr98297.C | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/pr98297.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dada13595268..cac1133d6f43 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -18997,7 +18997,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 000000000000..0dd63a57b5cc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr98297.C @@ -0,0 +1,6 @@ +// PR 98297, ICE +// { dg-do compile { target c++11 } } +template