From: Jakub Jelinek Date: Fri, 20 Dec 2019 23:16:58 +0000 (+0100) Subject: re PR c++/92666 (bogus -Wunused-but-set-variable in gcov.c with -Wno-restrict) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0bd002bf2e9f0224905ad19f036dde27b63c26c5;p=gcc.git re PR c++/92666 (bogus -Wunused-but-set-variable in gcov.c with -Wno-restrict) PR c++/92666 * call.c (convert_arg_to_ellipsis): For floating point or decltype(nullptr) arguments call mark_rvalue_use. * g++.dg/warn/Wunused-var-36.C: New test. From-SVN: r279681 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6858f98d57..5a9a648d333 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-12-20 Jakub Jelinek + PR c++/92666 + * call.c (convert_arg_to_ellipsis): For floating point or + decltype(nullptr) arguments call mark_rvalue_use. + PR c++/92992 * call.c (convert_arg_to_ellipsis): For decltype(nullptr) arguments that have side-effects use cp_build_compound_expr. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index aeddf30c71c..1abe1a79851 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7819,10 +7819,12 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain) "implicit conversion from %qH to %qI when passing " "argument to function", arg_type, double_type_node); + arg = mark_rvalue_use (arg); arg = convert_to_real_nofold (double_type_node, arg); } else if (NULLPTR_TYPE_P (arg_type)) { + arg = mark_rvalue_use (arg); if (TREE_SIDE_EFFECTS (arg)) arg = cp_build_compound_expr (arg, null_pointer_node, complain); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2e146464e0..dd9e529ebca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-12-20 Jakub Jelinek + PR c++/92666 + * g++.dg/warn/Wunused-var-36.C: New test. + PR c++/92992 * g++.dg/cpp0x/nullptr45.C: New test. diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-36.C b/gcc/testsuite/g++.dg/warn/Wunused-var-36.C new file mode 100644 index 00000000000..de338f8f6dd --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-36.C @@ -0,0 +1,25 @@ +// PR c++/92666 +// { dg-do compile } +// { dg-options "-Wunused-but-set-variable" } + +int bar (int, ...); +#if __cplusplus >= 201103L +enum class E : int { F = 0, G = 1 }; +#endif +struct S { int s; }; + +void +foo () +{ + float r = 1.0f; // { dg-bogus "set but not used" } + int i = 2; // { dg-bogus "set but not used" } +#if __cplusplus >= 201103L + decltype(nullptr) n = nullptr; // { dg-bogus "set but not used" } + E e = E::F; // { dg-bogus "set but not used" } +#else + void *n = (void *) 0; + int e = 4; +#endif + S s = { 3 }; // { dg-bogus "set but not used" } + bar (0, r, i, n, e, s); +}