On 03/22/2012 07:28 PM, Jason Merrill wrote:
On 03/22/2012 12:58 PM, Paolo Carlini wrote:
Anyway, I also think not calling literal_type_p from check_field_decls
if the type is incomplete is pretty ugly, but I'm not sure which is the
best way to make progress
I guess that's OK. Just add a comment explaining that we'll get an
error later.
Done: I applied the below to mainline and 4_7-branch.
Thanks!
Paolo.
///////////////////
/cp
2012-03-22 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/52487
* class.c (check_field_decls): Call literal_type_p only
on complete types.
/testsuite
2012-03-22 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/52487
* g++.dg/cpp0x/lambda/lambda-ice7.C: New.
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/class.c
===================================================================
--- cp/class.c (revision 185715)
+++ cp/class.c (working copy)
@@ -3149,8 +3149,9 @@ check_field_decls (tree t, tree *access_decls,
CLASSTYPE_NON_AGGREGATE (t) = 1;
/* If at least one non-static data member is non-literal, the whole
- class becomes non-literal. */
- if (!literal_type_p (type))
+ class becomes non-literal. Note: if the type is incomplete we
+ will complain later on. */
+ if (COMPLETE_TYPE_P (type) && !literal_type_p (type))
CLASSTYPE_LITERAL_P (t) = false;
/* A standard-layout class is a class that: