Skip to content
Snippets Groups Projects
Commit ad52d898 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

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.
parent 1d3707a5
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment