[PATCH] target/hexagon: fix -Wshadow=local build error on GCC 14

Brian Cain posted 1 patch 1 week, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260716184207.3357340-1-brian.cain@oss.qualcomm.com
Maintainers: Brian Cain <brian.cain@oss.qualcomm.com>, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
target/hexagon/gen_tcg.h | 4 ++--
target/hexagon/macros.h  | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
[PATCH] target/hexagon: fix -Wshadow=local build error on GCC 14
Posted by Brian Cain 1 week, 2 days ago
With --disable-hexagon-idef-parser, tcg_funcs_generated.c.inc fails
to build under GCC 14 with:

  error: declaration of 'HALF' shadows a previous local
  [-Werror=shadow=local]

This became a hard error with GCC ced651b7757e `c23: tag compatibility
rules for enums`.

After that GCC change, DECL_FILE_SCOPE_P is false for all
enumerators, so shadowing now falls under -Wshadow=local.

Rename the local variable to tmp_half to avoid the collision.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/gen_tcg.h | 4 ++--
 target/hexagon/macros.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h
index a28af0c245b..40e03781d36 100644
--- a/target/hexagon/gen_tcg.h
+++ b/target/hexagon/gen_tcg.h
@@ -414,7 +414,7 @@
 
 #define fGEN_TCG_STORE(SHORTCODE) \
     do { \
-        TCGv HALF G_GNUC_UNUSED = tcg_temp_new(); \
+        TCGv tmp_half G_GNUC_UNUSED = tcg_temp_new(); \
         TCGv BYTE G_GNUC_UNUSED = tcg_temp_new(); \
         SHORTCODE; \
     } while (0)
@@ -422,7 +422,7 @@
 #define fGEN_TCG_STORE_pcr(SHIFT, STORE) \
     do { \
         TCGv ireg = tcg_temp_new(); \
-        TCGv HALF G_GNUC_UNUSED = tcg_temp_new(); \
+        TCGv tmp_half G_GNUC_UNUSED = tcg_temp_new(); \
         TCGv BYTE G_GNUC_UNUSED = tcg_temp_new(); \
         tcg_gen_mov_tl(EA, RxV); \
         gen_read_ireg(ireg, MuV, SHIFT); \
diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h
index 21ab8ae5bbf..8a32d5f79c2 100644
--- a/target/hexagon/macros.h
+++ b/target/hexagon/macros.h
@@ -576,8 +576,8 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)
     } while (0)
 
 #ifdef QEMU_GENERATE
-#define fGETHALF(N, SRC)  gen_get_half(HALF, N, SRC, true)
-#define fGETUHALF(N, SRC) gen_get_half(HALF, N, SRC, false)
+#define fGETHALF(N, SRC)  gen_get_half(tmp_half, N, SRC, true)
+#define fGETUHALF(N, SRC) gen_get_half(tmp_half, N, SRC, false)
 #else
 #define fGETHALF(N, SRC) ((int16_t)((SRC >> ((N) * 16)) & 0xffff))
 #define fGETUHALF(N, SRC) ((uint16_t)((SRC >> ((N) * 16)) & 0xffff))
-- 
2.34.1

Re: [PATCH] target/hexagon: fix -Wshadow=local build error on GCC 14
Posted by Pierrick Bouvier 1 week, 2 days ago
On 7/16/2026 11:41 AM, Brian Cain wrote:
> With --disable-hexagon-idef-parser, tcg_funcs_generated.c.inc fails
> to build under GCC 14 with:
> 
>   error: declaration of 'HALF' shadows a previous local
>   [-Werror=shadow=local]
> 
> This became a hard error with GCC ced651b7757e `c23: tag compatibility
> rules for enums`.
> 
> After that GCC change, DECL_FILE_SCOPE_P is false for all
> enumerators, so shadowing now falls under -Wshadow=local.
> 
> Rename the local variable to tmp_half to avoid the collision.
> 
> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
> ---
>  target/hexagon/gen_tcg.h | 4 ++--
>  target/hexagon/macros.h  | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>