public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] RISC-V: avoid redundant and misleading/wrong error messages
@ 2023-04-25  9:19 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-04-25  9:19 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5e756e63e170cf69e06be98287528760833aad5

commit a5e756e63e170cf69e06be98287528760833aad5
Author: Jan Beulich <jbeulich@suse.com>
Date:   Tue Apr 25 11:16:44 2023 +0200

    RISC-V: avoid redundant and misleading/wrong error messages
    
    The use of a wrong (for the insn) relocation operator (or a future one
    which simply isn't recognized by older gas yet) doesn't render the (rest
    of the) expression "bad". Furthermore alongside the error from
    expression() in most cases the parser would emit another error then
    anyway. Suppress the call to my_getExpression() in such a case,
    arranging for a guaranteed subsequent error message by marking the
    expression "illegal".

Diff:
---
 gas/config/tc-riscv.c               | 9 +++++++++
 gas/testsuite/gas/riscv/tprel-add.l | 1 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 160161c3c75..6b7112bc7c7 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2279,6 +2279,15 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
 	 && reloc_index < 1
 	 && parse_relocation (&str, reloc, percent_op));
 
+  if (*str == '%')
+    {
+       /* expression() will choke on anything looking like an (unrecognized)
+	  relocation specifier.  Don't even call it, avoiding multiple (and
+	  perhaps redundant) error messages; our caller will issue one.  */
+       ep->X_op = O_illegal;
+       return 0;
+    }
+
   my_getExpression (ep, crux);
   str = expr_parse_end;
 
diff --git a/gas/testsuite/gas/riscv/tprel-add.l b/gas/testsuite/gas/riscv/tprel-add.l
index 74bb5352971..1378c274d9a 100644
--- a/gas/testsuite/gas/riscv/tprel-add.l
+++ b/gas/testsuite/gas/riscv/tprel-add.l
@@ -1,4 +1,3 @@
 .*: Assembler messages:
-.*: Error: bad expression
 .*: Error: illegal operands `amoadd.w x8,x9,%tprel_add\(i\)\(x10\)'
 .*: Error: illegal operands `add a5,a5,tp,0'

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-25  9:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25  9:19 [binutils-gdb] RISC-V: avoid redundant and misleading/wrong error messages Jan Beulich

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).