summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-09-24 10:08:52 +0300
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-09-30 03:39:05 +0200
commit1a38b82ebc4f41d5cfb3ea69c0924bbb01ba1358 (patch)
tree11c5606b71663a3b09b28de62a429d83bd8daa33
parent959e165a34d52778ca96bb062dc9c30063e8ccdf (diff)
downloadsparse-1a38b82ebc4f41d5cfb3ea69c0924bbb01ba1358.tar.gz
fix sign extension in casting enums
The function cast_value() needs the exact type of the old expression but when called via cast_enum_list() this type is incorrect because: - the same struct is used for the new and the old expression - the type of the new expression is adjusted before cast_value() is called. Fix this by adjusting the type of the new expression only after cast_value() has been called. Fixes: 604a148a73af ("enum: fix cast_enum_list()") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--parse.c2
-rw-r--r--validation/enum-sign-extend.c1
2 files changed, 1 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 005eb160..b01c876e 100644
--- a/parse.c
+++ b/parse.c
@@ -897,8 +897,8 @@ static void cast_enum_list(struct symbol_list *list, struct symbol *base_type)
expr->ctype = &int_ctype;
continue;
}
- expr->ctype = base_type;
cast_value(expr, base_type, expr, ctype);
+ expr->ctype = base_type;
} END_FOR_EACH_PTR(sym);
}
diff --git a/validation/enum-sign-extend.c b/validation/enum-sign-extend.c
index 9dfbc5eb..d852c934 100644
--- a/validation/enum-sign-extend.c
+++ b/validation/enum-sign-extend.c
@@ -9,5 +9,4 @@ _Static_assert(b == -1L, "value");
/*
* check-name: enum-sign-extend
* check-command: sparse -m64 $file
- * check-known-to-fail
*/