aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-25 18:06:36 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-25 18:06:36 -0400
commitf02296ddb9d4a183b90600659341baf91436f7d9 (patch)
treee788cf7e08f323720de2092e3f2fc3fa9a07b71d
parentb85db96a63b937220c248b438666eef4190276d4 (diff)
downloadgcc-f02296ddb9d4a183b90600659341baf91436f7d9.zip
gcc-f02296ddb9d4a183b90600659341baf91436f7d9.tar.gz
gcc-f02296ddb9d4a183b90600659341baf91436f7d9.tar.bz2
re PR c++/56699 (Failed for sizeof (non-static member) in lambda expression)
PR c++/56699 * semantics.c (maybe_resolve_dummy): Make sure that the enclosing class is derived from the type of the object. From-SVN: r197069
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this16.C28
3 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bac4844..6aaf1dd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,4 +1,8 @@
-2013-03-23 Jason Merrill <jason@redhat.com>
+2013-03-25 Jason Merrill <jason@redhat.com>
+
+ PR c++/56699
+ * semantics.c (maybe_resolve_dummy): Make sure that the enclosing
+ class is derived from the type of the object.
PR c++/52014
* semantics.c (lambda_expr_this_capture): Don't capture 'this' in
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fb38e8d..127e2da 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9565,7 +9565,8 @@ maybe_resolve_dummy (tree object)
if (type != current_class_type
&& current_class_type
- && LAMBDA_TYPE_P (current_class_type))
+ && LAMBDA_TYPE_P (current_class_type)
+ && DERIVED_FROM_P (type, current_nonlambda_class_type ()))
{
/* In a lambda, need to go through 'this' capture. */
tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this16.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this16.C
new file mode 100644
index 0000000..736d5f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this16.C
@@ -0,0 +1,28 @@
+// PR c++/56699
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ int a;
+};
+
+struct T
+{
+ int x;
+
+ T() : x([]{
+ sizeof(::A::a);
+ return 0;
+ }())
+ {}
+};
+
+struct B
+{
+ int a;
+};
+
+void f()
+{
+ []{sizeof(B::a);};
+}