http://d.puremagic.com/issues/show_bug.cgi?id=259





--- Comment #14 from Ellery Newcomer <ellery-newco...@utulsa.edu>  2009-09-03 
13:51:16 PDT ---
Okay, so what I have is it checks for 

signed cmp unsigned 

or vice versa in CmpExp::Semantic just before typeCombine gets called, which
works, but then stuff like

1 < 1u

doesn't. So the idea is 

signed cmp unsigned 

or vice versa is okay if the signed arg is a literal and its value is
nonnegative. 

This should work fine if sizeof(signed arg) =< sizeof(unsigned arg) because the
value of the signed arg is within the range of the unsigned arg, and
typeCombine should be able to expand the type of the signed arg to that of the
unsigned arg or whatever.
It should work if sizeof(signed arg) > sizeof(unsigned arg) because the value
of the unsigned arg is within the range of the signed arg, and typeCombine
should be able to expand the type of the unsigned arg to that of the signed
arg.

I don't know, maybe this should be happening in typeCombine. Insert the
following in expression.c CmpExp::semantic before the line

typeCombine(sc);


    if ( e1->type->isintegral() && e2->type->isintegral()){
        if(e1->type->isunsigned() ^ e2->type->isunsigned()){
            if(!e1->type->isunsigned() &&
                dynamic_cast<IntegerExp*>(e1) &&
                ((sinteger_t) e1->toInteger()) >= 0) goto JustKidding;
            if(!e2->type->isunsigned() &&
                dynamic_cast<IntegerExp*>(e2) &&
                ((sinteger_t) e2->toInteger()) >= 0) goto JustKidding;
            error("comparing signed and unsigned integers");
        }
        JustKidding:;
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to