[binutils-gdb] RISC-V: Fix build with clang and gcc prior to gcc11
Alan Modra via Binutils-cvs <[email protected]> Mon, 29 Jun 2026 03:40:15 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e5ab72bd1d8fd5fa532bae67208e85ec4412230 commit 7e5ab72bd1d8fd5fa532bae67208e85ec4412230 Author: Mark Zhuang <[email protected]> Date: Tue Jun 23 21:35:08 2026 +0800 RISC-V: Fix build with clang and gcc prior to gcc11 A label followed by a declaration is a C23 extension. Add braces to fix it. Diff: --- gas/config/tc-riscv.c | 46 +++++++++++++++++++++++----------------------- opcodes/riscv-dis.c | 16 ++++++++++------ 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 5ffa2ef1f1d..28875e77ff0 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -1791,8 +1791,6 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length) } break; case 'p': /* Vendor-specific (SpacemiT) operands. */ - size_t n; - size_t s; switch (*++oparg) { case 'V': @@ -1815,12 +1813,14 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length) break; case 'u': /* Integer immediate, 'XpuN@S' ... N-bit unsigned immediate at bit S. */ - n = strtol (oparg + 1, (char **)&oparg, 10); - if (*oparg != '@') - goto unknown_validate_operand; - s = strtol (oparg + 1, (char **)&oparg, 10); - oparg--; - USE_IMM (n, s); + { + size_t n = strtol (oparg + 1, (char **)&oparg, 10); + if (*oparg != '@') + goto unknown_validate_operand; + size_t s = strtol (oparg + 1, (char **)&oparg, 10); + oparg--; + USE_IMM (n, s); + } break; case 'n': case 'b': @@ -4309,8 +4309,6 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, break; case 'p': /* Vendor-specific (SpacemiT) operands. */ - size_t n; - size_t s; switch (*++oparg) { case 'V': @@ -4358,19 +4356,21 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, break; case 'u': /* Integer immediate, 'XpuN@S' ... N-bit unsigned immediate at bit S. */ - n = strtol (oparg + 1, (char **)&oparg, 10); - if (*oparg != '@') - goto unknown_riscv_ip_operand; - s = strtol (oparg + 1, (char **)&oparg, 10); - oparg--; - my_getExpression (imm_expr, asarg, force_reloc); - check_absolute_expr (ip, imm_expr, false); - if (!VALIDATE_U_IMM (imm_expr->X_add_number, n)) - as_bad (_("improper immediate value (%"PRIu64")"), - imm_expr->X_add_number); - INSERT_IMM (n, s, *ip, imm_expr->X_add_number); - imm_expr->X_op = O_absent; - asarg = expr_parse_end; + { + size_t n = strtol (oparg + 1, (char **)&oparg, 10); + if (*oparg != '@') + goto unknown_riscv_ip_operand; + size_t s = strtol (oparg + 1, (char **)&oparg, 10); + oparg--; + my_getExpression (imm_expr, asarg, force_reloc); + check_absolute_expr (ip, imm_expr, false); + if (!VALIDATE_U_IMM (imm_expr->X_add_number, n)) + as_bad (_("improper immediate value (%"PRIu64")"), + imm_expr->X_add_number); + INSERT_IMM (n, s, *ip, imm_expr->X_add_number); + imm_expr->X_op = O_absent; + asarg = expr_parse_end; + } continue; case 'n': /* Xpn: stride (0-1), paired with Xpx. */ my_getExpression (imm_expr, asarg, force_reloc); diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index ca0d9bfd121..edb9ce04778 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -924,14 +924,18 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info switch (*++oparg) { case 'd': - unsigned vd = EXTRACT_OPERAND (SPACEMIT_IME_VD, l) * 2; - print (info->stream, dis_style_register, "%s", - riscv_vecr_names_numeric[vd]); + { + unsigned vd = EXTRACT_OPERAND (SPACEMIT_IME_VD, l) * 2; + print (info->stream, dis_style_register, "%s", + riscv_vecr_names_numeric[vd]); + } break; case 's': - unsigned vs = EXTRACT_OPERAND (SPACEMIT_IME_VS1, l) * 2; - print (info->stream, dis_style_register, "%s", - riscv_vecr_names_numeric[vs]); + { + unsigned vs = EXTRACT_OPERAND (SPACEMIT_IME_VS1, l) * 2; + print (info->stream, dis_style_register, "%s", + riscv_vecr_names_numeric[vs]); + } break; case 'm': {