From: Jan Beulich <jbeulich@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] RISC-V: avoid redundant and misleading/wrong error messages
Date: Tue, 25 Apr 2023 09:19:41 +0000 (GMT) [thread overview]
Message-ID: <20230425091941.D378D3858D1E@sourceware.org> (raw)
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'
reply other threads:[~2023-04-25 9:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230425091941.D378D3858D1E@sourceware.org \
--to=jbeulich@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/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).