aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2023-04-25 11:16:44 +0200
committerJan Beulich <jbeulich@suse.com>2023-04-25 11:16:44 +0200
commita5e756e63e170cf69e06be98287528760833aad5 (patch)
treec010397cb5e728e61cc5626fdcaa9135226dee39
parent408ab0161d09ff29e258c8ff1bb02ec5e084087c (diff)
downloadgdb-a5e756e63e170cf69e06be98287528760833aad5.zip
gdb-a5e756e63e170cf69e06be98287528760833aad5.tar.gz
gdb-a5e756e63e170cf69e06be98287528760833aad5.tar.bz2
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".
-rw-r--r--gas/config/tc-riscv.c9
-rw-r--r--gas/testsuite/gas/riscv/tprel-add.l1
2 files changed, 9 insertions, 1 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 160161c..6b7112b 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 74bb535..1378c27 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'