| Submitter | Paolo Carlini |
|---|---|
| Date | Sept. 27, 2012, 11:08 a.m. |
| Message ID | <506433B1.1010206@oracle.com> |
| Download | mbox | patch |
| Permalink | /patch/187325/ |
| State | New |
| Headers | show |
Comments
On 09/27/2012 07:08 AM, Paolo Carlini wrote: > Then checking error_operand_p (decl) in is_capture_proxy solves the > problem but now the question is: do we have reasons to believe that such > VAR_DECLs should never ever reach is_normal_capture_proxy? That depends on our error recovery strategy for an invalid capture. It seems that we currently build a VAR_DECL that has an error_mark_node DECL_VALUE_EXPR; if we're going to do that, we need to deal with it. I guess we should return true in that case, if it doesn't cause more problems later on. Jason
Patch
Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 190666) +++ cp/semantics.c (working copy) @@ -8929,6 +8929,9 @@ capture_decltype (tree decl) bool is_capture_proxy (tree decl) { + if (error_operand_p (decl)) + return false; + return (TREE_CODE (decl) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (decl) && !DECL_ANON_UNION_VAR_P (decl) Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice8.C (revision 0) @@ -0,0 +1,10 @@ +// PR c++/51422 +// { dg-do compile { target c++11 } } + +template<typename> struct A {}; + +void foo() +{ + [i] { A<decltype(i)>(); }; // { dg-error "not declared|invalid" } + [i] { A<decltype(i)>(); }; // { dg-error "invalid" } +}