* semantics.c (lambda_expr_this_capture): In unevaluated context,
just return the nearest 'this'.
From-SVN: r196550
2013-03-08 Jason Merrill <jason@redhat.com>
+ * semantics.c (lambda_expr_this_capture): In unevaluated context,
+ just return the nearest 'this'.
+
PR c++/51494
PR c++/51884
PR c++/56222
if (!this_capture)
{
+ /* In unevaluated context this isn't an odr-use, so just return the
+ nearest 'this'. */
+ if (cp_unevaluated_operand)
+ return lookup_name (this_identifier);
+
error ("%<this%> was not captured for this lambda function");
result = error_mark_node;
}
--- /dev/null
+// Uses of 'this' in unevaluated context are not odr-uses.
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ int f() {}
+ int i;
+
+ void foo()
+ {
+ [] () { sizeof(i); sizeof(f()); };
+ }
+};