Re: [PATCH v3] RISC-V: Fix build with GCC-8
Jan Beulich <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <[email protected]> |
On 23.06.2026 15:35, Mark Zhuang wrote: > From: Mark Zhuang <[email protected]> > > GCC 8.5.0 rejects a declaration right after a case label. > Add braces to fix it. While I said I'd take care of getting this in, now I really can't seeing that Maciej reported this breaks gcc10 (in a way unknown to me, as of yet). As this made me look at the patch again (just to see if I can spot anything, which I couldn't), ... > --- 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,13 +1813,15 @@ 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); > - break; > + { > + 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; > + } ... I think the "break" here and ... > @@ -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,20 +4356,22 @@ 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; > - continue; > + { > + 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; > + } ... the "continue" here would be nice to keep in their original positions, just like ... > --- 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; ... you do here. Once again, I'm happy to adjust while committing, just that first we need to understand and address the gcc10 issue. Maciej, please provide details. Jan