aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@bitrange.com>2014-06-17 00:56:01 +0200
committerHans-Peter Nilsson <hp@bitrange.com>2014-06-17 00:56:01 +0200
commit29cf29a2cf1a5df53c9b77cce8916e8c0fc82e12 (patch)
tree4d834730fd48ffcc268e3493618d4034c860d362 /gas
parent6be47f0c48cbd58921a25e7493ca79a6f596dffe (diff)
downloadbinutils-29cf29a2cf1a5df53c9b77cce8916e8c0fc82e12.zip
binutils-29cf29a2cf1a5df53c9b77cce8916e8c0fc82e12.tar.gz
binutils-29cf29a2cf1a5df53c9b77cce8916e8c0fc82e12.tar.bz2
GAS: Fix CRIS double-error reports caused by recent generic GAS changes.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-cris.c63
-rw-r--r--gas/testsuite/ChangeLog4
-rw-r--r--gas/testsuite/gas/cris/range-err-3.s10
4 files changed, 59 insertions, 24 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 31d343a..9e3a320 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-17 Hans-Peter Nilsson <hp@axis.com>
+
+ * config/tc-cris.c (cris_bad): New function.
+ (cris_process_instruction): Where applicable, use it instead of
+ as_bad.
+
2014-06-16 Nick Clifton <nickc@redhat.com>
* 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 aba4ef7..2989f02 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 70aa400..b2d7af9 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-17 Hans-Peter Nilsson <hp@axis.com>
+
+ * gas/cris/range-err-3.s: New test.
+
2014-06-16 Jiong Wang <jiong.wang@arm.com>
* 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 0000000..601b24f
--- /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" }