diff mbox

C++ PATCH for c++/66533 (ICE with generic lambda)

Message ID 55C38D35.9020001@redhat.com
State New
Headers show

Commit Message

Jason Merrill Aug. 6, 2015, 4:37 p.m. UTC
In this testcase a tentative parse was failing, and after an error we 
called cp_parser_skip_to_end_of_statement, which messes with generic 
function scope.  So we shouldn't call that function during tentative 
parsing; we don't need to worry about error recovery then, anyway.

Tested x86_64-pc-linux-gnu, applying to trunk and 5.
diff mbox

Patch

commit 571aa064df4743ff9dc5ce03065c9623b6c4b2b5
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 6 12:00:01 2015 -0400

    	PR c++/66533
    	* parser.c (cp_parser_primary_expression): Don't skip to the end
    	of the statement if we're parsing tentatively.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b978fcf..bfad608 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4432,7 +4432,8 @@  cp_parser_primary_expression (cp_parser *parser,
 	parser->greater_than_is_operator_p
 	  = saved_greater_than_is_operator_p;
 	/* Consume the `)'.  */
-	if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
+	if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)
+	    && !cp_parser_uncommitted_to_tentative_parse_p (parser))
 	  cp_parser_skip_to_end_of_statement (parser);
 
 	return expr;
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice3.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice3.C
new file mode 100644
index 0000000..51e7a3f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice3.C
@@ -0,0 +1,3 @@ 
+// PR c++/66533
+// { dg-do compile { target c++14 } }
+auto a([](auto) -> decltype((void)0) {});