]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix detection of supported warnings in clang 592/head
authorKen Raeburn <raeburn@mit.edu>
Sat, 7 Jan 2017 03:39:39 +0000 (22:39 -0500)
committerGreg Hudson <ghudson@mit.edu>
Mon, 9 Jan 2017 19:46:00 +0000 (14:46 -0500)
Without -Werror=unknown-warning-option, clang will warn for
unrecognized -W options like "-Werror=discarded-qualifiers" but won't
return a nonzero exit status, leading configure to think the options
are supported and thus include them during the build, leading to a
rather noisy log.

This option isn't needed during the build, though it won't hurt
anything either.  It is desirable during the testing of other -W
options for cleaner results, but the existing code tests each option
independently, requiring different handling for this option than for
other -W options.

src/aclocal.m4

index 510d9ba5196b394b017189d6cb2e0c7ac95b29e2..0a2df0e01647c9ce7a4e3193bc7a7f15900e9471 100644 (file)
@@ -450,13 +450,13 @@ krb5_ac_warn_cflags_set=${WARN_CFLAGS+set}
 krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set}
 ])
 dnl
-AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
+AC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl
   cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g`
   AC_CACHE_CHECK([if C compiler supports $1], [$cachevar],
   [# first try without, then with
   AC_TRY_COMPILE([], 1;,
     [old_cflags="$CFLAGS"
-     CFLAGS="$CFLAGS $1"
+     CFLAGS="$CFLAGS $cflags_warning_test_flags $1"
      AC_TRY_COMPILE([], 1;, eval $cachevar=yes, eval $cachevar=no)
      CFLAGS="$old_cflags"],
     [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
@@ -466,6 +466,21 @@ AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
   eval flag_supported='${'$cachevar'}'
 ])dnl
 dnl
+dnl Are additional flags needed to make unsupported warning options
+dnl get reported as errors?
+AC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl
+  cflags_warning_test_flags=
+  TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option)
+  if test $flag_supported = yes; then
+    cflags_warning_test_flags=-Werror=unknown-warning-option
+  fi
+])dnl
+dnl
+AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
+AC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl
+TRY_WARN_CC_FLAG_1($1)dnl
+])dnl
+dnl
 AC_DEFUN(WITH_CC,[dnl
 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
 AC_REQUIRE([AC_PROG_CC])dnl