clang: Disable warning about expansion to 'defined'
PATCH 1/1 clang: Disable warning about expansion to 'defined'
Clang produces the following warning. The warning is detailed here:
https://reviews.llvm.org/D15866. Disable the warning.
/home/pranith/devops/code/qemu/hw/display/qxl.c:507:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if SPICE_NEEDS_SET_MM_TIME
^
/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06))
^
/home/pranith/devops/code/qemu/hw/display/qxl.c:1074:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if SPICE_NEEDS_SET_MM_TIME
^/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06))
--- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+)
configure +13 -0
@@ -3025,6 +3025,19 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then fi fi +# Silence clang warnings about expansion to 'defined' in macro +cat > $TMPC << EOF +#define TEST (defined(DUMMY)) +#if TEST +int main(void) { return 0; } +#endif +EOF +if ! compile_prog "-Werror" ; then + if cc_has_warning_flag "-Wno-expansion-to-defined"; then + CFLAGS="-Wno-expansion-to-defined $CFLAGS" + fi +fi + ########################################## # SHA command probe for modules if test "$modules" = yes; then
Signature · 1 line
2.9.2
Quoted 35 lines · Pranith Kumar
Clang produces the following warning. The warning is detailed here:
https://reviews.llvm.org/D15866. Disable the warning.
/home/pranith/devops/code/qemu/hw/display/qxl.c:507:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]#if SPICE_NEEDS_SET_MM_TIME ^ /home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME' (!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)) ^ /home/pranith/devops/code/qemu/hw/display/qxl.c:1074:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] #if SPICE_NEEDS_SET_MM_TIME ^
/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION<0xc06))Signed-off-by Pranith Kumar <[email protected]>--- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+)configure +6
-0@@ -3025,6 +3025,19 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then fi fi +# Silence clang warnings about expansion to 'defined' in macro +cat > $TMPC << EOF +#define TEST (defined(DUMMY)) +#if TEST +int main(void) { return 0; } +#endif
configure if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then · line 3043
Quoted 10 lines
configure +7
-0+EOF +if ! compile_prog "-Werror" ; then + if cc_has_warning_flag "-Wno-expansion-to-defined"; then + CFLAGS="-Wno-expansion-to-defined $CFLAGS" + fi +fi + ########################################## # SHA command probe for modules if test "$modules" = yes; then
Can you just add it to gcc_flags instead?
Thanks,
Paolo
Quoted 12 lines · Pranith Kumar
Clang produces the following warning. The warning is detailed here:
https://reviews.llvm.org/D15866. Disable the warning.
/home/pranith/devops/code/qemu/hw/display/qxl.c:507:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]#if SPICE_NEEDS_SET_MM_TIME ^ /home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME' (!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)) ^ /home/pranith/devops/code/qemu/hw/display/qxl.c:1074:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] #if SPICE_NEEDS_SET_MM_TIME ^
Quoted 2 lines
/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION<0xc06))
Is this the only thing in our code which provokes the warning? If so, why don't we just fix it to not be undefined behaviour?
thanks
-- PMM
Quoted 16 lines · Peter Maydell
Quoted 12 lines · Pranith Kumar
Clang produces the following warning. The warning is detailed here:
https://reviews.llvm.org/D15866. Disable the warning.
/home/pranith/devops/code/qemu/hw/display/qxl.c:507:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]#if SPICE_NEEDS_SET_MM_TIME ^ /home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME' (!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)) ^ /home/pranith/devops/code/qemu/hw/display/qxl.c:1074:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] #if SPICE_NEEDS_SET_MM_TIME ^Quoted 2 lines
/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION<0xc06))
Quoted 2 lines
Is this the only thing in our code which provokes the warning? If so, why don't we just fix it to not be undefined behaviour?
Indeed, it looks like it could be fixed by changing include/ui/qemu-spice.h
#define SPICE_NEEDS_SET_MM_TIME \
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06))
to be
#if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06) #define SPICE_NEEDS_SET_MM_TIME
#endif
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 16 lines · Peter Maydell
Quoted 12 lines · Pranith Kumar
Clang produces the following warning. The warning is detailed here:
https://reviews.llvm.org/D15866. Disable the warning.
/home/pranith/devops/code/qemu/hw/display/qxl.c:507:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]#if SPICE_NEEDS_SET_MM_TIME ^ /home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME' (!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06)) ^ /home/pranith/devops/code/qemu/hw/display/qxl.c:1074:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] #if SPICE_NEEDS_SET_MM_TIME ^Quoted 2 lines
/home/pranith/devops/code/qemu/include/ui/qemu-spice.h:46:5: note: expanded from macro 'SPICE_NEEDS_SET_MM_TIME'
(!defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION<0xc06))
Quoted 2 lines
Is this the only thing in our code which provokes the warning? If so, why don't we just fix it to not be undefined behaviour?
Indeed that was my first suggestion yesterday. However, we use -Wundef (a good idea, I think), and fixing it would cause the -Wundef warning to appear instead.
Paolo
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Peter Maydell
Is this the only thing in our code which provokes the warning? If so, why don't we just fix it to not be undefined behaviour?
Indeed that was my first suggestion yesterday. However, we use -Wundef (a good idea, I think), and fixing it would cause the -Wundef warning to appear instead.
Why would
#if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06) #define SPICE_NEEDS_SET_MM_TIME 1
#else
#define SPICE_NEEDS_SET_MM_TIME 0
#endif
provoke a Wundef warning?
thanks
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Peter Maydell
Is this the only thing in our code which provokes the warning? If so, why don't we just fix it to not be undefined behaviour?
Indeed that was my first suggestion yesterday. However, we use -Wundef (a good idea, I think), and fixing it would cause the -Wundef warning to appear instead.
Quoted 8 lines
Why would
#if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION<0xc06) #defineSPICE_NEEDS_SET_MM_TIME1
#else
#defineSPICE_NEEDS_SET_MM_TIME0
#endifprovoke a Wundef warning?
Oh, that would work indeed. I was thinking of simplifying the definition of SPICE_NEEDS_SET_MM_TIME like this:
#define SPICE_NEEDS_SET_MM_TIME (SPICE_SERVER_VERSION < 0xc06)
If we do this, it would make sense to add -Wexpansion-to-defined to GCC and enable it (though I still believe it's wrong to add it to -Wall).
Thanks,
Paolo
Quoted 6 lines · Peter Maydell
#if !defined(SPICE_SERVER_VERSION) || (
SPICE_SERVER_VERSION<0xc06) #defineSPICE_NEEDS_SET_MM_TIME1
#else
#defineSPICE_NEEDS_SET_MM_TIME0
#endif
This looks better. I will fix up a patch.
Signature · 1 line
Pranith