re PR c++/52487 ([C++11] ICE at cp/semantics.c:5613 with lambda capturing reference...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 23 Mar 2012 00:35:33 +0000 (00:35 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 23 Mar 2012 00:35:33 +0000 (00:35 +0000)
/cp
2012-03-22  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/52487
* g++.dg/cpp0x/lambda/lambda-ice7.C: New.

From-SVN: r185722

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C [new file with mode: 0644]

index 7da7f59872f01b4055072fd3650ead6af1fe27c3..0fc0bd8a7f64c21dc4d2f32fcb23eb55a0d19e20 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-22  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52487
+       * class.c (check_field_decls): Call literal_type_p only
+       on complete types.
+
 2012-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/52671
index 6ed4cde6b51a4d8052435158a4e1151224e73944..bc17c82c6a0308fa15c5fe80fb8794ace42b6bae 100644 (file)
@@ -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:
index 36bb18b96e52e1c0a3fa587ed3414733f29df5b8..bf3c5d10bdb1698b4684a09590e6db48d5a7a6a6 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-22  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52487
+       * g++.dg/cpp0x/lambda/lambda-ice7.C: New.
+
 2012-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/52671
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice7.C
new file mode 100644 (file)
index 0000000..946377e
--- /dev/null
@@ -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" }
+}