Skip to content

Commit

Permalink
[RV64_DYNAREC] Fix compilation error in _helper.c
Browse files Browse the repository at this point in the history
Fix compilation error in RV64 dynarec helper function

Encountered a compilation failure with gcc 10.2.0 for RISC-V
when trying to declare a variable within a switch case
without enclosing it in braces.
This change fixes the issue by adding curly braces around the code block
inside the case statement, which is necessary for older versions of GCC
that require a declaration to be part of a block.

This resolves the error:
"error: a label can only be part of a statement and a declaration is not a statement"

Now, variable declarations inside switch cases are enclosed in braces
to ensure compatibility with older compilers and maintain consistent coding style.
  • Loading branch information
devarajabc committed Oct 22, 2024
1 parent ffe2736 commit ca82dd4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dynarec/rv64/dynarec_rv64_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2694,11 +2694,12 @@ void vector_loadmask(dynarec_rv64_t* dyn, int ninst, int vreg, uint64_t imm, int
ADDI(s1, xZR, 1);
VMV_S_X(vreg, s1);
return;
case 2:
case 2: {
int scratch = fpu_get_scratch(dyn);
VMV_V_I(scratch, 1);
VSLIDE1UP_VX(vreg, scratch, xZR, VECTOR_UNMASKED);
return;
}
case 3:
VMV_V_I(vreg, 1);
return;
Expand Down

0 comments on commit ca82dd4

Please sign in to comment.