re PR c++/83806 (Spurious -Wunused-but-set-parameter with nullptr)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 8 Feb 2018 18:54:39 +0000 (18:54 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 8 Feb 2018 18:54:39 +0000 (18:54 +0000)
/cp
2018-02-08  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/83806
* g++.dg/warn/Wunused-parm-11.C: New.

From-SVN: r257502

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wunused-parm-11.C [new file with mode: 0644]

index 2fc35d2dea15daa8f5b374281c09f2f9b4cfa7e7..c68b590a295d875b315f11602db9cf7ffe4e77d0 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/83806
+       * typeck.c (decay_conversion): Use mark_rvalue_use for the special
+       case of nullptr too.
+
 2018-02-08  Nathan Sidwell  <nathan@acm.org>
 
        * class.c (finish_struct): Fix std:initializer_list diagnostic
index 83e767829986d614317f6777184c0344d11a5b50..fe18ea9d16ab010ee523d6f39c20673a7ad6ce90 100644 (file)
@@ -2009,7 +2009,10 @@ decay_conversion (tree exp,
     return error_mark_node;
 
   if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
-    return nullptr_node;
+    {
+      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.  */
index 92e9e34ae07cfb79cca047abdff88eb55a8c894f..c51d2dd912e3a59e214610036fb0f68ce32dba05 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/83806
+       * g++.dg/warn/Wunused-parm-11.C: New.
+
 2018-02-08  Marek Polacek  <polacek@redhat.com>
 
        PR tree-optimization/84238
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-parm-11.C b/gcc/testsuite/g++.dg/warn/Wunused-parm-11.C
new file mode 100644 (file)
index 0000000..35896df
--- /dev/null
@@ -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);
+}