Skip to contentSkip to conversation

target/avr: Fix compiler errors (-Werror=enum-conversion)

PATCH Applied Stefan Weil 3 participants 3 messages Jul 6, 2021 – Sep 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/avr: Fix compiler errors (-Werror=enum-conversion)

../target/avr/translate.c: In function ‘gen_jmp_ez’:
../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
1012 | ctx->base.is_jmp = DISAS_LOOKUP;
| ^

---

-Werror=enum-conversion is not enabled by -Wall, but by -Weverything with clang for example.

As other targets use similar define statements, I think that's a simple fix.

Regards,
Stefan

 target/avr/translate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
target/avr/translate.c +3 -5
index c06ce45bc7..fcc839ac36 100644
@@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8] = {
 };
 #define REG(x) (cpu_r[x])
 
-enum {
-    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main loop.  */
-    DISAS_LOOKUP = DISAS_TARGET_1,  /* We have a variable condition exit.  */
-    DISAS_CHAIN  = DISAS_TARGET_2,  /* We have a single condition exit.  */
-};
+#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main loop.  */
+#define DISAS_LOOKUP DISAS_TARGET_1  /* We have a variable condition exit.  */
+#define DISAS_CHAIN  DISAS_TARGET_2  /* We have a single condition exit.  */
 
 typedef struct DisasContext DisasContext;
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 52 lines · Stefan Weil

../target/avr/translate.c: In function ‘gen_jmp_ez’:
../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
1012 | ctx->base.is_jmp = DISAS_LOOKUP;
| ^

---

-Werror=enum-conversion is not enabled by -Wall, but by -Weverything with clang for example.

As other targets use similar define statements, I think that's a simple fix.

Regards,
Stefan

 target/avr/translate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
target/avr/translate.c +0 -2
index c06ce45bc7..fcc839ac36 100644
@@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8]
 = {
 };
 #define REG(x) (cpu_r[x])
 
-enum {
-    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main

loop. */
- DISAS_LOOKUP = DISAS_TARGET_1, /* We have a variable condition
exit. */
- DISAS_CHAIN = DISAS_TARGET_2, /* We have a single condition exit.
*/

target/avr/translate.c +1 -1
-};
+#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main

loop. */
+#define DISAS_LOOKUP DISAS_TARGET_1 /* We have a variable condition exit. */
+#define DISAS_CHAIN DISAS_TARGET_2 /* We have a single condition exit. */

typedef struct DisasContext DisasContext;

--
2.30.2

Signature · 2 lines
Best Regards,
Michael Rolnik
#2 lore raw
In reply to Stefan Weil

Le 06/07/2021 à 20:09, Stefan Weil a écrit :

Quoted 30 lines

../target/avr/translate.c: In function ‘gen_jmp_ez’:
../target/avr/translate.c:1012:22: error: implicit conversion from ‘enum <anonymous>’ to ‘DisasJumpType’ [-Werror=enum-conversion]
1012 | ctx->base.is_jmp = DISAS_LOOKUP;
| ^

---

-Werror=enum-conversion is not enabled by -Wall, but by -Weverything with clang for example.

As other targets use similar define statements, I think that's a simple fix.

Regards,
Stefan

 target/avr/translate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
target/avr/translate.c +0 -1
index c06ce45bc7..fcc839ac36 100644
@@ -70,11 +70,9 @@ static const char reg_names[NUMBER_OF_CPU_REGISTERS][8] = {
 };
 #define REG(x) (cpu_r[x])
 
-enum {

target/avr/translate.c static const char reg_names[NUMBER_OF_CPU_REGISTERS][8] = { · line 78

Quoted 10 lines
target/avr/translate.c +3 -4
-    DISAS_EXIT   = DISAS_TARGET_0,  /* We want return to the cpu main loop.  */
-    DISAS_LOOKUP = DISAS_TARGET_1,  /* We have a variable condition exit.  */
-    DISAS_CHAIN  = DISAS_TARGET_2,  /* We have a single condition exit.  */
-};
+#define DISAS_EXIT   DISAS_TARGET_0  /* We want return to the cpu main loop.  */
+#define DISAS_LOOKUP DISAS_TARGET_1  /* We have a variable condition exit.  */
+#define DISAS_CHAIN  DISAS_TARGET_2  /* We have a single condition exit.  */
 
 typedef struct DisasContext DisasContext;
 

Applied to my trivial-patches branch.

Thanks,
Laurent