mark_exp_read doesn't know how to deal with a CONSTRUCTOR. In this case it doesn't need to, since we're about to pull out the single element anyway, so let's do that before calling mark_exp_read.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit cd87c48098daa3f1f31a7877d6fb0bf799b10d7b
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Sep 18 14:05:55 2014 -0400

    	PR c++/61465
    	* call.c (convert_like_real) [ck_identity]: Call mark_rvalue_use
    	after pulling out an element from a CONSTRUCTOR.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 161235b..8f1b91a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6206,7 +6206,6 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 	return expr;
       }
     case ck_identity:
-      expr = mark_rvalue_use (expr);
       if (BRACE_ENCLOSED_INITIALIZER_P (expr))
 	{
 	  int nelts = CONSTRUCTOR_NELTS (expr);
@@ -6217,6 +6216,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 	  else
 	    gcc_unreachable ();
 	}
+      expr = mark_rvalue_use (expr);
 
       if (type_unknown_p (expr))
 	expr = instantiate_type (totype, expr, complain);
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-parm-6.C b/gcc/testsuite/g++.dg/warn/Wunused-parm-6.C
new file mode 100644
index 0000000..95fb7e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-parm-6.C
@@ -0,0 +1,8 @@
+// PR c++/61465
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-but-set-parameter" }
+
+struct Foo {
+  Foo(void* x) : y{static_cast<char*>(x)} {}
+  char* y;
+};

Reply via email to