]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Avoid -Wunused-value false positives on nullptr passed to ellipsis [PR100666]
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 May 2021 15:24:38 +0000 (17:24 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 10 May 2022 08:14:23 +0000 (10:14 +0200)
commit589a0f34b1d176b62b064c9815c341b6abf48a2b
tree34f58ff86c87f5f7c1458dc899ee9b1df867f45f
parentb5a972b300f26d2af4f1622c560f6ffda25852ce
c++: Avoid -Wunused-value false positives on nullptr passed to ellipsis [PR100666]

When passing expressions with decltype(nullptr) type with side-effects to
ellipsis, we pass (void *)0 instead, but for the side-effects evaluate them
on the lhs of a COMPOUND_EXPR.  Unfortunately that means we warn about it
if the expression is a call to nodiscard marked function, even when the
result is really used, just needs to be transformed.

Fixed by adding a warning_sentinel.

2021-05-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/100666
* call.c (convert_arg_to_ellipsis): For expressions with NULLPTR_TYPE
and side-effects, temporarily disable -Wunused-result warning when
building COMPOUND_EXPR.

* g++.dg/cpp1z/nodiscard8.C: New test.
* g++.dg/cpp1z/nodiscard9.C: New test.

(cherry picked from commit ad52d89808a947264397e920d7483090d4108f7b)
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp1z/nodiscard8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/nodiscard9.C [new file with mode: 0644]