commit 03426fb7d994c8eb6bf7f1097c45f6079e8227d5
Author: Jason Merrill <jason@redhat.com>
Date: Wed Mar 27 15:47:58 2013 -0400
PR c++/56710
* semantics.c (finish_member_declaration): Don't push closure
members.
@@ -2719,8 +2719,10 @@ finish_member_declaration (tree decl)
/*friend_p=*/0);
}
}
- /* Enter the DECL into the scope of the class. */
- else if (pushdecl_class_level (decl))
+ /* Enter the DECL into the scope of the class, if the class
+ isn't a closure (whose fields are supposed to be unnamed). */
+ else if (CLASSTYPE_LAMBDA_EXPR (current_class_type)
+ || pushdecl_class_level (decl))
{
if (TREE_CODE (decl) == USING_DECL)
{
new file mode 100644
@@ -0,0 +1,9 @@
+// PR c++/56710
+// { dg-options "-std=c++11 -Wall" }
+
+int main()
+{
+ int t = 0;
+ return [&]() -> int {int __t; __t = t; return __t; }();
+ return [&t]() -> int {int __t; __t = t; return __t; }();
+}
commit db4f00892384f76f442401984007eb2a0b476eb2
Author: Jason Merrill <jason@redhat.com>
Date: Wed Mar 27 15:31:09 2013 -0400
* name-lookup.c (pushdecl_maybe_friend_1): Use
nonlambda_method_basetype and current_nonlambda_class_type.
@@ -1163,8 +1163,8 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
{
tree member;
- if (current_class_ptr)
- member = lookup_member (current_class_type,
+ if (nonlambda_method_basetype ())
+ member = lookup_member (current_nonlambda_class_type (),
name,
/*protect=*/0,
/*want_type=*/false,
new file mode 100644
@@ -0,0 +1,10 @@
+// { dg-options "-std=c++11 -Wshadow" }
+
+struct A
+{
+ int i;
+ void f()
+ {
+ [=]{ int i; }; // { dg-warning "shadows" }
+ }
+};