aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-aarch64.c
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2014-06-16 17:22:19 +0100
committerNick Clifton <nickc@redhat.com>2014-06-16 17:22:19 +0100
commitf4c51f600ed2fcf9f29bdaae71aa767b9b1bc4ac (patch)
treed97cf438a17a872f8fcce3d10d99a85573e9a1f5 /gas/config/tc-aarch64.c
parent9f19ab6dfa13c3971423624d18f20d90ab70c9cc (diff)
downloadgdb-f4c51f600ed2fcf9f29bdaae71aa767b9b1bc4ac.zip
gdb-f4c51f600ed2fcf9f29bdaae71aa767b9b1bc4ac.tar.gz
gdb-f4c51f600ed2fcf9f29bdaae71aa767b9b1bc4ac.tar.bz2
This fixes the aarch64 assembler so that it will generate error messages when
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.
Diffstat (limited to 'gas/config/tc-aarch64.c')
-rw-r--r--gas/config/tc-aarch64.c42
1 files changed, 33 insertions, 9 deletions
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 ();