re PR c++/64129 (ICE on invalid: in grokfndecl, at cp/decl.c:7658)

PR c++/64129
	* decl.c (grokdeclarator): Recover from variable template
	specialization declared as function.

From-SVN: r218557
This commit is contained in:
Jason Merrill 2014-12-09 21:51:03 -05:00 committed by Jason Merrill
parent 9c78f8e605
commit 59bce71381
3 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2014-12-09 Jason Merrill <jason@redhat.com>
PR c++/64129
* decl.c (grokdeclarator): Recover from variable template
specialization declared as function.
PR c++/64222
* parser.c (cp_parser_unqualified_id): Don't declare fname while
parsing function parms.

View File

@ -10739,6 +10739,19 @@ grokdeclarator (const cp_declarator *declarator,
return error_mark_node;
}
if (TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR)
{
tree tmpl = TREE_OPERAND (unqualified_id, 0);
if (variable_template_p (tmpl))
{
error ("specialization of variable template %qD "
"declared as function", tmpl);
inform (DECL_SOURCE_LOCATION (tmpl),
"variable template declared here");
return error_mark_node;
}
}
/* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */
function_context = (ctype != NULL_TREE) ?
decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE;

View File

@ -0,0 +1,5 @@
// PR c++/64129
template <0> int __copy_streambufs_eof; // { dg-error "" }
class {
friend __copy_streambufs_eof <> ( // { dg-error "" }