From 29cf29a2cf1a5df53c9b77cce8916e8c0fc82e12 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Tue, 17 Jun 2014 00:56:01 +0200 Subject: [PATCH] GAS: Fix CRIS double-error reports caused by recent generic GAS changes. --- gas/ChangeLog | 6 +++ gas/config/tc-cris.c | 63 +++++++++++++++++----------- gas/testsuite/ChangeLog | 4 ++ gas/testsuite/gas/cris/range-err-3.s | 10 +++++ 4 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 gas/testsuite/gas/cris/range-err-3.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 31d343acdeb..9e3a320b40d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2014-06-17 Hans-Peter Nilsson + + * config/tc-cris.c (cris_bad): New function. + (cris_process_instruction): Where applicable, use it instead of + as_bad. + 2014-06-16 Nick Clifton * config/tc-aarch64.c (md_apply_fix): Ignore unused relocs. diff --git a/gas/config/tc-cris.c b/gas/config/tc-cris.c index aba4ef7dffc..2989f02d203 100644 --- a/gas/config/tc-cris.c +++ b/gas/config/tc-cris.c @@ -1492,6 +1492,19 @@ md_assemble (char *str) } } +/* Helper error-reporting function: calls as_bad for a format string + for a single value and zeroes the offending value (zero assumed + being a valid value) to avoid repeated error reports in later value + checking. */ + +static void +cris_bad (const char *format, offsetT *valp) +{ + /* We cast to long so the format string can assume that format. */ + as_bad (format, (long) *valp); + *valp = 0; +} + /* Low level text-to-bits assembly. */ static void @@ -1646,8 +1659,8 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < 0 || out_insnp->expr.X_add_number > 31)) - as_bad (_("Immediate value not in 5 bit unsigned range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 5 bit unsigned range: %ld"), + &out_insnp->expr.X_add_number); out_insnp->reloc = BFD_RELOC_CRIS_UNSIGNED_5; continue; @@ -1662,8 +1675,8 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < 0 || out_insnp->expr.X_add_number > 15)) - as_bad (_("Immediate value not in 4 bit unsigned range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 4 bit unsigned range: %ld"), + &out_insnp->expr.X_add_number); out_insnp->reloc = BFD_RELOC_CRIS_UNSIGNED_4; continue; @@ -1714,8 +1727,9 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < -32 || out_insnp->expr.X_add_number > 31)) - as_bad (_("Immediate value not in 6 bit range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 6 bit range: %ld"), + &out_insnp->expr.X_add_number); + out_insnp->reloc = BFD_RELOC_CRIS_SIGNED_6; continue; } @@ -1729,8 +1743,9 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < 0 || out_insnp->expr.X_add_number > 63)) - as_bad (_("Immediate value not in 6 bit unsigned range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 6 bit unsigned range: %ld"), + &out_insnp->expr.X_add_number); + out_insnp->reloc = BFD_RELOC_CRIS_UNSIGNED_6; continue; } @@ -2122,8 +2137,8 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < -128 || out_insnp->expr.X_add_number > 255)) - as_bad (_("Immediate value not in 8 bit range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 8 bit range: %ld"), + &out_insnp->expr.X_add_number); /* Fall through. */ case 2: /* FIXME: We need an indicator in the instruction @@ -2132,8 +2147,8 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (out_insnp->expr.X_op == O_constant && (out_insnp->expr.X_add_number < -32768 || out_insnp->expr.X_add_number > 65535)) - as_bad (_("Immediate value not in 16 bit range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 16 bit range: %ld"), + &out_insnp->expr.X_add_number); out_insnp->imm_oprnd_size = 2; break; @@ -2162,18 +2177,18 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (instruction->imm_oprnd_size == SIZE_FIELD && (out_insnp->expr.X_add_number < -128 || out_insnp->expr.X_add_number > 255)) - as_bad (_("Immediate value not in 8 bit range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 8 bit range: %ld"), + &out_insnp->expr.X_add_number); else if (instruction->imm_oprnd_size == SIZE_FIELD_SIGNED && (out_insnp->expr.X_add_number < -128 || out_insnp->expr.X_add_number > 127)) - as_bad (_("Immediate value not in 8 bit signed range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 8 bit signed range: %ld"), + &out_insnp->expr.X_add_number); else if (instruction->imm_oprnd_size == SIZE_FIELD_UNSIGNED && (out_insnp->expr.X_add_number < 0 || out_insnp->expr.X_add_number > 255)) - as_bad (_("Immediate value not in 8 bit unsigned range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 8 bit unsigned range: %ld"), + &out_insnp->expr.X_add_number); } /* Fall through. */ @@ -2183,18 +2198,18 @@ cris_process_instruction (char *insn_text, struct cris_instruction *out_insnp, if (instruction->imm_oprnd_size == SIZE_FIELD && (out_insnp->expr.X_add_number < -32768 || out_insnp->expr.X_add_number > 65535)) - as_bad (_("Immediate value not in 16 bit range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 16 bit range: %ld"), + &out_insnp->expr.X_add_number); else if (instruction->imm_oprnd_size == SIZE_FIELD_SIGNED && (out_insnp->expr.X_add_number < -32768 || out_insnp->expr.X_add_number > 32767)) - as_bad (_("Immediate value not in 16 bit signed range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 16 bit signed range: %ld"), + &out_insnp->expr.X_add_number); else if (instruction->imm_oprnd_size == SIZE_FIELD_UNSIGNED && (out_insnp->expr.X_add_number < 0 || out_insnp->expr.X_add_number > 65535)) - as_bad (_("Immediate value not in 16 bit unsigned range: %ld"), - out_insnp->expr.X_add_number); + cris_bad (_("Immediate value not in 16 bit unsigned range: %ld"), + &out_insnp->expr.X_add_number); } out_insnp->imm_oprnd_size = 2; break; diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 70aa4008f68..b2d7af98136 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-06-17 Hans-Peter Nilsson + + * gas/cris/range-err-3.s: New test. + 2014-06-16 Jiong Wang * gas/aarch64/diagnostic.s: Add new test patterns. diff --git a/gas/testsuite/gas/cris/range-err-3.s b/gas/testsuite/gas/cris/range-err-3.s new file mode 100644 index 00000000000..601b24f8871 --- /dev/null +++ b/gas/testsuite/gas/cris/range-err-3.s @@ -0,0 +1,10 @@ +; Test more error cases for constant ranges. + +; { dg-do assemble { target cris-*-* } } + + .text +start: + asrq 63,$r0 ; { dg-error "mmediate value not in 5 bit unsigned range: 63" } + move 65536,$p0 ; { dg-error "mmediate value not in 8 bit range: 65536" } + move 65536,$p5 ; { dg-error "mmediate value not in 16 bit range: 65536" } + bdap.b 65536,$r0 ; { dg-error "mmediate value not in 8 bit signed range: 65536" } -- 2.39.2