Hi! convert_arg_to_ellipsis used to call decay_conversion for all types (which calls mark_rvalue_use), but it doesn't anymore in GCC 10, and while for INTEGRAL_OR_ENUMERATION_TYPE_P args it calls cp_perform_integral_promotions which does that too and for aggregate args keeps calling decay_conversion, for floating point or decltype(nullptr) args there is nothing that would shut up -Wunused-but-set-* warning (and I guess equally also handle lambda captures).
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-12-19 Jakub Jelinek <ja...@redhat.com> 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. --- gcc/cp/call.c.jj 2019-12-17 10:19:51.013282361 +0100 +++ gcc/cp/call.c 2019-12-18 18:23:01.441357443 +0100 @@ -7819,10 +7819,12 @@ convert_arg_to_ellipsis (tree arg, tsubs "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 --- gcc/testsuite/g++.dg/warn/Wunused-var-36.C.jj 2019-12-18 18:05:50.804946325 +0100 +++ gcc/testsuite/g++.dg/warn/Wunused-var-36.C 2019-12-18 18:40:19.130654606 +0100 @@ -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); +} Jakub