a syntax error is detected in an optional operand.
* config/tc-aarch64.c (END_OF_INSN): New macro.
(parse_operands): Handle operand given and be in wrong
format when operand is optional.
* gas/aarch64/diagnostic.s: New test patterns.
* gas/aarch64/diagnostic.l: Likewise.
+2014-06-16 Jiong Wang <jiong.wang@arm.com>
+
+ * config/tc-aarch64.c (END_OF_INSN): New macro.
+ (parse_operands): Handle operand given and in wrong format when
+ operand is optional.
+
2014-06-16 Alan Modra <amodra@gmail.com>
* write.h (subsegs_finish): Delete declaration.
#define streq(a, b) (strcmp (a, b) == 0)
+#define END_OF_INSN '\0'
+
static aarch64_feature_set cpu_variant;
/* Variables that we set while parsing command-line options. Once all
if (! backtrack_pos)
goto parse_operands_return;
+ {
+ /* We reach here because this operand is marked as optional, and
+ either no operand was supplied or the operand was supplied but it
+ was syntactically incorrect. In the latter case we report an
+ error. In the former case we perform a few more checks before
+ dropping through to the code to insert the default operand. */
+
+ char *tmp = backtrack_pos;
+ char endchar = END_OF_INSN;
+
+ if (i != (aarch64_num_of_operands (opcode) - 1))
+ endchar = ',';
+ skip_past_char (&tmp, ',');
+
+ if (*tmp != endchar)
+ /* The user has supplied an operand in the wrong format. */
+ goto parse_operands_return;
+
+ /* Make sure there is not a comma before the optional operand.
+ For example the fifth operand of 'sys' is optional:
+
+ sys #0,c0,c0,#0, <--- wrong
+ sys #0,c0,c0,#0 <--- correct. */
+ if (comma_skipped_p && i && endchar == END_OF_INSN)
+ {
+ set_fatal_syntax_error
+ (_("unexpected comma before the omitted optional operand"));
+ goto parse_operands_return;
+ }
+ }
+
/* Reaching here means we are dealing with an optional operand that is
omitted from the assembly line. */
gas_assert (optional_operand_p (opcode, i));
str = backtrack_pos;
backtrack_pos = 0;
- /* If this is the last operand that is optional and omitted, but without
- the presence of a comma. */
- if (i && comma_skipped_p && i == aarch64_num_of_operands (opcode) - 1)
- {
- set_fatal_syntax_error
- (_("unexpected comma before the omitted optional operand"));
- goto parse_operands_return;
- }
-
/* Clear any error record after the omitted optional operand has been
successfully handled. */
clear_error ();
+2014-06-16 Jiong Wang <jiong.wang@arm.com>
+
+ * gas/aarch64/diagnostic.s: Add new test patterns.
+ * gas/aarch64/diagnostic.l: Update expected diagnostic output.
+
2014-06-16 Alan Modra <amodra@gmail.com>
* gas/elf/bad-group.s: Use %function.
[^:]*:16: Error: immediate value out of range 0 to 31 at operand 2 -- `ccmp x0,-1,10,le'
[^:]*:17: Error: extraneous register at operand 2 -- `tlbi alle3is,x0'
[^:]*:18: Error: missing register at operand 2 -- `tlbi vaale1is'
-[^:]*:19: Error: unexpected characters following instruction at operand 1 -- `tlbi vaale1is x0'
+[^:]*:19: Error: comma expected between operands at operand 2 -- `tlbi vaale1is x0'
[^:]*:20: Error: immediate value out of range 0 to 1 at operand 1 -- `msr spsel,3'
[^:]*:21: Error: immediate value out of range 1 to 64 at operand 3 -- `fcvtzu x15,d31,#66'
[^:]*:22: Error: immediate value out of range 1 to 32 at operand 3 -- `scvtf s0,w0,33'
[^:]*:99: Error: operand 3 should be one of the standard conditions, excluding AL and NV. -- `cinc w0,w1,nv'
[^:]*:100: Error: operand 2 should be one of the standard conditions, excluding AL and NV. -- `cset w0,al'
[^:]*:101: Error: operand 2 should be one of the standard conditions, excluding AL and NV. -- `cset w0,nv'
+[^:]*:104: Error: operand 1 should be an integer register -- `ret lr'
+[^:]*:105: Error: operand 1 should be an integer register -- `ret kk'
+[^:]*:106: Error: immediate operand required at operand 1 -- `clrex x0'
+[^:]*:107: Error: immediate operand required at operand 1 -- `clrex w0'
+[^:]*:108: Error: constant expression required at operand 1 -- `clrex kk'
+[^:]*:109: Error: operand 5 should be an integer register -- `sys #0,c0,c0,#0,kk'
+[^:]*:110: Error: unexpected comma before the omitted optional operand at operand 5 -- `sys #0,c0,c0,#0,'
cinc w0, w1, nv
cset w0, al
cset w0, nv
+
+ # test diagnostic info on optional operand
+ ret lr
+ ret kk
+ clrex x0
+ clrex w0
+ clrex kk
+ sys #0, c0, c0, #0, kk
+ sys #0, c0, c0, #0,