diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-02-08 18:54:39 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-02-08 18:54:39 +0000 |
commit | 739745618a4202f3bf515494175eacae6ff05d2d (patch) | |
tree | ee74a0c7ce2eacceafb4337723bb831769dc7ce6 | |
parent | b00dcb136ea594997c35108903782142849d6ac8 (diff) | |
download | gcc-739745618a4202f3bf515494175eacae6ff05d2d.zip gcc-739745618a4202f3bf515494175eacae6ff05d2d.tar.gz gcc-739745618a4202f3bf515494175eacae6ff05d2d.tar.bz2 |
re PR c++/83806 (Spurious -Wunused-but-set-parameter with nullptr)
/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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-parm-11.C | 13 |
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2fc35d2..c68b590 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 83e7678..fe18ea9 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 92e9e34..c51d2dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..35896df --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-parm-11.C @@ -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); +} |