+2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
+
+ * config/tc-mips.c (match_const_int): Call `match_out_of_range'
+ rather than `match_not_constant' for unrelocated operands
+ retrieved as an `O_big' expression.
+ (match_int_operand): Call `match_out_of_range' for relocatable
+ operands retrieved as an `O_big' expression.
+ (match_mips16_insn): Call `match_out_of_range' for relaxable
+ operands retrieved as an `O_big' expression.
+ * testsuite/gas/mips/addiu-error.d: New test.
+ * testsuite/gas/mips/mips16@addiu-error.d: New test.
+ * testsuite/gas/mips/micromips@addiu-error.d: New test.
+ * testsuite/gas/mips/break-error.d: New test.
+ * testsuite/gas/mips/lui-1.l: Adjust error message.
+ * testsuite/gas/mips/addiu-error.l: New stderr output.
+ * testsuite/gas/mips/mips16@addiu-error.l: New stderr output.
+ * testsuite/gas/mips/micromips@addiu-error.l: New stderr output.
+ * testsuite/gas/mips/break-error.l: New stderr output.
+ * testsuite/gas/mips/addiu-error.s: New test source.
+ * testsuite/gas/mips/break-error.s: New test source.
+ * testsuite/gas/mips/mips.exp: Run the new tests.
+
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
* config/tc-mips.c (match_mips16_insn): Remove the explicit
*value = ex.X_add_number;
else
{
- match_not_constant (arg);
+ if (r[0] == BFD_RELOC_UNUSED && ex.X_op == O_big)
+ match_out_of_range (arg);
+ else
+ match_not_constant (arg);
return FALSE;
}
return TRUE;
if (!match_expression (arg, &offset_expr, offset_reloc))
return FALSE;
+ if (offset_expr.X_op == O_big)
+ {
+ match_out_of_range (arg);
+ return FALSE;
+ }
+
if (offset_reloc[0] != BFD_RELOC_UNUSED)
/* Relocation operators were used. Accept the argument and
leave the relocation value in offset_expr and offset_relocs
return FALSE;
}
+ if (offset_expr.X_op == O_big)
+ {
+ match_out_of_range (&arg);
+ return FALSE;
+ }
+
relax_char = c;
continue;
}
--- /dev/null
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: addiu-error.l
--- /dev/null
+.*: Assembler messages:
+.*:5: Error: operand 2 out of range `addiu \$2,-32769'
+.*:6: Error: operand 2 out of range `addiu \$2,65536'
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
--- /dev/null
+# Source code used to test error diagnostics with the ADDIU instruction.
+
+ .text
+foo:
+ addiu $2, -32769
+ addiu $2, 65536
+ addiu $2, 0x10000000000000000
+ addiu $2, $3
+ addiu $2, ($3)
+ addiu $2, 0+$3
+ addiu $2, (($3))
--- /dev/null
+#name: MIPS BREAK errors
+#as: -32
+#error-output: break-error.l
--- /dev/null
+.*: Assembler messages:
+.*:5: Error: operand 1 out of range `break -1'
+.*:6: Error: operand 1 out of range `break 65536'
+.*:7: Error: operand 1 out of range `break 0x10000000000000000'
+.*:8: Error: operand 1 must be an immediate expression `break \$3'
+.*:9: Error: invalid operands `break \(\$3\)'
+.*:10: Error: register value used as expression `break 0\+\$3'
+.*:11: Error: register value used as expression `break \(\(\$3\)\)'
--- /dev/null
+# Source code used to test error diagnostics with the BREAK instruction.
+
+ .text
+foo:
+ break -1
+ break 65536
+ break 0x10000000000000000
+ break $3
+ break ($3)
+ break 0+$3
+ break (($3))
.*\.s: Assembler messages:
.*\.s:5: Error: operand 2 out of range `lui \$2,-1'
.*\.s:6: Error: operand 2 out of range `lui \$2,65536'
-.*\.s:7: Error: bignum invalid
+.*\.s:7: Error: operand 2 out of range `lui \$2,0x10000000000000000'
.*\.s:8: Error: operand 2 must be an immediate expression `lui \$2,\$3'
.*\.s:9: Error: invalid operands `lui \$2,\(\$3\)'
.*\.s:10: Error: register value used as expression `lui \$2,0\+\$3'
--- /dev/null
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: micromips@addiu-error.l
+#source: addiu-error.s
--- /dev/null
+.*: Assembler messages:
+.*:5: Error: operand 2 out of range `addiu \$2,-32769'
+.*:6: Error: operand 2 out of range `addiu \$2,65536'
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: operand 2 out of range `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
run_dump_test_arches "lui" [mips_arch_list_matching mips1]
run_dump_test_arches "lui-1" [mips_arch_list_matching mips1]
run_dump_test_arches "lui-2" [mips_arch_list_matching mips1]
+ run_dump_test_arches "addiu-error" [mips_arch_list_all]
+ run_dump_test_arches "break-error" [mips_arch_list_all]
run_dump_test "r5900"
run_dump_test "r5900-full"
--- /dev/null
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: mips16@addiu-error.l
+#source: addiu-error.s
--- /dev/null
+.*: Assembler messages:
+.*:5: Error: operand value out of range for instruction
+.*:6: Error: operand value out of range for instruction
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'