public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-6157] c++: Fix template parm ICE [PR 98297]
@ 2020-12-16 19:57 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-12-16 19:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8d8bb85b48693a8a8a26e03ea4469888a1170f01
commit r11-6157-g8d8bb85b48693a8a8a26e03ea4469888a1170f01
Author: Nathan Sidwell <nathan@acm.org>
Date: Wed Dec 16 11:49:41 2020 -0800
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.
Diff:
---
gcc/cp/parser.c | 4 +++-
gcc/testsuite/g++.dg/template/pr98297.C | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7ea8c28830e..3883339aa64 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 00000000000..0dd63a57b5c
--- /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 }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-16 19:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 19:57 [gcc r11-6157] c++: Fix template parm ICE [PR 98297] Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).