llvm.org GIT mirror llvm / 9097e5d
We're actually -Wmissing-field-initializers clean thanks to the cmake build so check and turn on -Wmissing-field-initializers. While there, reorganize the conditional warning code based on compiler to be a bit more obvious and inside a switch statement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244330 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 4 years ago
4 changed file(s) with 60 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
395395 BINUTILS_INCDIR := @BINUTILS_INCDIR@
396396
397397 # Optional flags supported by the compiler
398 # -Wno-missing-field-initializers
399 NO_MISSING_FIELD_INITIALIZERS = @NO_MISSING_FIELD_INITIALIZERS@
398 # -Wmissing-field-initializers
399 MISSING_FIELD_INITIALIZERS = @MISSING_FIELD_INITIALIZERS@
400400 # -Wno-variadic-macros
401401 NO_VARIADIC_MACROS = @NO_VARIADIC_MACROS@
402402 # -Wcovered-switch-default
685685 CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \
686686 $(EXTRA_OPTIONS) $(COVERED_SWITCH_DEFAULT) \
687687 $(NO_UNINITIALIZED) $(NO_MAYBE_UNINITIALIZED) \
688 $(NO_MISSING_FIELD_INITIALIZERS) $(NO_COMMENT)
688 $(MISSING_FIELD_INITIALIZERS) $(NO_COMMENT)
689689 # Enable cast-qual for C++; the workaround is to use const_cast.
690690 CXX.Flags += -Wcast-qual
691691
15471547
15481548 dnl Check optional compiler flags.
15491549 AC_MSG_CHECKING([optional compiler flags])
1550 CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
1551 CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
1552 CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
1553
1554 dnl GCC's potential uninitialized use analysis is weak and presents lots of
1555 dnl false positives, so disable it.
1556 NO_UNINITIALIZED=
1557 NO_MAYBE_UNINITIALIZED=
1558 if test "$GXX" = "yes"
1559 then
1560 CXX_FLAG_CHECK(NO_MAYBE_UNINITIALIZED, [-Wno-maybe-uninitialized])
1561 dnl gcc 4.7 introduced -Wmaybe-uninitialized to distinguish cases which are
1562 dnl known to be uninitialized from cases which might be uninitialized. We
1563 dnl still want to catch the first kind of errors.
1564 if test -z "$NO_MAYBE_UNINITIALIZED"
1565 then
1566 CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
1567 fi
1568 fi
1550 case "$llvm_cv_cxx_compiler" in
1551 clang)
1552 CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
1553 CXX_FLAG_CHECK(MISSING_FIELD_INITIALIZERS, [-Wmissing-field-initializers])
1554 CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
1555 ;;
1556 gcc)
1557 dnl If we're using gcc check for -Wno-missing-field-initializers as gcc will warn
1558 dnl on plain open brace initializations. clang won't so use -Wmissing-field-initializers
1559 dnl there.
1560 CXX_FLAG_CHECK(MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
1561 CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
1562 CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
1563 CXX_FLAG_CHECK(NO_MAYBE_UNINITIALIZED, [-Wno-maybe-uninitialized])
1564 dnl gcc 4.7 introduced -Wmaybe-uninitialized to distinguish cases which are
1565 dnl known to be uninitialized from cases which might be uninitialized. We
1566 dnl still want to catch the first kind of errors.
1567 if test -z "$NO_MAYBE_UNINITIALIZED"
1568 then
1569 CXX_FLAG_CHECK(NO_UNINITIALIZED, [-Wno-uninitialized])
1570 fi
1571 ;;
1572 unknown)
1573 ;;
1574 esac
15691575
15701576 dnl Check for misbehaving -Wcomment (gcc-4.7 has this) and maybe add
15711577 dnl -Wno-comment to the flags.
15861592 AC_SUBST(NO_COMMENT, [$no_comment])
15871593 CXXFLAGS="$llvm_cv_old_cxxflags"
15881594
1589 AC_MSG_RESULT([$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT])
1595 AC_MSG_RESULT([$NO_VARIADIC_MACROS $MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT])
15901596
15911597 AC_ARG_WITH([python],
15921598 [AS_HELP_STRING([--with-python], [path to python])],
776776 HAVE_LINK_VERSION_SCRIPT
777777 EGREP
778778 NO_VARIADIC_MACROS
779 NO_MISSING_FIELD_INITIALIZERS
779 MISSING_FIELD_INITIALIZERS
780780 COVERED_SWITCH_DEFAULT
781781 NO_MAYBE_UNINITIALIZED
782782 NO_UNINITIALIZED
83788378
83798379 { echo "$as_me:$LINENO: checking optional compiler flags" >&5
83808380 echo $ECHO_N "checking optional compiler flags... $ECHO_C" >&6; }
8381 NO_VARIADIC_MACROS=`$CXX -Werror -Wvariadic-macros -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-variadic-macros`
8382
8383 NO_MISSING_FIELD_INITIALIZERS=`$CXX -Werror -Wmissing-field-initializers -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-missing-field-initializers`
8384
8385 COVERED_SWITCH_DEFAULT=`$CXX -Werror -Wcovered-switch-default -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wcovered-switch-default`
8386
8387
8388 NO_UNINITIALIZED=
8389 NO_MAYBE_UNINITIALIZED=
8390 if test "$GXX" = "yes"
8391 then
8392 NO_MAYBE_UNINITIALIZED=`$CXX -Werror -Wmaybe-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-maybe-uninitialized`
8393
8394 if test -z "$NO_MAYBE_UNINITIALIZED"
8395 then
8396 NO_UNINITIALIZED=`$CXX -Werror -Wuninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-uninitialized`
8397
8398 fi
8399 fi
8381 case "$llvm_cv_cxx_compiler" in
8382 clang)
8383 NO_VARIADIC_MACROS=`$CXX -Werror -Wvariadic-macros -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-variadic-macros`
8384
8385 MISSING_FIELD_INITIALIZERS=`$CXX -Werror -Wmissing-field-initializers -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wmissing-field-initializers`
8386
8387 COVERED_SWITCH_DEFAULT=`$CXX -Werror -Wcovered-switch-default -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wcovered-switch-default`
8388
8389 ;;
8390 gcc)
8391 MISSING_FIELD_INITIALIZERS=`$CXX -Werror -Wmissing-field-initializers -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-missing-field-initializers`
8392
8393 NO_VARIADIC_MACROS=`$CXX -Werror -Wvariadic-macros -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-variadic-macros`
8394
8395 COVERED_SWITCH_DEFAULT=`$CXX -Werror -Wcovered-switch-default -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wcovered-switch-default`
8396
8397 NO_MAYBE_UNINITIALIZED=`$CXX -Werror -Wmaybe-uninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-maybe-uninitialized`
8398
8399 if test -z "$NO_MAYBE_UNINITIALIZED"
8400 then
8401 NO_UNINITIALIZED=`$CXX -Werror -Wuninitialized -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wno-uninitialized`
8402
8403 fi
8404 ;;
8405 unknown)
8406 ;;
8407 esac
84008408
84018409 no_comment=
84028410 llvm_cv_old_cxxflags="$CXXFLAGS"
84638471
84648472 CXXFLAGS="$llvm_cv_old_cxxflags"
84658473
8466 { echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&5
8467 echo "${ECHO_T}$NO_VARIADIC_MACROS $NO_MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&6; }
8474 { echo "$as_me:$LINENO: result: $NO_VARIADIC_MACROS $MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&5
8475 echo "${ECHO_T}$NO_VARIADIC_MACROS $MISSING_FIELD_INITIALIZERS $COVERED_SWITCH_DEFAULT $NO_UNINITIALIZED $NO_MAYBE_UNINITIALIZED $NO_COMMENT" >&6; }
84688476
84698477
84708478 # Check whether --with-python was given.
1865218660 HAVE_LINK_VERSION_SCRIPT!$HAVE_LINK_VERSION_SCRIPT$ac_delim
1865318661 EGREP!$EGREP$ac_delim
1865418662 NO_VARIADIC_MACROS!$NO_VARIADIC_MACROS$ac_delim
18655 NO_MISSING_FIELD_INITIALIZERS!$NO_MISSING_FIELD_INITIALIZERS$ac_delim
18663 MISSING_FIELD_INITIALIZERS!$MISSING_FIELD_INITIALIZERS$ac_delim
1865618664 COVERED_SWITCH_DEFAULT!$COVERED_SWITCH_DEFAULT$ac_delim
1865718665 NO_MAYBE_UNINITIALIZED!$NO_MAYBE_UNINITIALIZED$ac_delim
1865818666 NO_UNINITIALIZED!$NO_UNINITIALIZED$ac_delim