I think I got it right at last:

[...]
       vv = yylval.vval;
       if(c1 & Numvlong ||
         (uvlong)convvtox(vv, TUVLONG) > convvtox(vv, TULONG)){
               /* unsigned suffix or hex occupying the sing bit */
               if((c1 & Numuns) || convvtox(vv, TVLONG) < 0 && (c1 & Numdec) == 
0) {
                       c = LUVLCONST;
                       t = TUVLONG;
                       goto nret;
               }
               c = LVLCONST;
               t = TVLONG;
               goto nret;
       }
       if(c1 & Numlong ||
         (uvlong)convvtox(vv, TULONG) > convvtox(vv, TUINT)){
               if((c1 & Numuns) || convvtox(vv, TLONG) < 0 && (c1 & Numdec) == 
0) {
                       c = LULCONST;
                       t = TULONG;
                       goto nret;
               }
               /* decimal occupying the sing bit */
               if(convvtox(vv, TLONG) < 0 && (c1 & Numdec) == 0) {
                       c = LVLCONST;
                       t = TVLONG;
                       goto nret;
               }
               c = LLCONST;
               t = TLONG;
               goto nret;
       }
       if((c1 & Numuns) || convvtox(vv, TINT) < 0 && (c1 & Numdec) == 0) {
               c = LUCONST;
               t = TUINT;
               goto nret;
       }
       if(convvtox(vv, TINT) < 0 && (c1 & Numdec) == 0) {
               c = LLCONST;
               t = TLONG;
               goto nret;
       }
       c = LCONST;
       t = TINT;
       goto nret;
[...]

I used the cast also in (uvlong)convvtox(vv, TULONG) because the
standard only specifies that long long can't be smaller than long.

After playing with this I'm thinking about using the original code
and substituting the warning for an error when a constant is
truncated. Makes sense to me and Plan9's C isn't C99 anyway.

adr.

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T22754f10b241991c-M1f19d8edddfa4ec4ae0f5901
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to