Disable Uninitialized Use Warnings for Broken gcc Versions
authorDavid Greene <greened@obbligato.org>
Tue, 15 Jan 2013 18:21:15 +0000 (18:21 +0000)
committerDavid Greene <greened@obbligato.org>
Tue, 15 Jan 2013 18:21:15 +0000 (18:21 +0000)
Some versions of gcc accept unsupported -W flags and run just fine if
there are no warnings, but die with an unsupported flag error if a
warning is encountered.  gcc 4.3 and gcc 4.4 both exhibit this
behavior for -Wno-maybe-uninitialized.  Therefore, if the flag check
for -Wno-maybe-uninitialized succeeds, only use
-Wno-maybe-uninitialized if we are using gcc version 4.7 or greater.
Use -Wno-uninitialized otherwise.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172543 91177308-0d34-0410-b5e6-96231b3b80d8

autoconf/configure.ac
configure

index c186ed55744c64e3b29577978e119f7e8f9cf6d0..ce360109d2efffdab4294c70b1b8eb0638cf7e42 100644 (file)
@@ -1269,8 +1269,23 @@ then
   then
     CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
   else
-    dnl AC_SUBST doesn't work with empty strings.
-    NO_UNINITIALIZED=
+    dnl Some versions of gcc accept unsupported -W flags if there is
+    dnl no warning but stop with an error when a warning is
+    dnl encountered.  If this gcc is earlier than 4.7, just use
+    dnl -Wno-uninitialized.
+    gxx_version=`$CXX -dumpversion`
+    gxx_version_major=`echo $gxx_version | cut -d'.' -f1`
+    gxx_version_minor=`echo $gxx_version | cut -d'.' -f2`
+    gxx_version_patch=`echo $gxx_version | cut -d'.' -f3`
+
+    if    test "$gxx_version_major" -ge "4" \
+       && test "$gxx_version_minor" -ge "7"; then
+      dnl AC_SUBST doesn't work with empty strings.
+      NO_UNINITIALIZED=
+    else
+      NO_MAYBE_UNINITIALIZED=
+      CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
+    fi
   fi
 else
   NO_UNINITIALIZED=
index 95bf6107e3b67c2b0b967b09b26f9b54ceb0b23e..d4687590183c50d3a907be42b9ace2cc3c67f51f 100755 (executable)
--- a/configure
+++ b/configure
@@ -12257,7 +12257,19 @@ then
     NO_UNINITIALIZED=`$CXX -Werror -Wno-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-uninitialized`
 
   else
-        NO_UNINITIALIZED=
+                    gxx_version=`$CXX -dumpversion`
+    gxx_version_major=`echo $gxx_version | cut -d'.' -f1`
+    gxx_version_minor=`echo $gxx_version | cut -d'.' -f2`
+    gxx_version_patch=`echo $gxx_version | cut -d'.' -f3`
+
+    if    test "$gxx_version_major" -ge "4" \
+       && test "$gxx_version_minor" -ge "7"; then
+            NO_UNINITIALIZED=
+    else
+      NO_MAYBE_UNINITIALIZED=
+      NO_UNINITIALIZED=`$CXX -Werror -Wno-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-uninitialized`
+
+    fi
   fi
 else
   NO_UNINITIALIZED=