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
This commit is contained in:
Jason Merrill 2013-03-25 18:06:36 -04:00 committed by Jason Merrill
parent b85db96a63
commit f02296ddb9
3 changed files with 35 additions and 2 deletions

View file

@ -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

View file

@ -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);

View file

@ -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);};
}