re PR c++/49482 ([C++0x] unused parameter warning on lambda in function template)
authorJason Merrill <jason@redhat.com>
Tue, 21 Jun 2011 20:07:45 +0000 (16:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 21 Jun 2011 20:07:45 +0000 (16:07 -0400)
PR c++/49482
* semantics.c (maybe_add_lambda_conv_op): Call mark_exp_read for
static fn parameters.

From-SVN: r175273

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

index 4fc801761912d1800aea9041108708417b1a5d8e..cf325fc7926b85c93adf9e4d9e0b56aa522aa1b7 100644 (file)
@@ -1,5 +1,9 @@
 2011-06-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49482
+       * semantics.c (maybe_add_lambda_conv_op): Call mark_exp_read for
+       static fn parameters.
+
        * call.c (add_builtin_candidates): Use cv_unqualified rather than
        TYPE_MAIN_VARIANT.
        * pt.c (tsubst_arg_types): Likewise.
index 594d239f4ea131057489aa307e27bbf1e79527bd..6622de62985133e22ad47d1de93353cf55637d65 100644 (file)
@@ -8780,7 +8780,10 @@ maybe_add_lambda_conv_op (tree type)
   argvec = make_tree_vector ();
   VEC_quick_push (tree, argvec, arg);
   for (arg = DECL_ARGUMENTS (statfn); arg; arg = DECL_CHAIN (arg))
-    VEC_safe_push (tree, gc, argvec, arg);
+    {
+      mark_exp_read (arg);
+      VEC_safe_push (tree, gc, argvec, arg);
+    }
   call = build_call_a (callop, VEC_length (tree, argvec),
                       VEC_address (tree, argvec));
   CALL_FROM_THUNK_P (call) = 1;
index b2040700cdaaffdbaf01949b1d938cdfea3981e3..59464fa2703ce339601a4b96d005cca7a023d549 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49482
+       * g++.dg/cpp0x/lambda/lambda-warn3.C: New.
+
        PR c++/49418
        * g++.dg/template/param3.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C
new file mode 100644 (file)
index 0000000..77f35bc
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/49482
+// { dg-options "-std=c++0x -Wunused-but-set-parameter" }
+
+template<class T>
+void f() {
+  []( bool b ){ return b; };
+}
+
+int main()
+{
+  f<int>();
+}