diff options
author | Nicolai Stange <nicstange@gmail.com> | 2016-02-01 03:39:58 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-31 02:27:12 +0200 |
commit | 950dd57c4e43248c8a4dac6595991df42a36c0f1 (patch) | |
tree | 867f9ff6cb9f82a8aa1a05dce161db5c91a0ee99 /evaluate.c | |
parent | f2c8ea249e59bac572bc23469d2e5d475418a473 (diff) | |
download | sparse-950dd57c4e43248c8a4dac6595991df42a36c0f1.tar.gz |
constexpr: recognize address constants created through pointer arithmetic
An address constant +/- an integer constant expression qualifies as an
address constant again.
Furthermore, the array-subscript operator "[]" may be used in the creation
of address constant.
Handle both cases by making evaluate_ptr_add() check whether an integer
constant expression is added to an address constant and tag the result as
being an address constant again if so.
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 | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -571,6 +571,13 @@ static struct symbol *evaluate_ptr_add(struct expression *expr, struct symbol *i classify_type(degenerate(expr->left), &ctype); base = examine_pointer_target(ctype); + /* + * An address constant +/- an integer constant expression + * yields an address constant again [6.6(7)]. + */ + if ((expr->left->flags & CEF_ADDR) && (expr->right->flags & CEF_ICE)) + expr->flags = CEF_ADDR; + if (!base) { expression_error(expr, "missing type information"); return NULL; |