OSDN Git Service

PR c++/50224
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Aug 2011 04:40:22 +0000 (04:40 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Aug 2011 04:40:22 +0000 (04:40 +0000)
* semantics.c (finish_id_expression): Mark captured variables used.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@178278 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C [new file with mode: 0644]

index c6a704c..70919cd 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-29  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50224
+       * semantics.c (finish_id_expression): Mark captured variables used.
+
 2011-08-25  Jason Merrill  <jason@redhat.com>
 
        PR c++/50157
index e2a3c39..6ceed2f 100644 (file)
@@ -2897,6 +2897,9 @@ finish_id_expression (tree id_expression,
          tree lambda_expr = NULL_TREE;
          tree initializer = convert_from_reference (decl);
 
+         /* Mark it as used now even if the use is ill-formed.  */
+         mark_used (decl);
+
          /* Core issue 696: "[At the July 2009 meeting] the CWG expressed
             support for an approach in which a reference to a local
             [constant] automatic variable in a nested class or lambda body
index badfe5d..7ab09d3 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-29  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50224
+       * g++.dg/cpp0x/lambda/lambda-use2.C: New.
+
 2011-08-29  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C
new file mode 100644 (file)
index 0000000..695a0b4
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/50224
+// { dg-options "-std=c++0x -Wunused-parameter" }
+
+struct T;
+
+void m(T& t) // ERROR here
+{
+  [&]{
+    t; // ``t`` is referenced here
+  };
+}