===================================================================
@@ -0,0 +1,5 @@
+// PR c++/45043
+
+template < typename > class A;
+template < typename T > A < T >::B::~B () // { dg-error "type" }
+{}
===================================================================
@@ -8115,7 +8115,8 @@ grokdeclarator (const cp_declarator *declarator,
common. With no options, it is allowed. With -Wreturn-type,
it is a warning. It is only an error with -pedantic-errors. */
is_main = (funcdef_flag
- && dname && MAIN_NAME_P (dname)
+ && dname && TREE_CODE (dname) == IDENTIFIER_NODE
+ && MAIN_NAME_P (dname)
&& ctype == NULL_TREE
&& in_namespace == NULL_TREE
&& current_namespace == global_namespace);