aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2013-01-09 22:11:13 +0000
committerDavid Greene <greened@obbligato.org>2013-01-09 22:11:13 +0000
commitd2f8216ba496b139815aee29052093c1b0d7a996 (patch)
treec67b0c125cbb888ca8dfc850f03512200603e4ea
parent78ec0255d9ab184af7799c14d93879e5f21b9007 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172006 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Makefile.config.in4
-rw-r--r--Makefile.rules3
-rw-r--r--autoconf/configure.ac22
-rwxr-xr-xconfigure32
4 files changed, 53 insertions, 8 deletions
diff --git a/Makefile.config.in b/Makefile.config.in
index 3c4f7b7a32..5cb3c58673 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -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@
diff --git a/Makefile.rules b/Makefile.rules
index c64275f11e..59bab8fcff 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -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
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index a1426c1832..c186ed5574 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -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===
diff --git a/configure b/configure
index 3ca2df90ab..95bf6107e3 100755
--- a/configure
+++ b/configure
@@ -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