From 7a64640413a306635ad94403b72d798e4aa527ee Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Wed, 3 Dec 2008 18:21:22 +0000 Subject: [PATCH] Move warning flags to new variables WARN_CFLAGS and WARN_CXXFLAGS, so that users can override the debugging and optimization flags independently of the warning flags. Remove -Wconversion from the standard set of warning flags since it warns excessively on perfectly good code, and is designed to aid in conversion of code from K&R to ANSI C rather than to maintain code quality. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21273 dc483132-0cff-0310-8789-dd5450dbe970 --- src/aclocal.m4 | 32 ++++++++++++++++++-------------- src/config/pre.in | 7 +++++-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index cd4ac9c1a..051f01f0d 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -562,9 +562,11 @@ AC_BEFORE([$0],[AC_PROG_CC]) AC_BEFORE([$0],[AC_PROG_CXX]) krb5_ac_cflags_set=${CFLAGS+set} krb5_ac_cxxflags_set=${CXXFLAGS+set} +krb5_ac_warn_cflags_set=${WARN_CFLAGS+set} +krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set} ]) dnl -AC_DEFUN(TRY_CC_FLAG,[dnl +AC_DEFUN(TRY_WARN_CC_FLAG,[dnl cachevar=`echo "krb5_cv_cc_flag_$1" | sed s/[[^a-zA-Z0-9_]]/_/g` AC_CACHE_CHECK([if C compiler supports $1], [$cachevar], [# first try without, then with @@ -575,7 +577,7 @@ AC_DEFUN(TRY_CC_FLAG,[dnl CFLAGS="$old_cflags"], [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])]) if eval test '"${'$cachevar'}"' = yes; then - CFLAGS="$CFLAGS $1" + WARN_CFLAGS="$WARN_CFLAGS $1" fi eval flag_supported='${'$cachevar'}' ])dnl @@ -606,7 +608,7 @@ if test "$withval" = yes; then AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage]) fi # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc. -extra_gcc_warn_opts="-Wall -Wcast-qual -Wcast-align -Wconversion -Wshadow" +extra_gcc_warn_opts="-Wall -Wcast-qual -Wcast-align -Wshadow" # -Wmissing-prototypes if test "$GCC" = yes ; then # Putting this here means we get -Os after -O2, which works. @@ -618,32 +620,32 @@ if test "$GCC" = yes ; then *) CFLAGS="$CFLAGS -Os" ;; esac fi - if test "x$krb5_ac_cflags_set" = xset ; then - AC_MSG_NOTICE(not adding extra gcc warning flags because CFLAGS was set) + if test "x$krb5_ac_warn_cflags_set" = xset ; then + AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set) else AC_MSG_NOTICE(adding extra warning flags for gcc) - CFLAGS="$CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes" + WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes" if test "`uname -s`" = Darwin ; then AC_MSG_NOTICE(skipping pedantic warnings on Darwin) elif test "`uname -s`" = Linux ; then AC_MSG_NOTICE(skipping pedantic warnings on Linux) else - CFLAGS="$CFLAGS -pedantic" + WARN_CFLAGS="$WARN_CFLAGS -pedantic" fi if test "$ac_cv_cxx_compiler_gnu" = yes; then - if test "x$krb5_ac_cxxflags_set" = xset ; then - AC_MSG_NOTICE(not adding extra g++ warnings because CXXFLAGS was set) + if test "x$krb5_ac_warn_cxxflags_set" = xset ; then + AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set) else AC_MSG_NOTICE(adding extra warning flags for g++) - CXXFLAGS="$CXXFLAGS $extra_gcc_warn_opts" + WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts" fi fi # Currently, G++ does not support -Wno-format-zero-length. - TRY_CC_FLAG(-Wno-format-zero-length) + TRY_WARN_CC_FLAG(-Wno-format-zero-length) # Other flags here may not be supported on some versions of # gcc that people want to use. for flag in overflow strict-overflow missing-format-attribute missing-prototypes return-type missing-braces parentheses switch unused-function unused-label unused-variable unused-value unknown-pragmas sign-compare newline-eof ; do - TRY_CC_FLAG(-W$flag) + TRY_WARN_CC_FLAG(-W$flag) done # old-style-definition? generates many, many warnings # @@ -659,9 +661,9 @@ if test "$GCC" = yes ; then # We're currently targeting C89+, not C99, so disallow some # constructs. for flag in declaration-after-statement variadic-macros ; do - TRY_CC_FLAG(-Werror=$flag) + TRY_WARN_CC_FLAG(-Werror=$flag) if test "$flag_supported" = no; then - TRY_CC_FLAG(-W$flag) + TRY_WARN_CC_FLAG(-W$flag) fi done # missing-prototypes? maybe someday @@ -713,6 +715,8 @@ else esac fi fi +AC_SUBST(WARN_CFLAGS) +AC_SUBST(WARN_CXXFLAGS) ])dnl dnl dnl diff --git a/src/config/pre.in b/src/config/pre.in index c4a5722a3..eee077540 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -152,17 +152,20 @@ FAKELIBDIR=$(FAKEPREFIX)/lib # LOCALINCLUDES set by local Makefile.in # CPPFLAGS user override # CFLAGS user override but starts off set by configure +# WARN_CFLAGS user override but starts off set by configure # PTHREAD_CFLAGS set by configure, not included in CFLAGS so that we # don't pull the pthreads library into shared libraries ALL_CFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \ -DKRB5_DEPRECATED=1 \ - $(CPPFLAGS) $(CFLAGS) $(PTHREAD_CFLAGS) + $(CPPFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(PTHREAD_CFLAGS) ALL_CXXFLAGS = $(DEFS) $(DEFINES) $(KRB_INCLUDES) $(LOCALINCLUDES) \ -DKRB5_DEPRECATED=1 \ - $(CPPFLAGS) $(CXXFLAGS) $(PTHREAD_CFLAGS) + $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(PTHREAD_CFLAGS) CFLAGS = @CFLAGS@ CXXFLAGS = @CXXFLAGS@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ THREAD_LINKOPTS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) -- 2.26.2