Disable -Wuninitialized for gcc

If the compiler is gcc, disable variants of -Wuninitialized depending
on the gcc version.  This gets a lot of false positive warnings out of
the build.

Generate a new configure for the gcc -Wno-uninitialized fix.

Pick up -Wno-uninitialized from configure

Add the option -Wno[-maybe]-uninitialized as determined by configure.

llvm-svn: 172006
This commit is contained in:
David Greene 2013-01-09 22:11:13 +00:00
parent 63710d3c5e
commit 981d358618
4 changed files with 53 additions and 8 deletions

View File

@ -358,6 +358,10 @@ NO_MISSING_FIELD_INITIALIZERS = @NO_MISSING_FIELD_INITIALIZERS@
NO_VARIADIC_MACROS = @NO_VARIADIC_MACROS@
# -Wcovered-switch-default
COVERED_SWITCH_DEFAULT = @COVERED_SWITCH_DEFAULT@
# -Wno-uninitialized
NO_UNINITIALIZED = @NO_UNINITIALIZED@
# -Wno-maybe-uninitialized
NO_MAYBE_UNINITIALIZED = @NO_MAYBE_UNINITIALIZED@
# Was polly found in tools/polly?
LLVM_HAS_POLLY = @LLVM_HAS_POLLY@

View File

@ -668,7 +668,8 @@ ifndef NO_PEDANTIC
CompileCommonOpts += -pedantic -Wno-long-long
endif
CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
$(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT)
$(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
$(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED)
# Enable cast-qual for C++; the workaround is to use const_cast.
CXX.Flags += -Wcast-qual

View File

@ -1257,7 +1257,27 @@ AC_MSG_CHECKING([optional compiler flags])
CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT])
dnl GCC's potential uninitialized use analysis is weak and presents lots of
dnl false positives, so disable it.
if test "$GXX" = "yes"
then
CXX_FLAG_CHECK(NO_MAYBE_UNINITIALIZED, [-Wno-maybe-uninitialized])
dnl gcc 4.7 introduced -Wmaybe-uninitialized to distinguish cases which are
dnl known to be uninitialized from cases which might be uninitialized. We
dnl still want to catch the first kind of errors.
if test "$NO_MAYBE_UNINITIALIZED" != "-Wno-maybe-uninitialized"
then
CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
else
dnl AC_SUBST doesn't work with empty strings.
NO_UNINITIALIZED=
fi
else
NO_UNINITIALIZED=
NO_MAYBE_UNINITIALIZED=
fi
AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED])
dnl===-----------------------------------------------------------------------===
dnl===

32
configure vendored
View File

@ -767,6 +767,8 @@ LIBADD_DL
NO_VARIADIC_MACROS
NO_MISSING_FIELD_INITIALIZERS
COVERED_SWITCH_DEFAULT
NO_MAYBE_UNINITIALIZED
NO_UNINITIALIZED
USE_UDIS86
USE_OPROFILE
USE_INTEL_JITEVENTS
@ -10485,7 +10487,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10488 "configure"
#line 10490 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12246,8 +12248,24 @@ NO_MISSING_FIELD_INITIALIZERS=`$CXX -Werror -Wno-missing-field-initializers -fsy
COVERED_SWITCH_DEFAULT=`$CXX -Werror -Wcovered-switch-default -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wcovered-switch-default`
{ echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT" >&5
echo "${ECHO_T}$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT" >&6; }
if test "$GXX" = "yes"
then
NO_MAYBE_UNINITIALIZED=`$CXX -Werror -Wno-maybe-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-maybe-uninitialized`
if test "$NO_MAYBE_UNINITIALIZED" != "-Wno-maybe-uninitialized"
then
NO_UNINITIALIZED=`$CXX -Werror -Wno-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-uninitialized`
else
NO_UNINITIALIZED=
fi
else
NO_UNINITIALIZED=
NO_MAYBE_UNINITIALIZED=
fi
{ echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED" >&5
echo "${ECHO_T}$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED" >&6; }
@ -22303,6 +22321,8 @@ LIBADD_DL!$LIBADD_DL$ac_delim
NO_VARIADIC_MACROS!$NO_VARIADIC_MACROS$ac_delim
NO_MISSING_FIELD_INITIALIZERS!$NO_MISSING_FIELD_INITIALIZERS$ac_delim
COVERED_SWITCH_DEFAULT!$COVERED_SWITCH_DEFAULT$ac_delim
NO_MAYBE_UNINITIALIZED!$NO_MAYBE_UNINITIALIZED$ac_delim
NO_UNINITIALIZED!$NO_UNINITIALIZED$ac_delim
USE_UDIS86!$USE_UDIS86$ac_delim
USE_OPROFILE!$USE_OPROFILE$ac_delim
USE_INTEL_JITEVENTS!$USE_INTEL_JITEVENTS$ac_delim
@ -22330,8 +22350,6 @@ OCAML_LIBDIR!$OCAML_LIBDIR$ac_delim
ENABLE_VISIBILITY_INLINES_HIDDEN!$ENABLE_VISIBILITY_INLINES_HIDDEN$ac_delim
RPATH!$RPATH$ac_delim
RDYNAMIC!$RDYNAMIC$ac_delim
program_prefix!$program_prefix$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@ -22373,10 +22391,12 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
program_prefix!$program_prefix$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 1; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 3; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5