aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorJens Remus <jremus@linux.ibm.com>2024-03-01 12:45:14 +0100
committerJens Remus <jremus@linux.ibm.com>2024-03-01 12:45:14 +0100
commit6130dcb9e58209ee7679a38642ee43fb4a0b16d5 (patch)
treebdc6810dff67050ac83b92208ce0ec16b81421de /gas/config
parent5159682a61d4a874fb2428c7178f14da29ecedb7 (diff)
downloadbinutils-6130dcb9e58209ee7679a38642ee43fb4a0b16d5.zip
binutils-6130dcb9e58209ee7679a38642ee43fb4a0b16d5.tar.gz
binutils-6130dcb9e58209ee7679a38642ee43fb4a0b16d5.tar.bz2
s390: Enhance handling of syntax errors in assembler
Do not consume any unexpected character including newline ('\n') when detecting a syntax error when parsing an operand block with parenthesis. This resolves the unfavorable assembler messages from the example below, including consuming the newline at the end of the current statement and reporting the next statement as junk. While at it change the only pre-increment of the current instruction string pointer into a post-increment to align with the other instances. Example assembler source: mvi 16(),32 # syntax error a %r1,16(%r2 # syntax error a %r1,16(%r2) mvc 16(1,),32(%r2) # syntax error mvc 16(1,%r1,32(%r2 # syntax error Assembler messages without commit: 1: Error: bad expression 1: Error: syntax error; missing ')' after base register 1: Error: syntax error; expected ',' 1: Error: junk at end of line: `32' 2: Error: syntax error; missing ')' after base register 2: Error: junk at end of line: `a %r1,16(%r2)' 4: Error: bad expression 4: Error: syntax error; missing ')' after base register 4: Error: syntax error; expected ',' 4: Error: operand out of range (32 is not between 0 and 15) 4: Error: syntax error; missing ')' after base register 4: Error: junk at end of line: `%r2)' 5: Error: syntax error; missing ')' after base register 5: Error: syntax error; expected ',' 5: Error: operand out of range (32 is not between 0 and 15) 5: Error: syntax error; missing ')' after base register 5: Error: junk at end of line: `%r2' Assembler messages with commit: 1: Error: bad expression 1: Error: syntax error; missing ')' after base register 2: Error: syntax error; missing ')' after base register 4: Error: bad expression 4: Error: syntax error; missing ')' after base register 5: Error: syntax error; missing ')' after base register 5: Error: syntax error; missing ')' after base register gas/ * config/tc-s390.c: Do not erroneously consume newline when parsing an addressing operand with parentheses. Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-s390.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index 1b7935a..019f26b 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -1526,8 +1526,10 @@ md_gather_operands (char *str,
else if (operand->flags & S390_OPERAND_BASE)
{
/* After the base register the parenthesised block ends. */
- if (*str++ != ')')
+ if (*str != ')')
as_bad (_("syntax error; missing ')' after base register"));
+ else
+ str++;
skip_optional = 0;
if (*str == '\0' && skip_optargs_p (opcode->flags, &opindex_ptr[1]))
@@ -1584,7 +1586,7 @@ md_gather_operands (char *str,
}
while (ISSPACE (*str))
- ++str;
+ str++;
/* Check for tls instruction marker. */
reloc = s390_tls_suffix (&str, &ex);