All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 2/8] clean up evaluate_sign()
Date: Fri, 13 Jul 2007 18:44:37 +0100	[thread overview]
Message-ID: <E1I9PC1-0000E0-4q@ZenIV.linux.org.uk> (raw)


Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 evaluate.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 9f543fe..7669c9a 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);
-- 
1.5.0-rc2.GIT

             reply	other threads:[~2007-07-13 17:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-13 17:44 Al Viro [this message]
2007-07-13 18:03 ` [PATCH 2/8] clean up evaluate_sign() Josh Triplett
2007-07-13 18:06   ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1I9PC1-0000E0-4q@ZenIV.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.