From a58b0053f4c4b4f0089f3985a41d0deac4c59ea4 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 21 Mar 2022 11:33:59 +0000 Subject: [PATCH] z80 assembler: Fix new unexpected overflow warning in v2.37 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 | 8 ++++++++ gas/config/tc-z80.c | 10 +++++++++- gas/testsuite/gas/z80/pr28791.d | 16 ++++++++++++++++ gas/testsuite/gas/z80/pr28791.s | 7 +++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/z80/pr28791.d create mode 100644 gas/testsuite/gas/z80/pr28791.s diff --git a/gas/ChangeLog b/gas/ChangeLog index e2e48973204..c6f177bf23c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2022-03-21 Nick Clifton + + 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 * po/fr.po: Updated French translation. diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c index 522e909bbc6..81fbfe3b0ae 100644 --- a/gas/config/tc-z80.c +++ b/gas/config/tc-z80.c @@ -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 index 00000000000..4351f1a753c --- /dev/null +++ b/gas/testsuite/gas/z80/pr28791.d @@ -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 index 00000000000..bcfdbe5012a --- /dev/null +++ b/gas/testsuite/gas/z80/pr28791.s @@ -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 -- 2.39.2