Hi,

this one should be rather straightforward. As noticed by Jakub, we started emitting the spurious warning with the fix for c++/69257, which, among other things, fixed decay_conversion wrt mark_rvalue_use and mark_lvalue_use calls. In particular it removed the mark_rvalue_use call at the very beginning of the function, thus now a PARM_DECL with NULLPTR_TYPE as type, being handled specially at the beginning of the function, doesn't get the mark_rvalue_use treatment - which, for example, POINTER_TYPE now gets later. I'm finishing testing on x86_64-linux the below. Ok if it passes?

Thanks, Paolo.

PS: sorry Jason, I have to re-send separately to the mailing list because some HTML crept in again. Grrr.

/////////////////////////

/cp
2018-02-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/83806
        * typeck.c (decay_conversion): Use mark_rvalue_use for the special
        case of nullptr too.

/testsuite
2018-02-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/83806
        * g++.dg/warn/Wunused-parm-11.C: New.
Index: testsuite/g++.dg/warn/Wunused-parm-11.C
===================================================================
--- testsuite/g++.dg/warn/Wunused-parm-11.C     (nonexistent)
+++ testsuite/g++.dg/warn/Wunused-parm-11.C     (working copy)
@@ -0,0 +1,13 @@
+// PR c++/83806
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-but-set-parameter" }
+
+template <class X, class Y>
+bool equals(X x, Y y) {
+    return (x == y); 
+}
+
+int main() {
+    const char* p = nullptr;
+    equals(p, nullptr);
+}
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 257477)
+++ cp/typeck.c (working copy)
@@ -2009,7 +2009,10 @@ decay_conversion (tree exp,
     return error_mark_node;
 
   if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
-    return nullptr_node;
+    {
+      exp = mark_rvalue_use (exp, loc, reject_builtin);
+      return nullptr_node;
+    }
 
   /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
      Leave such NOP_EXPRs, since RHS is being used in non-lvalue context.  */

Reply via email to