re PR c++/28420 (ICE with "typeid" as template parameter)

PR c++/28420
        * parser.c (cp_parser_postfix_expression): Make sure that the
        saved value for parser->type_definition_forbidden_message is
        restored before returning to avoid an invalid free().

From-SVN: r116330
This commit is contained in:
Simon Martin 2006-08-22 18:51:40 +00:00 committed by Jason Merrill
parent 8e30dcf345
commit 5e8c38c2de
3 changed files with 16 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2006-08-22 Simon Martin <simartin@users.sourceforge.net>
PR c++/28420
* parser.c (cp_parser_postfix_expression): Make sure that the
saved value for parser->type_definition_forbidden_message is
restored before returning to avoid an invalid free().
2006-08-22 Jason Merrill <jason@redhat.com>
PR c++/28659

View File

@ -4076,12 +4076,12 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p)
/* Look for the `)' token. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
}
/* Restore the saved message. */
parser->type_definition_forbidden_message = saved_message;
/* `typeid' may not appear in an integral constant expression. */
if (cp_parser_non_integral_constant_expression(parser,
"`typeid' operator"))
return error_mark_node;
/* Restore the saved message. */
parser->type_definition_forbidden_message = saved_message;
}
break;

View File

@ -0,0 +1,7 @@
// This used to ICE (PR28420)
// { dg-do compile }
template<int> struct A;
int i = sizeof(A<typeid>); // { dg-error "operator cannot appear in a constant-expression|template argument 1 is invalid" }