public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] RISC-V: fix build after "Add support for arbitrary immediate encoding formats"
@ 2022-09-30  9:44 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2022-09-30  9:44 UTC (permalink / raw)
  To: bfd-cvs

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

commit b0423163b808c463fe35e861471f80123f0b309f
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Sep 30 11:43:59 2022 +0200

    RISC-V: fix build after "Add support for arbitrary immediate encoding formats"
    
    Pre- and post-increment/decrement are side effects, the behavior of
    which is undefined when combined with passing an address of the accessed
    variable in the same function invocation. There's no need for the
    increments here - simply adding 1 achieves the intended effect without
    triggering compiler diagnostics (which are fatal with -Werror).

Diff:
---
 gas/config/tc-riscv.c | 8 ++++----
 opcodes/riscv-dis.c   | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index d9f63b11398..38ff016dbb1 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1287,10 +1287,10 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length)
 		case 'u': /* 'XuN@S' ... N-bit unsigned immediate at bit S.  */
 		  goto use_imm;
 		use_imm:
-		  n = strtol (++oparg, (char **)&oparg, 10);
+		  n = strtol (oparg + 1, (char **)&oparg, 10);
 		  if (*oparg != '@')
 		    goto unknown_validate_operand;
-		  s = strtol (++oparg, (char **)&oparg, 10);
+		  s = strtol (oparg + 1, (char **)&oparg, 10);
 		  oparg--;
 
 		  USE_IMM (n, s);
@@ -3327,10 +3327,10 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
 		      sign = false;
 		      goto parse_imm;
 		    parse_imm:
-		      n = strtol (++oparg, (char **)&oparg, 10);
+		      n = strtol (oparg + 1, (char **)&oparg, 10);
 		      if (*oparg != '@')
 			goto unknown_riscv_ip_operand;
-		      s = strtol (++oparg, (char **)&oparg, 10);
+		      s = strtol (oparg + 1, (char **)&oparg, 10);
 		      oparg--;
 
 		      my_getExpression (imm_expr, asarg);
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index f2d399260c1..6ac69490b78 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -586,10 +586,10 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 		  sign = false;
 		  goto print_imm;
 		print_imm:
-		  n = strtol (++oparg, (char **)&oparg, 10);
+		  n = strtol (oparg + 1, (char **)&oparg, 10);
 		  if (*oparg != '@')
 		    goto undefined_modifier;
-		  s = strtol (++oparg, (char **)&oparg, 10);
+		  s = strtol (oparg + 1, (char **)&oparg, 10);
 		  oparg--;
 
 		  if (!sign)

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

only message in thread, other threads:[~2022-09-30  9:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30  9:44 [binutils-gdb] RISC-V: fix build after "Add support for arbitrary immediate encoding formats" 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).