diff mbox

[C++] PR 47242

Message ID 4D63A7CE.70907@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Feb. 22, 2011, 12:10 p.m. UTC
Hi,

another patchlet for an ICE on invalid. Tested x86_64-linux.

Ok?

Thanks,
Paolo.

//////////////////////
/cp
2011-02-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/47242
	* semantics.c (build_lambda_object): Bail out if a field is
	error_mark_node.

/testsuite
2011-02-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/47242
	* g++.dg/cpp0x/lambda/lambda-ice4.C: New.

Comments

Jason Merrill Feb. 23, 2011, 12:19 a.m. UTC | #1
I tend to prefer a 'goto out' approach to dealing with cleanups.  OK 
either way.

Jason
Paolo Carlini Feb. 23, 2011, 12:23 a.m. UTC | #2
On 02/23/2011 01:19 AM, Jason Merrill wrote:
> I tend to prefer a 'goto out' approach to dealing with cleanups.  OK
> either way.
Eh, I regression tested yesterday exactly the 'goto out' (well, my label
was named 'fail' ;) version. Then I feared somebody could not like the
dreaded goto ;) Thus no problem, I'll apply locally that version,
regtest again, and commit.

Thanks,
Paolo.
Jason Merrill Feb. 23, 2011, 1:03 a.m. UTC | #3
On 02/22/2011 07:23 PM, Paolo Carlini wrote:
> was named 'fail' ;) version. Then I feared somebody could not like the
> dreaded goto ;)

But Knuth argued that goto is useful for error exits.  :)

Since we don't have destructors, the other options in this situation 
would be either code duplication, which I try hard to avoid, or 
splitting out the code between the save and restore of input_location 
into another function, which could be cleaner but seems like overkill in 
this case.

Jason
diff mbox

Patch

Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C	(revision 0)
@@ -0,0 +1,14 @@ 
+// PR c++/47242
+// { dg-options "-std=c++0x" }
+
+template < typename > void
+bar ()
+{
+  [i]{}; // { dg-error "declared|invalid" }
+}
+
+void
+foo ()
+{
+  bar<int>();
+}
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 170394)
+++ cp/semantics.c	(working copy)
@@ -7795,6 +7795,12 @@  build_lambda_object (tree lambda_expr)
       tree field = TREE_PURPOSE (node);
       tree val = TREE_VALUE (node);
 
+      if (field == error_mark_node)
+	{
+	  input_location = saved_loc;
+	  return error_mark_node;
+	}
+
       if (DECL_P (val))
 	mark_used (val);