* [PATCH 2/8] clean up evaluate_sign()
@ 2007-07-13 17:44 Al Viro
2007-07-13 18:03 ` Josh Triplett
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2007-07-13 17:44 UTC (permalink / raw)
To: linux-sparse
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/8] clean up evaluate_sign()
2007-07-13 17:44 [PATCH 2/8] clean up evaluate_sign() Al Viro
@ 2007-07-13 18:03 ` Josh Triplett
2007-07-13 18:06 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Josh Triplett @ 2007-07-13 18:03 UTC (permalink / raw)
To: Al Viro; +Cc: linux-sparse
On Fri, 2007-07-13 at 18:44 +0100, Al Viro wrote:
> --- 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);
Most of this seems quite reasonable and obvious. I noticed, though,
that this drops the handling for fouled types; did you do that
intentionally, and if so could you elaborate on why?
- Josh Triplett
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/8] clean up evaluate_sign()
2007-07-13 18:03 ` Josh Triplett
@ 2007-07-13 18:06 ` Al Viro
0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2007-07-13 18:06 UTC (permalink / raw)
To: Josh Triplett; +Cc: linux-sparse
On Fri, Jul 13, 2007 at 11:03:01AM -0700, Josh Triplett wrote:
> > + if (!(class & (TYPE_FLOAT|TYPE_RESTRICT))) {
> > + struct symbol *rtype = integer_promotion(ctype);
> > expr->unop = cast_to(expr->unop, rtype);
> > ctype = rtype;
> Most of this seems quite reasonable and obvious. I noticed, though,
> that this drops the handling for fouled types; did you do that
> intentionally, and if so could you elaborate on why?
They get folded with handling of restricted - classify_type() gets
TYPE_NUM|TYPE_RESTRICT|TYPE_FOULED for those.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-13 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-13 17:44 [PATCH 2/8] clean up evaluate_sign() Al Viro
2007-07-13 18:03 ` Josh Triplett
2007-07-13 18:06 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).