Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C (revision 0) @@ -0,0 +1,9 @@ +// PR c++/52487 +// { dg-options "-std=c++0x" } + +struct A; // { dg-error "forward declaration" } + +void foo(A& a) +{ + [=](){a;}; // { dg-error "invalid use of incomplete type" } +} Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 185571) +++ cp/semantics.c (working copy) @@ -5610,8 +5610,7 @@ literal_type_p (tree t) if (CLASS_TYPE_P (t)) { t = complete_type (t); - gcc_assert (COMPLETE_TYPE_P (t) || errorcount); - return CLASSTYPE_LITERAL_P (t); + return COMPLETE_TYPE_P (t) && CLASSTYPE_LITERAL_P (t); } if (TREE_CODE (t) == ARRAY_TYPE) return literal_type_p (strip_array_types (t));