diff mbox

[C++] PR 59120

Message ID 534FFBF3.6080300@oracle.com
State New
Headers show

Commit Message

Paolo Carlini April 17, 2014, 4:06 p.m. UTC
Hi,

we can fix this crash during error recovery very easily, by grouping 
together the two conditions leading to skip & early return, in complete 
analogy with the single-declaration case (note that we explicitly commit 
to tentative parse at the beginning of the function, thus we are good). 
Tested x86_64-linux.

Thanks,
Paolo.

///////////////////
/cp
2014-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/59120
	* parser.c (cp_parser_alias_declaration): Check return value of
	cp_parser_require.

/testsuite
2014-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/59120
	* g++.dg/cpp0x/alias-decl-42.C: New.

Comments

Jason Merrill April 20, 2014, 10:23 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 209472)
+++ cp/parser.c	(working copy)
@@ -16142,20 +16142,13 @@  cp_parser_alias_declaration (cp_parser* parser)
   if (parser->num_template_parameter_lists)
     parser->type_definition_forbidden_message = saved_message;
 
-  if (type == error_mark_node)
+  if (type == error_mark_node
+      || !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON))
     {
       cp_parser_skip_to_end_of_block_or_statement (parser);
       return error_mark_node;
     }
 
-  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
-
-  if (cp_parser_error_occurred (parser))
-    {
-      cp_parser_skip_to_end_of_block_or_statement (parser);
-      return error_mark_node;
-    }
-
   /* A typedef-name can also be introduced by an alias-declaration. The
      identifier following the using keyword becomes a typedef-name. It has
      the same semantics as if it were introduced by the typedef
Index: testsuite/g++.dg/cpp0x/alias-decl-42.C
===================================================================
--- testsuite/g++.dg/cpp0x/alias-decl-42.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/alias-decl-42.C	(working copy)
@@ -0,0 +1,4 @@ 
+// PR c++/59120
+// { dg-do compile { target c++11 } }
+
+template<typename T> using X = int T::T*;  // { dg-error "expected" }