aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-12-08 21:47:11 -0500
committerJason Merrill <jason@redhat.com>2020-12-09 00:36:07 -0500
commitc3a63fb3854392af65a191154e3586e7f5a1066e (patch)
treebd153bc97384ebe5bb874f1424a0049f86dc49b1 /gcc/cp
parent4eb28483004f8291c1f17df3b242716a5151c180 (diff)
downloadgcc-c3a63fb3854392af65a191154e3586e7f5a1066e.zip
gcc-c3a63fb3854392af65a191154e3586e7f5a1066e.tar.gz
gcc-c3a63fb3854392af65a191154e3586e7f5a1066e.tar.bz2
c++: Avoid [[nodiscard]] warning in requires-expr [PR98019]
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/cvt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index bcd7c5a..29ceaeb 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -1031,6 +1031,9 @@ cp_get_callee_fndecl_nofold (tree call)
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);