diff options
| author | Nicolai Stange <nicstange@gmail.com> | 2016-02-01 03:33:38 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-31 02:14:10 +0200 |
| commit | ccd9e3b5c6ab48bc03b52014a48ea53d681aa704 (patch) | |
| tree | 9a6f998f985333900315c5c2bbee099269b0bc61 /evaluate.c | |
| parent | 4a99724da62bfe56c6347be07cf01579b16c6e68 (diff) | |
| download | sparse-dev-ccd9e3b5c6ab48bc03b52014a48ea53d681aa704.tar.gz | |
constexpr: examine constness of preops at evaluation only
Move the whole calculation of prefix expressions' constness flags to
the evaluation phase such that expressions like
-__builtin_choose_expr(0, 0, 0)
~__builtin_choose_expr(0, 0, 0)
!__builtin_choose_expr(0, 0, 0)
can now be recognized as qualifying as integer constant expressions.
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
| -rw-r--r-- | evaluate.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1805,8 +1805,8 @@ static struct symbol *evaluate_sign(struct expression *expr) { struct symbol *ctype = expr->unop->ctype; int class = classify_type(ctype, &ctype); - if (expr->flags && !(expr->unop->flags & CEF_ICE)) - expr->flags = CEF_NONE; + unsigned char flags = expr->unop->flags & ~CEF_CONST_MASK; + /* should be an arithmetic type */ if (!(class & TYPE_NUM)) return bad_expr_type(expr); @@ -1823,6 +1823,7 @@ Normal: } if (expr->op == '+') *expr = *expr->unop; + expr->flags = flags; expr->ctype = ctype; return ctype; Restr: @@ -1860,8 +1861,7 @@ static struct symbol *evaluate_preop(struct expression *expr) return evaluate_postop(expr); case '!': - if (expr->flags && !(expr->unop->flags & CEF_ICE)) - expr->flags = CEF_NONE; + expr->flags = expr->unop->flags & ~CEF_CONST_MASK; if (is_safe_type(ctype)) warning(expr->pos, "testing a 'safe expression'"); if (is_float_type(ctype)) { |
