]> Shamusworld >> Repos - rmac/commitdiff
Fix for subtle bug in the expression analyzer.
authorShamus Hammons <jlhamm@acm.org>
Sat, 24 Feb 2018 16:27:31 +0000 (10:27 -0600)
committerShamus Hammons <jlhamm@acm.org>
Sat, 24 Feb 2018 16:27:31 +0000 (10:27 -0600)
Turns out if you blindly promote arithmetic expressions to
ABS + DEFINED, it causes things to assemble wrong. This crept in around
v1.9.1; Now at version 1.12.5.

.gitignore
expr.c
version.h

index a89b4bf1f87b2ae3fffe9ae94e42547dad149e28..be2b8f877f1e35820971881fed4c26e096f2b953 100644 (file)
@@ -23,3 +23,8 @@ bugs8/
 *.zip
 features/
 patches/
 *.zip
 features/
 patches/
+tmp/
+elf/
+tests/
+regression-tests/
+rmac-*
diff --git a/expr.c b/expr.c
index 1d6ce38a5b9e581ef705960b1083e3e56b44f36e..74b68c9c3ffe0bb9bfc7368bb48ef0ecd3a8fc25 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -900,11 +900,10 @@ printf("EVEXPR (-): sym1 = %X, sym2 = %X\n", attr, sattr[1]);
 
                // All other binary operators must have two ABS items to work with.
                // They all produce an ABS value.
 
                // All other binary operators must have two ABS items to work with.
                // They all produce an ABS value.
+               // Shamus: Is this true? There's at least one counterexample of legit
+               //         code where this assumption fails to produce correct code.
                default:
 //printf("evexpr(): default\n");
                default:
 //printf("evexpr(): default\n");
-                       // GH - Removed for v1.0.15 as part of the fix for indexed loads.
-                       //if ((*sattr & (TEXT|DATA|BSS)) || (*--sattr & (TEXT|DATA|BSS)))
-                       //error(seg_error);
 
                        switch ((int)tk.u32[-1])
                        {
 
                        switch ((int)tk.u32[-1])
                        {
@@ -936,7 +935,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                }
 //printf("%i\n", *sval);
 
                                }
 //printf("%i\n", *sval);
 
-                               *sattr = ABS | DEFINED | attr;          // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED | attr;          // Expr becomes absolute
                                break;
 
                        case '/':
                                break;
 
                        case '/':
@@ -974,7 +973,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                }
 //printf("%i\n", *sval);
 
                                }
 //printf("%i\n", *sval);
 
-                               *sattr = ABS | DEFINED | attr;          // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED | attr;          // Expr becomes absolute
                                break;
 
                        case '%':
                                break;
 
                        case '%':
@@ -988,7 +987,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("mod (%) by zero");
 
                                *sval %= sval[1];
                                        return error("mod (%) by zero");
 
                                *sval %= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        case SHL:
                                break;
 
                        case SHL:
@@ -999,7 +998,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("floating point numbers not allowed with operator '<<'.");
 
                                *sval <<= sval[1];
                                        return error("floating point numbers not allowed with operator '<<'.");
 
                                *sval <<= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        case SHR:
                                break;
 
                        case SHR:
@@ -1010,7 +1009,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("floating point numbers not allowed with operator '>>'.");
 
                                *sval >>= sval[1];
                                        return error("floating point numbers not allowed with operator '>>'.");
 
                                *sval >>= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        case '&':
                                break;
 
                        case '&':
@@ -1021,7 +1020,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("floating point numbers not allowed with operator '&'.");
 
                                *sval &= sval[1];
                                        return error("floating point numbers not allowed with operator '&'.");
 
                                *sval &= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        case '^':
                                break;
 
                        case '^':
@@ -1032,7 +1031,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("floating point numbers not allowed with operator '^'.");
 
                                *sval ^= sval[1];
                                        return error("floating point numbers not allowed with operator '^'.");
 
                                *sval ^= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        case '|':
                                break;
 
                        case '|':
@@ -1043,7 +1042,7 @@ An open question here is do we promote ints to floats as signed or unsigned? It
                                        return error("floating point numbers not allowed with operator '|'.");
 
                                *sval |= sval[1];
                                        return error("floating point numbers not allowed with operator '|'.");
 
                                *sval |= sval[1];
-                               *sattr = ABS | DEFINED;                 // Expr becomes absolute
+//no                           *sattr = ABS | DEFINED;                 // Expr becomes absolute
                                break;
 
                        default:
                                break;
 
                        default:
index e80f72d63f7dcea4b657fe3ce78f698b9f833ebd..b56b49a5ff03504515436c21958f753015b2812d 100644 (file)
--- a/version.h
+++ b/version.h
@@ -15,7 +15,7 @@
 
 #define MAJOR   1              // Major version number
 #define MINOR   12             // Minor version number
 
 #define MAJOR   1              // Major version number
 #define MINOR   12             // Minor version number
-#define PATCH   4              // Patch release number
+#define PATCH   5              // Patch release number
 
 #endif // __VERSION_H__
 
 
 #endif // __VERSION_H__