2006-12-05 Mark Mitchell <mark@codesourcery.com>
+ PR c++/29729
+ * decl2.c (check_member_template): Move check for member
+ templates in local classes to ...
+ * parser.c (cp_parser_template_declaration_after_export):
+ ... here.
+
PR c++/29728
* decl.c (check_array_designated_initializer): New function.
(maybe_deduce_size_from_array_init): Use it.
|| (TREE_CODE (decl) == TYPE_DECL
&& IS_AGGR_TYPE (TREE_TYPE (decl))))
{
- if (current_function_decl)
- /* 14.5.2.2 [temp.mem]
-
- A local class shall not have member templates. */
- error ("invalid declaration of member template %q#D in local class",
- decl);
-
+ /* The parser rejects template declarations in local classes. */
+ gcc_assert (!current_function_decl);
/* The parser rejects any use of virtual in a function template. */
gcc_assert (!(TREE_CODE (decl) == FUNCTION_DECL
&& DECL_VIRTUAL_P (decl)));
/* And the `<'. */
if (!cp_parser_require (parser, CPP_LESS, "`<'"))
return;
+ if (at_class_scope_p () && current_function_decl)
+ {
+ /* 14.5.2.2 [temp.mem]
+
+ A local class shall not have member templates. */
+ error ("invalid declaration of member template in local class");
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ return;
+ }
/* [temp]
A template ... shall not have C linkage. */
2006-12-05 Mark Mitchell <mark@codesourcery.com>
+ PR c++/29729
+ * g++.dg/template/crash63.C: New test.
+
PR c++/29728
* g++.dg/template/crash62.C: New test.
--- /dev/null
+// PR c++/29729
+
+template<typename T> void foo(T)
+{
+ struct A
+ {
+ template<int> struct B // { dg-error "local class" }
+ {
+ typedef B<0> C;
+ }
+ };
+}