diff mbox

[C++] PR 72800

Message ID 15811e27-2bac-382a-ae3c-ff37fa7925fb@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Aug. 4, 2016, 5:02 p.m. UTC
Hi,

when back in 2014 I sent the patch for c++/61088 I noticed some cases 
where we wanted to return early error_mark_node from add_capture to 
avoid ICEs during error recovery when COMPLETE_TYPE_P is used on an 
error_mark_node. The new testcase noticed one additional case, where the 
error_mark_node is returned by lambda_capture_field_type. I propose to 
just immediately check it. Alternately we could add the check to the 
else branch of the following conditional (which also passes testing) or 
somewhere else too, I guess. Tested x86_64-linux.

Thanks,

Paolo.

////////////////////////
/cp
2016-08-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/72800
	* lambda.c (add_capture): Check lambda_capture_field_type return
	value for error_mark_node.

/testsuite
2016-08-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/72800
	* g++.dg/cpp1y/lambda-ice1.C: New.

Comments

Jason Merrill Aug. 4, 2016, 6:53 p.m. UTC | #1
OK.

On Thu, Aug 4, 2016 at 1:02 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> when back in 2014 I sent the patch for c++/61088 I noticed some cases where
> we wanted to return early error_mark_node from add_capture to avoid ICEs
> during error recovery when COMPLETE_TYPE_P is used on an error_mark_node.
> The new testcase noticed one additional case, where the error_mark_node is
> returned by lambda_capture_field_type. I propose to just immediately check
> it. Alternately we could add the check to the else branch of the following
> conditional (which also passes testing) or somewhere else too, I guess.
> Tested x86_64-linux.
>
> Thanks,
>
> Paolo.
>
> ////////////////////////
>
diff mbox

Patch

Index: cp/lambda.c
===================================================================
--- cp/lambda.c	(revision 239118)
+++ cp/lambda.c	(working copy)
@@ -492,6 +492,8 @@  add_capture (tree lambda, tree id, tree orig_init,
   else
     {
       type = lambda_capture_field_type (initializer, explicit_init_p);
+      if (type == error_mark_node)
+	return error_mark_node;
       if (by_reference_p)
 	{
 	  type = build_reference_type (type);
Index: testsuite/g++.dg/cpp1y/lambda-ice1.C
===================================================================
--- testsuite/g++.dg/cpp1y/lambda-ice1.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/lambda-ice1.C	(working copy)
@@ -0,0 +1,7 @@ 
+// PR c++/72800
+// { dg-do compile { target c++14 } }
+
+void foo ()
+{
+  [n {}] {};  // { dg-error "one element|deducing" }
+}