z80 assembler: Fix new unexpected overflow warning in v2.37
authorNick Clifton <nickc@redhat.com>
Mon, 21 Mar 2022 11:33:59 +0000 (11:33 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 21 Mar 2022 11:33:59 +0000 (11:33 +0000)
PR 28791
* config/tc-z80.c (emit_data_val): Do not warn about overlarge
constants generated by bit manipulation operators.
* testsuite/gas/z80/pr28791.s: New test source file.
* testsuite/gas/z80/pr28791.d: New test driver file.

gas/ChangeLog
gas/config/tc-z80.c
gas/testsuite/gas/z80/pr28791.d [new file with mode: 0644]
gas/testsuite/gas/z80/pr28791.s [new file with mode: 0644]

index e2e489732042aceae0919a24ef61ecee972c5231..c6f177bf23c6c35dfde379de65d17ea50a1ad116 100644 (file)
@@ -1,3 +1,11 @@
+2022-03-21  Nick Clifton  <nickc@redhat.com>
+
+       PR 28791
+       * config/tc-z80.c (emit_data_val): Do not warn about overlarge
+       constants generated by bit manipulation operators.
+       * testsuite/gas/z80/pr28791.s: New test source file.
+       * testsuite/gas/z80/pr28791.d: New test driver file.
+
 2022-01-28  Nick Clifton  <nickc@redhat.com>
 
        * po/fr.po: Updated French translation.
index 522e909bbc6d2186c880b752e83dc6d577d68a78..81fbfe3b0aefc3b3424d0e1229be43704575c6eb 100644 (file)
@@ -1134,7 +1134,15 @@ emit_data_val (expressionS * val, int size)
   if (val->X_op == O_constant)
     {
       int i;
-      if (is_overflow (val->X_add_number, size*8))
+
+       /* PR 28791:
+         Check for overflow, but ignore values that were generated by bit
+         manipulation operators (eg ~0xe6 and -7).  This does mean that
+         manipluated overlarge values will not be reported (eg ~0x1234),
+         but it does help to maintain compatibility with earlier versions
+         of the assembler.  */
+      if (! val->X_extrabit
+         && is_overflow (val->X_add_number, size*8))
        as_warn ( _("%d-bit overflow (%+ld)"), size*8, val->X_add_number);
       for (i = 0; i < size; ++i)
        p[i] = (char)(val->X_add_number >> (i*8));
diff --git a/gas/testsuite/gas/z80/pr28791.d b/gas/testsuite/gas/z80/pr28791.d
new file mode 100644 (file)
index 0000000..4351f1a
--- /dev/null
@@ -0,0 +1,16 @@
+#as: -march=ez80
+#objdump: -d
+#name: PR 28791: Do not complain about overlarge bit manipulated constants
+
+.*:.*
+
+Disassembly of section .text:
+
+0+ <.text>:
+\s+0:\s+1e 19\s+ld e,0x19
+\s+2:\s+1e 1a\s+ld e,0x1a
+\s+4:\s+1e e6\s+ld e,0xe6
+\s+6:\s+1e ff\s+ld e,0xff
+\s+8:\s+1e 00\s+ld e,0x00
+\s+a:\s+1e f9\s+ld e,0xf9
+\s+c:\s+1e cb\s+ld e,0xcb
diff --git a/gas/testsuite/gas/z80/pr28791.s b/gas/testsuite/gas/z80/pr28791.s
new file mode 100644 (file)
index 0000000..bcfdbe5
--- /dev/null
@@ -0,0 +1,7 @@
+ld e, ~0xe6
+ld e, -0xe6
+ld e, 0xe6
+ld e, ~0
+ld e, !0xe6
+ld e, -7
+ld e, ~0x1234