diff mbox series

[v4,08/16] configure: Use -Wunused-const-variable

Message ID 20180818190118.12911-9-richard.henderson@linaro.org
State New
Headers show
Series linux-user: Split do_syscall | expand

Commit Message

Richard Henderson Aug. 18, 2018, 7:01 p.m. UTC
For the linux-user syscall split, we have static const structs
that must be matched up with a switch statement that uses them.
By default, gcc will not warn for such a variable, but silently
remove them.

For C++, such objects are sometimes declared for their constructor
side effects.  Do not propagate this flag into QEM_CXXFLAGS.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Laurent Vivier Aug. 21, 2018, 5:29 p.m. UTC | #1
Le 18/08/2018 à 21:01, Richard Henderson a écrit :
> For the linux-user syscall split, we have static const structs

> that must be matched up with a switch statement that uses them.

> By default, gcc will not warn for such a variable, but silently

> remove them.

> 

> For C++, such objects are sometimes declared for their constructor

> side effects.  Do not propagate this flag into QEM_CXXFLAGS.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  configure | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)


Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Laurent Vivier Aug. 21, 2018, 5:34 p.m. UTC | #2
Le 18/08/2018 à 21:01, Richard Henderson a écrit :
> For the linux-user syscall split, we have static const structs

> that must be matched up with a switch statement that uses them.

> By default, gcc will not warn for such a variable, but silently

> remove them.

> 

> For C++, such objects are sometimes declared for their constructor

> side effects.  Do not propagate this flag into QEM_CXXFLAGS.


s/QEM_CXXFLAGS/QEMU_CXXFLAGS/

Laurent
Laurent Vivier Aug. 22, 2018, 1:06 a.m. UTC | #3
Le 18/08/2018 à 21:01, Richard Henderson a écrit :
> For the linux-user syscall split, we have static const structs

> that must be matched up with a switch statement that uses them.

> By default, gcc will not warn for such a variable, but silently

> remove them.

> 

> For C++, such objects are sometimes declared for their constructor

> side effects.  Do not propagate this flag into QEM_CXXFLAGS.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  configure | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/configure b/configure

> index db97930314..86e6e18428 100755

> --- a/configure

> +++ b/configure

> @@ -105,7 +105,8 @@ update_cxxflags() {

>      for arg in $QEMU_CFLAGS; do

>          case $arg in

>              -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\

> -            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)

> +            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls|\

> +            -Wunused-const-variable)

>                  ;;

>              *)

>                  QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg

> @@ -1780,6 +1781,7 @@ gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"

>  gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"

>  gcc_flags="-Wno-string-plus-int $gcc_flags"

>  gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"

> +gcc_flags="-Wunused-const-variable $gcc_flags"

>  # Note that we do not add -Werror to gcc_flags here, because that would

>  # enable it for all configure tests. If a configure test failed due

>  # to -Werror this would just silently disable some features,

> 


This breaks build of hw/misc/macio/gpio.o:

In file included from include/hw/misc/macio/macio.h:33,
                 from hw/misc/macio/gpio.c:29:
hw/misc/macio/pmu.h:129:21: error: 'pmu_data_len' defined but not used
[-Werror=unused-const-variable=]
 static const int8_t pmu_data_len[256][2] = {
                     ^~~~~~~~~~~~
In file included from include/hw/misc/macio/macio.h:33,
                 from hw/misc/macio/macio.c:33:
include/hw/misc/macio/pmu.h:129:21: error: 'pmu_data_len' defined but
not used [-Werror=unused-const-variable=]
 static const int8_t pmu_data_len[256][2] = {
                     ^~~~~~~~~~~~

This can be fixed by moving pmu_data_len array from pmu.h to pmu.c as it
is the only user.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/configure b/configure
index db97930314..86e6e18428 100755
--- a/configure
+++ b/configure
@@ -105,7 +105,8 @@  update_cxxflags() {
     for arg in $QEMU_CFLAGS; do
         case $arg in
             -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
-            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
+            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls|\
+            -Wunused-const-variable)
                 ;;
             *)
                 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
@@ -1780,6 +1781,7 @@  gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
 gcc_flags="-Wno-string-plus-int $gcc_flags"
 gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
+gcc_flags="-Wunused-const-variable $gcc_flags"
 # Note that we do not add -Werror to gcc_flags here, because that would
 # enable it for all configure tests. If a configure test failed due
 # to -Werror this would just silently disable some features,