Commit 5e8c38c2 by Simon Martin Committed by Jason Merrill

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
parent 8e30dcf3
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
......
......@@ -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;
......
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment