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
-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
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);
--- /dev/null
+// 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);};
+}