From: Paolo Carlini Date: Thu, 8 Feb 2018 18:54:39 +0000 (+0000) Subject: re PR c++/83806 (Spurious -Wunused-but-set-parameter with nullptr) X-Git-Tag: upstream/12.2.0~33521 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=739745618a4202f3bf515494175eacae6ff05d2d;p=platform%2Fupstream%2Fgcc.git re PR c++/83806 (Spurious -Wunused-but-set-parameter with nullptr) /cp 2018-02-08 Paolo Carlini PR c++/83806 * typeck.c (decay_conversion): Use mark_rvalue_use for the special case of nullptr too. /testsuite 2018-02-08 Paolo Carlini PR c++/83806 * g++.dg/warn/Wunused-parm-11.C: New. From-SVN: r257502 --- 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 + + PR c++/83806 + * typeck.c (decay_conversion): Use mark_rvalue_use for the special + case of nullptr too. + 2018-02-08 Nathan Sidwell * 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 + + PR c++/83806 + * g++.dg/warn/Wunused-parm-11.C: New. + 2018-02-08 Marek Polacek 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 +bool equals(X x, Y y) { + return (x == y); +} + +int main() { + const char* p = nullptr; + equals(p, nullptr); +}