summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-12-09 02:52:33 +0000
committerGuy Harris <guy@alum.mit.edu>2012-12-09 02:52:33 +0000
commitb961881fb35d6d678daeb82fdf51e625b90c206b (patch)
tree15ee61537fcbbb442c08a228cafd2fdc45871769 /acinclude.m4
parentea47ca37b1aca1b6da320597379178a21f8bc388 (diff)
downloadwireshark-b961881fb35d6d678daeb82fdf51e625b90c206b.tar.gz
Add some additional arguments to AC_WIRESHARK_GCC_CFLAGS_CHECK() to make
it do an additional check, if it finds that a given compiler option is supported by the compiler, to see whether it's supported but undesirable. The arguments are a chunk of code to try to compile with -Werror, and a string to be used in the "checking..." message printed when trying to compile the cunk of code. Try enabling -Wshadow again, but have it check whether extern int atoi(char *p); int foo(char *p) { int (*fptr)(char *p) = atoi; return fptr(p) * 2; } compiles with -Wshadow and -Werror, so that we don't use -Wshadow with compilers that complain about that; some older versions of GCC complain about that, and it's really not worth our effort to eliminate or rename arguments in function prototypes to make -Wshadow work even with those compilers. svn path=/trunk/; revision=46475
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m485
1 files changed, 77 insertions, 8 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index c81f2ebd9f..a17c7a1328 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1578,6 +1578,13 @@ fi
#
# $1 : cflags to test
# $2 : if supplied, C for C-only flags, CXX for C++-only flags
+# $3 : if supplied, a program to try to compile with the flag
+# and, if the compile fails when -Werror is turned on,
+# we don't add the flag - used for warning flags that
+# issue incorrect or non-useful warnings with some
+# compiler versions
+# $4 : must be supplied if $3 is supplied - a message describing
+# for what the test program is testing
#
# The macro first determines if the compiler supports GCC-style flags.
# Then it attempts to compile with the defined cflags. The defined
@@ -1630,16 +1637,47 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
[
AC_MSG_RESULT(yes)
#
- # Remove -Werror=unknown-warning-option, if we
- # added it, by setting CFLAGS to the saved value
- # plus just the new option.
- #
- CFLAGS="$CFLAGS_saved $GCC_OPTION"
- if test "$2" != C ; then
+ # OK, do we have a test program? If so, check
+ # whether it fails with this option and -Werror,
+ # and, if so, don't include it.
+ #
+ if test "x$3" != "x" ; then
+ CFLAGS="$CFLAGS -Werror"
+ AC_MSG_CHECKING(whether $GCC_OPTION $4)
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE($3)],
+ [
+ AC_MSG_RESULT(no)
+ #
+ # Remove -Werror=unknown-warning-option, if we
+ # added it, and -Werror by setting CFLAGS to
+ # the saved value plus just the new option.
+ #
+ CFLAGS="$CFLAGS_saved $GCC_OPTION"
+ if test "$2" != C ; then
+ #
+ # Add it to the C++ flags as well.
+ #
+ CXXFLAGS="$CXXFLAGS $GCC_OPTION"
+ fi
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ CFLAGS="$CFLAGS_saved"
+ ])
+ else
#
- # Add it to the C++ flags as well.
+ # Remove -Werror=unknown-warning-option, if we
+ # added it, and -Werror by setting CFLAGS to
+ # the saved value plus just the new option.
#
- CXXFLAGS="$CXXFLAGS $GCC_OPTION"
+ CFLAGS="$CFLAGS_saved $GCC_OPTION"
+ if test "$2" != C ; then
+ #
+ # Add it to the C++ flags as well.
+ #
+ CXXFLAGS="$CXXFLAGS $GCC_OPTION"
+ fi
fi
],
[
@@ -1662,6 +1700,37 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
]])],
[
AC_MSG_RESULT(yes)
+ #
+ # OK, do we have a test program? If so, check
+ # whether it fails with this option and -Werror,
+ # and, if so, don't include it.
+ #
+ if test "x$3" != "x" ; then
+ CXXFLAGS="$CXXFLAGS -Werror"
+ AC_MSG_CHECKING(whether $GCC_OPTION $4)
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE($3)],
+ [
+ AC_MSG_RESULT(no)
+ #
+ # Remove -Werror=unknown-warning-option, if we
+ # added it, and -Werror by setting CXXFLAGS to
+ # the saved value plus just the new option.
+ #
+ CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ CXXFLAGS="$CXXFLAGS_saved"
+ ])
+ else
+ #
+ # Remove -Werror=unknown-warning-option, if we
+ # added it, and -Werror by setting CXXFLAGS to
+ # the saved value plus just the new option.
+ #
+ CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
+ fi
],
[
AC_MSG_RESULT(no)