From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 898D23858D1E; Fri, 30 Sep 2022 09:44:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 898D23858D1E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] RISC-V: fix build after "Add support for arbitrary immediate encoding formats" X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 3bf4994276269a241d97f8ccb5171fe581baa4cb X-Git-Newrev: b0423163b808c463fe35e861471f80123f0b309f Message-Id: <20220930094444.898D23858D1E@sourceware.org> Date: Fri, 30 Sep 2022 09:44:44 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2022 09:44:44 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db0423163b808= c463fe35e861471f80123f0b309f commit b0423163b808c463fe35e861471f80123f0b309f Author: Jan Beulich Date: Fri Sep 30 11:43:59 2022 +0200 RISC-V: fix build after "Add support for arbitrary immediate encoding f= ormats" =20 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 =3D strtol (++oparg, (char **)&oparg, 10); + n =3D strtol (oparg + 1, (char **)&oparg, 10); if (*oparg !=3D '@') goto unknown_validate_operand; - s =3D strtol (++oparg, (char **)&oparg, 10); + s =3D strtol (oparg + 1, (char **)&oparg, 10); oparg--; =20 USE_IMM (n, s); @@ -3327,10 +3327,10 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expr= essionS *imm_expr, sign =3D false; goto parse_imm; parse_imm: - n =3D strtol (++oparg, (char **)&oparg, 10); + n =3D strtol (oparg + 1, (char **)&oparg, 10); if (*oparg !=3D '@') goto unknown_riscv_ip_operand; - s =3D strtol (++oparg, (char **)&oparg, 10); + s =3D strtol (oparg + 1, (char **)&oparg, 10); oparg--; =20 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 =3D false; goto print_imm; print_imm: - n =3D strtol (++oparg, (char **)&oparg, 10); + n =3D strtol (oparg + 1, (char **)&oparg, 10); if (*oparg !=3D '@') goto undefined_modifier; - s =3D strtol (++oparg, (char **)&oparg, 10); + s =3D strtol (oparg + 1, (char **)&oparg, 10); oparg--; =20 if (!sign)