]> gcc.gnu.org Git - gcc.git/commit - gcc/cp/constexpr.cc
c++: Use constexpr to avoid wrong -Wsign-compare (PR90691).
authorJason Merrill <jason@redhat.com>
Mon, 27 Jan 2020 03:58:32 +0000 (22:58 -0500)
committerJason Merrill <jason@redhat.com>
Sat, 8 Feb 2020 16:14:58 +0000 (11:14 -0500)
commitaaa26bf496a646778ac861aed124d960b5bf549f
tree1167d885bee00dad0a0f9437ebe7fcfc8d1c19cb
parent173c8defa6e82f1bc003173b6ee1e4eb2830d1c2
c++: Use constexpr to avoid wrong -Wsign-compare (PR90691).

We would like to do constexpr evaluation to avoid false positives on
warnings, but constexpr evaluation can involve function body copying that
changes DECL_UID, which breaks -fcompare-debug.  So let's remember
that we need to avoid that.

PR c++/90691
* expr.c (fold_for_warn): Call maybe_constant_value.
* constexpr.c (struct constexpr_ctx): Add uid_sensitive field.
(maybe_constant_value): Add uid_sensitive parm.
(get_fundef_copy): Don't copy if it's true.
(cxx_eval_call_expression): Don't instantiate if it's true.
(cxx_eval_outermost_constant_expr): Likewise.
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/cp-tree.h
gcc/cp/expr.c
gcc/testsuite/g++.dg/warn/Walways-true-3.C
gcc/testsuite/g++.dg/warn/Wsign-compare-9.C [new file with mode: 0644]
This page took 0.06391 seconds and 5 git commands to generate.