BR 1864243: better warnings for out-of-range constants
authorH. Peter Anvin <hpa@zytor.com>
Wed, 9 Jan 2008 06:13:48 +0000 (22:13 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 9 Jan 2008 06:13:48 +0000 (22:13 -0800)
In particular, we'd miss issuing warnings for out-of-range dword
values, and the message for constants too large (we can't deal with >
64 bits) said 32 bits, not 64.

assemble.c
nasmlib.c

index af620fb..f15b11a 100644 (file)
@@ -159,7 +159,7 @@ static void warn_overflow(int size, int64_t data)
        int64_t lim = ((int64_t)1 << (size*8))-1;
 
        if (data < ~lim || data > lim)
-           errfunc(ERR_WARNING, "%s data exceeds bounds", size_name(size));
+           errfunc(ERR_WARNING | ERR_WARN_NOV, "%s data exceeds bounds", size_name(size));
     }
 }
 /*
@@ -1174,7 +1174,8 @@ static void gencode(int32_t segment, int64_t offset, int bits,
         case 016:
        case 017:
             if (opx->offset < -128 || opx->offset > 127) {
-                errfunc(ERR_WARNING, "signed byte value exceeds bounds");
+                errfunc(ERR_WARNING | ERR_WARN_NOV,
+                       "signed byte value exceeds bounds");
             }
 
             if (opx->segment != NO_SEG) {
@@ -1194,7 +1195,8 @@ static void gencode(int32_t segment, int64_t offset, int bits,
         case 022:
        case 023:
             if (opx->offset < -256 || opx->offset > 255) {
-                errfunc(ERR_WARNING, "byte value exceeds bounds");
+                errfunc(ERR_WARNING | ERR_WARN_NOV,
+                       "byte value exceeds bounds");
             }
             if (opx->segment != NO_SEG) {
                 data = opx->offset;
@@ -1213,7 +1215,8 @@ static void gencode(int32_t segment, int64_t offset, int bits,
         case 026:
        case 027:
             if (opx->offset < 0 || opx->offset > 255)
-                errfunc(ERR_WARNING, "unsigned byte value exceeds bounds");
+                errfunc(ERR_WARNING | ERR_WARN_NOV,
+                       "unsigned byte value exceeds bounds");
             if (opx->segment != NO_SEG) {
                 data = opx->offset;
                 out(offset, segment, &data, OUT_ADDRESS, 1,
@@ -1259,6 +1262,8 @@ static void gencode(int32_t segment, int64_t offset, int bits,
         case 042:
        case 043:
             data = opx->offset;
+            if (opx->segment == NO_SEG && opx->wrt == NO_SEG)
+               warn_overflow(4, data);
             out(offset, segment, &data, OUT_ADDRESS, 4,
                 opx->segment, opx->wrt);
             offset += 4;
index 7e4e91f..eefeb2c 100644 (file)
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -316,7 +316,7 @@ int64_t readnum(char *str, bool *error)
 
     if (warn)
         nasm_malloc_error(ERR_WARNING | ERR_PASS1 | ERR_WARN_NOV,
-                          "numeric constant %s does not fit in 32 bits",
+                          "numeric constant %s does not fit in 64 bits",
                           str);
 
     return result * sign;