aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorAl Viro <viro@zeniv.linux.org.uk>2007-07-02 00:15:16 -0400
committerJosh Triplett <josh@freedesktop.org>2007-07-14 12:16:52 -0700
commitbe1c3d3c92892bfcdfaaef046cee6590a4f794a8 (patch)
treed6ea0fe0a290fd8c89673783fcf85927b3beadb9
parentebc3fbeff7eab34352c423831387b5f9c8c0ccac (diff)
downloadsparse-dev-be1c3d3c92892bfcdfaaef046cee6590a4f794a8.tar.gz
[PATCH] clean up evaluate_sign()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--evaluate.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/evaluate.c b/evaluate.c
index 9f543feb..7669c9af 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1671,17 +1671,19 @@ static struct symbol *evaluate_postop(struct expression *expr)
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 & Int_const_expr))
expr->flags = 0;
- if (is_int_type(ctype)) {
- struct symbol *rtype = rtype = integer_promotion(ctype);
+ /* should be an arithmetic type */
+ if (!(class & TYPE_NUM))
+ return bad_expr_type(expr);
+ if (!(class & (TYPE_FLOAT|TYPE_RESTRICT))) {
+ struct symbol *rtype = integer_promotion(ctype);
expr->unop = cast_to(expr->unop, rtype);
ctype = rtype;
- } else if (is_float_type(ctype) && expr->op != '~') {
- /* no conversions needed */
- } else if (is_restricted_type(ctype) && !restricted_unop(expr->op, &ctype)) {
+ } else if ((class & TYPE_FLOAT) && expr->op != '~') {
/* no conversions needed */
- } else if (is_fouled_type(ctype) && !restricted_unop(expr->op, &ctype)) {
+ } else if ((class & TYPE_RESTRICT) && !restricted_unop(expr->op, &ctype)) {
/* no conversions needed */
} else {
return bad_expr_type(expr);