]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix template parm ICE [PR 98297]
authorNathan Sidwell <nathan@acm.org>
Wed, 16 Dec 2020 19:49:41 +0000 (11:49 -0800)
committerNathan Sidwell <nathan@acm.org>
Wed, 16 Dec 2020 20:02:02 +0000 (12:02 -0800)
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
gcc/testsuite/g++.dg/template/pr98297.C [new file with mode: 0644]

index dada13595268034cc2b67c95f96d6488a0a234de..cac1133d6f4381ff32ff2e1bce3175f3770a3112 100644 (file)
@@ -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 (file)
index 0000000..0dd63a5
--- /dev/null
@@ -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 }