Hi,
almost forgot that a few weeks ago I spent some time on this PR...
The issue is simple: in these repeated error conditions we ICE on the
gcc_assert in is_normal_capture_proxy: decl is a VAR_DECL with an
error_mark_node as TREE_TYPE.
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? Otherwise
robustifying a predicate like this seems a good idea to me. Patch passes
testing on x86_64-linux of course.
Thanks!
Paolo.
///////////////////////////
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" }
+}