diff options
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-aarch64.c | 42 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/aarch64/diagnostic.l | 9 | ||||
-rw-r--r-- | gas/testsuite/gas/aarch64/diagnostic.s | 9 |
5 files changed, 61 insertions, 10 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index e62969c..08d2c26 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 67c0871..2509529 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -42,6 +42,8 @@ #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 @@ -5302,6 +5304,37 @@ failure: 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)); @@ -5312,15 +5345,6 @@ failure: 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 (); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index c146d66..70aa400 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/gas/testsuite/gas/aarch64/diagnostic.l b/gas/testsuite/gas/aarch64/diagnostic.l index 00a0d7a..88a004f 100644 --- a/gas/testsuite/gas/aarch64/diagnostic.l +++ b/gas/testsuite/gas/aarch64/diagnostic.l @@ -14,7 +14,7 @@ [^:]*: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' @@ -97,3 +97,10 @@ [^:]*: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,' diff --git a/gas/testsuite/gas/aarch64/diagnostic.s b/gas/testsuite/gas/aarch64/diagnostic.s index 2bb16b0..241f0cc 100644 --- a/gas/testsuite/gas/aarch64/diagnostic.s +++ b/gas/testsuite/gas/aarch64/diagnostic.s @@ -99,3 +99,12 @@ 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, |