aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-28 14:20:45 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-28 14:20:45 -0400
commitfad882c6d9f520191ea301a023aa86e348049973 (patch)
tree8d4dd00befd820ba47095c74be1d3d12d3bddd02
parentc561e95201474d7951cbd7a09195b7f3b412d1e9 (diff)
downloadgcc-fad882c6d9f520191ea301a023aa86e348049973.zip
gcc-fad882c6d9f520191ea301a023aa86e348049973.tar.gz
gcc-fad882c6d9f520191ea301a023aa86e348049973.tar.bz2
re PR c++/56710 (Using reserved double underscore variable name in a lambda causes internal compiler error)
PR c++/56710 * semantics.c (finish_member_declaration): Don't push closure members. From-SVN: r197211
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-names1.C9
3 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b204153..2b02880 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2013-03-28 Jason Merrill <jason@redhat.com>
+ PR c++/56710
+ * semantics.c (finish_member_declaration): Don't push closure
+ members.
+
* name-lookup.c (pushdecl_maybe_friend_1): Use
nonlambda_method_basetype and current_nonlambda_class_type.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0b8e2f7..ad1c209 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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)
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-names1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-names1.C
new file mode 100644
index 0000000..df2b037
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-names1.C
@@ -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; }();
+}