public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jens Remus <jremus@linux.ibm.com>
To: binutils@sourceware.org
Cc: Jens Remus <jremus@linux.ibm.com>,
	Andreas Krebbel <krebbel@linux.ibm.com>
Subject: [PATCH 02/14] s390: Enhance handling of syntax errors in assembler
Date: Thu, 15 Feb 2024 16:58:09 +0100	[thread overview]
Message-ID: <20240215155821.4065623-3-jremus@linux.ibm.com> (raw)
In-Reply-To: <20240215155821.4065623-1-jremus@linux.ibm.com>

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>
---
 gas/config/tc-s390.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index 1b7935a848d0..019f26b2f4ab 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);
-- 
2.40.1


  parent reply	other threads:[~2024-02-15 15:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 15:58 [PATCH 00/14] s390: Enhancements to working with addressing operands Jens Remus
2024-02-15 15:58 ` [PATCH 01/14] s390: Lower severity of assembler syntax errors from fatal to error Jens Remus
2024-02-15 15:58 ` Jens Remus [this message]
2024-02-15 15:58 ` [PATCH 03/14] s390: Do not erroneously use base operand value for length operand Jens Remus
2024-02-15 15:58 ` [PATCH 04/14] s390: Correct setting of highgprs flag in ELF output Jens Remus
2024-02-15 15:58 ` [PATCH 05/14] s390: Assemble processor specific test cases for their processor Jens Remus
2024-02-15 15:58 ` [PATCH 06/14] s390: Add comments to assembler operand parsing logic Jens Remus
2024-02-15 15:58 ` [PATCH 07/14] s390: Add test cases for base/index register 0 Jens Remus
2024-02-15 15:58 ` [PATCH 08/14] s390: Add test case for disassembler option warn-areg-zero Jens Remus
2024-02-15 15:58 ` [PATCH 09/14] s390: Revise s390-specific assembler option descriptions Jens Remus
2024-02-15 15:58 ` [PATCH 10/14] s390: Warn when register name type does not match operand Jens Remus
2024-02-15 15:58 ` [PATCH 11/14] s390: Print base register 0 as "0" in disassembly Jens Remus
2024-02-15 15:58 ` [PATCH 12/14] s390: Allow to explicitly omit base register operand in assembly Jens Remus
2024-02-15 15:58 ` [PATCH 13/14] s390: Provide operand number in assembler warning and error messages Jens Remus
2024-02-15 15:58 ` [PATCH 14/14] s390: Be more verbose about missing operand type Jens Remus
2024-03-01 12:24 ` [PATCH 00/14] s390: Enhancements to working with addressing operands Jens Remus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240215155821.4065623-3-jremus@linux.ibm.com \
    --to=jremus@linux.ibm.com \
    --cc=binutils@sourceware.org \
    --cc=krebbel@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).