diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-06-27 00:45:39 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-06-27 00:45:39 +0000 |
commit | 04cc1e2fb5ded745000c90897ba73e8d11599cc1 (patch) | |
tree | d37e758f866026a18d154c30cddcc550313aa8e5 | |
parent | eaf5e3fd1f296131e22b72e8f9986c6b3e1dcc56 (diff) | |
download | wireshark-04cc1e2fb5ded745000c90897ba73e8d11599cc1.tar.gz wireshark-04cc1e2fb5ded745000c90897ba73e8d11599cc1.tar.bz2 wireshark-04cc1e2fb5ded745000c90897ba73e8d11599cc1.zip |
Don't assume that compilers not named "clang" will, by default, report
an error, or not issue warnings, by default if you give them an unknown
-f flag. Instead, test that flag with all compilers, and use -Werror to
force it to error out.
As with C/C++ flags, so with C++-only flags.
svn path=/trunk/; revision=50178
-rw-r--r-- | acinclude.m4 | 27 | ||||
-rw-r--r-- | configure.ac | 10 |
2 files changed, 24 insertions, 13 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index a3c47fce18..3bef361b1b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1650,13 +1650,27 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then if test "$2" != CXX ; then # # Not C++-only; if this can be added to the C compiler flags, add them. - # Add $ac_wireshark_unknown_warning_option_error to make sure that + # + # If the option begins with "-W", add + # $ac_wireshark_unknown_warning_option_error to make sure that # we'll get an error if it's an unknown warning option; not all # compilers treat unknown warning options as errors (I'm looking at # you, clang). # + # If the option begins with "-f", add -Werror to make sure that + # we'll get an error if we get "argument unused during compilation" + # warnings, as those will either cause a failure for files compiled + # with -Werror or annoying noise for files compiled without it. + # (Yeah, you, clang.) + # CFLAGS_saved="$CFLAGS" - CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION" + if expr "$GCC_OPTION" : "-W.*" >/dev/null + then + CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION" + elif expr "$GCC_OPTION" : "-f.*" >/dev/null + then + CFLAGS="$CFLAGS -Werror $GCC_OPTION" + fi AC_COMPILE_IFELSE([ AC_LANG_SOURCE([[ int foo; @@ -1729,9 +1743,12 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then # C++-only; if this can be added to the C++ compiler flags, add them. # CXXFLAGS_saved="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $GCC_OPTION" - if test "x$CC" = "xclang" ; then - CXXFLAGS="$CXXFLAGS -Werror=unknown-warning-option" + if expr "$GCC_OPTION" : "-W.*" >/dev/null + then + CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION" + elif expr "$GCC_OPTION" : "-f.*" >/dev/null + then + CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION" fi AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([ diff --git a/configure.ac b/configure.ac index f9883eb431..da7d663e32 100644 --- a/configure.ac +++ b/configure.ac @@ -643,15 +643,9 @@ bar(void) ## AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable) # -# Use the faster pre gcc 4.5 floating point precision if available; -# clang doesn't error out on -f options that it doesn't know about, -# it just warns and ignores them, so this check doesn't cause us -# to omit -fexcess-precision=fast, which produces a pile of -# annoying warnings. +# Use the faster pre gcc 4.5 floating point precision if available. # -if test "x$CC" != "xclang" ; then - AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast) -fi +AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast) CFLAGS_before_fvhidden=$CFLAGS AC_WIRESHARK_GCC_CFLAGS_CHECK(-fvisibility=hidden) |