]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Result of shift operation on signed integers is bad.
authorDale Weiler <killfieldengine@gmail.com>
Wed, 29 May 2013 02:24:12 +0000 (02:24 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 29 May 2013 02:24:12 +0000 (02:24 +0000)
Makefile
gmqcc.h
parser.c

index 01a5dac15054b4facb70bda399283f5732240e10..d419daaa62d866110c9131b3e717ac2c9906bddb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -162,7 +162,6 @@ SPLINTFLAGS =            \
     -mayaliasunique      \
     -realcompare         \
     -observertrans       \
-    -shiftnegative       \
     -abstract            \
     -statictrans         \
     -castfcnptr
diff --git a/gmqcc.h b/gmqcc.h
index 2e019a561138ee990b0f256b5f59422940cdbe33..3b221e9dc6d6836cd7f82d496bb1d48da5232a7d 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -1163,7 +1163,7 @@ typedef struct {
 
 extern opts_cmd_t opts;
 
-#define OPTS_GENERIC(f,i)    (!! (((f)[(i)/32]) & (1<< ((i)%32))))
+#define OPTS_GENERIC(f,i)    (!! (((f)[(i)/32]) & (1<< (unsigned)((i)%32))))
 #define OPTS_FLAG(i)         OPTS_GENERIC(opts.flags,        (i))
 #define OPTS_WARN(i)         OPTS_GENERIC(opts.warn,         (i))
 #define OPTS_WERROR(i)       OPTS_GENERIC(opts.werror,       (i))
index 4d50bad5e15232cc0da981bd08484b3362b131f8..da9d33a99a165f080005738874576e557d4c109f 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1038,9 +1038,9 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
         case opid2('>','>'):
             if (CanConstFold(exprs[0], exprs[1]) && ! NotSameType(TYPE_FLOAT)) {
                 if (op->id == opid2('<','<'))
-                    out = (ast_expression*)parser_const_float(parser, (double)((int)(ConstF(0)) << (int)(ConstF(1))));
+                    out = (ast_expression*)parser_const_float(parser, (double)((unsigned int)(ConstF(0)) << (unsigned int)(ConstF(1))));
                 else
-                    out = (ast_expression*)parser_const_float(parser, (double)((int)(ConstF(0)) >> (int)(ConstF(1))));
+                    out = (ast_expression*)parser_const_float(parser, (double)((unsigned int)(ConstF(0)) >> (unsigned int)(ConstF(1))));
                 break;
             }
         case opid3('<','<','='):