If we aren't really evaluating the expression, it doesn't matter that the
return value is discarded.
gcc/cp/ChangeLog:
PR c++/98019
* cvt.c (maybe_warn_nodiscard): Check c_inhibit_evaluation_warnings.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-nodiscard1.C: Remove xfail.
static void
maybe_warn_nodiscard (tree expr, impl_conv_void implicit)
{
+ if (!warn_unused_result || c_inhibit_evaluation_warnings)
+ return;
+
tree call = expr;
if (TREE_CODE (expr) == TARGET_EXPR)
call = TARGET_EXPR_INITIAL (expr);
// PR c++/98019
// { dg-do compile { target c++20 } }
-// { dg-excess-errors *-*-* }
+// Don't give [[nodiscard]] warning for an expression requirement.
template <class T, class U> concept same_as = __is_same_as (T, U);