Message ID | 4D63A7CE.70907@oracle.com |
---|---|
State | New |
Headers | show |
I tend to prefer a 'goto out' approach to dealing with cleanups. OK either way. Jason
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.
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
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);