diff mbox

[C++] PR 57352

Message ID 519D0FFC.3080607@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 22, 2013, 6:35 p.m. UTC
Hi,

avoiding this ICE on invalid seems just matter of setting up the 
parser->type_definition_forbidden_message string.

Tested x86_64-linux.

Thanks,
Paolo.

///////////////////////
/cp
2013-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57352
	* parser.c (cp_parser_conversion_type_id): Set up
	parser->type_definition_forbidden_message before calling
	cp_parser_type_specifier_seq.

/testsuite
2013-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57352
	* g++.dg/parse/crash62.C: New.

Comments

Jason Merrill May 22, 2013, 8:59 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 199204)
+++ cp/parser.c	(working copy)
@@ -11715,13 +11715,22 @@  cp_parser_conversion_type_id (cp_parser* parser)
   cp_decl_specifier_seq type_specifiers;
   cp_declarator *declarator;
   tree type_specified;
+  const char *saved_message;
 
   /* Parse the attributes.  */
   attributes = cp_parser_attributes_opt (parser);
+
+  saved_message = parser->type_definition_forbidden_message;
+  parser->type_definition_forbidden_message
+    = G_("types may not be defined in a conversion-type-id");
+
   /* Parse the type-specifiers.  */
   cp_parser_type_specifier_seq (parser, /*is_declaration=*/false,
 				/*is_trailing_return=*/false,
 				&type_specifiers);
+
+  parser->type_definition_forbidden_message = saved_message;
+
   /* If that didn't work, stop.  */
   if (type_specifiers.type == error_mark_node)
     return error_mark_node;
Index: testsuite/g++.dg/parse/crash62.C
===================================================================
--- testsuite/g++.dg/parse/crash62.C	(revision 0)
+++ testsuite/g++.dg/parse/crash62.C	(working copy)
@@ -0,0 +1,6 @@ 
+// PR c++/57352
+
+struct x
+{
+  operator class {} ();  // { dg-error "types|expected" }
+};