Bug 1076698 - Part 2: Treat some individual gcc/clang warnings as errors in all directories. r=ted
--- a/configure.in
+++ b/configure.in
@@ -1411,34 +1411,60 @@ if test "$GNU_CC"; then
esac
fi
fi
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
+ # -Wchar-subscripts - catches array index using signed char
+ # -Wcomment - catches nested comments
# -Wdeclaration-after-statement - MSVC doesn't like these
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+ # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
+ # -Wenum-compare - catches comparison of different enum types
+ # -Wignored-qualifiers - catches returns types with qualifiers like const
+ # -Wimplicit-int - catches C variable declaration without a type
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
+ # -Wmultichar - catches multicharacter integer constants like 'THIS'
+ # -Wnonnull - catches NULL used with functions arguments marked as non-null
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
+ # -Wpointer-sign - catches mixing pointers to signed and unsigned types
+ # -Wpointer-to-int-cast - catches casts from pointer to different sized int
# -Wreturn-type - catches missing returns, zero false positives
+ # -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
+ # -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
+ # -Wunknown-pragmas - catches unexpected #pragma directives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wdeclaration-after-statement"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wempty-body"
- _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-arith"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-to-int-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wsign-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
# Treat some warnings as errors:
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=char-subscripts"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=comment"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=endif-labels"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=enum-compare"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=ignored-qualifiers"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=implicit-int"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=int-to-pointer-cast"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=multichar"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=nonnull"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-arith"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-sign"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=return-type"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=sequence-point"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=trigraphs"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=unknown-pragmas"
# Turn off the following warnings that -Wall turns on:
# -Wno-unused - lots of violations in third-party code
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
@@ -1484,32 +1510,46 @@ if test "$GNU_CXX"; then
# FIXME: Let us build with strict aliasing. bug 414641.
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+ # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
+ # -Wmissing-braces - catches aggregate initializers missing nested braces
# -Woverloaded-virtual - function declaration hides virtual function from base class
+ # -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
# -Wreturn-type - catches missing returns, zero false positives
+ # -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
+ # -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
+ # -Wunused-label - catches unused goto labels
+ # -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wpointer-arith"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wwrite-strings"
# Treat some warnings as errors:
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=type-limits"
# Turn off the following warnings that -Wall turns on:
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
# -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
# for performance reasons, and because GCC and clang accept it (though
# clang warns about it).
#
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -1163,34 +1163,72 @@ if test "$GNU_CC"; then
[NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
AC_MSG_RESULT([no])
LDFLAGS=$_SAVE_LDFLAGS)
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
+ # -Waddress - catches suspicious uses of memory addresses
+ # -Wchar-subscripts - catches array index using signed char
+ # -Wcomment - catches nested comments
# -Wdeclaration-after-statement - MSVC doesn't like these
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+ # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
+ # -Wenum-compare - catches comparison of different enum types
+ # -Wignored-qualifiers - catches returns types with qualifiers like const
+ # -Wimplicit-function-declaration - catches missing C function prototypes
+ # -Wimplicit-int - catches C variable declaration without a type
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
+ # -Wmissing-braces - catches aggregate initializers missing nested braces
+ # -Wmultichar - catches multicharacter integer constants like 'THIS'
+ # -Wnonnull - catches NULL used with functions arguments marked as non-null
+ # -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
+ # -Wpointer-sign - catches mixing pointers to signed and unsigned types
+ # -Wpointer-to-int-cast - catches casts from pointer to different sized int
# -Wreturn-type - catches missing returns, zero false positives
+ # -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
+ # -Wswitch - catches switches without all enum cases or default case
+ # -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
+ # -Wunknown-pragmas - catches unexpected #pragma directives
+ # -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wdeclaration-after-statement"
- _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wempty-body"
- _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-arith"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wsign-compare"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
# Treat some warnings as errors:
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=address"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=char-subscripts"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=comment"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=empty-body"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=endif-labels"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=enum-compare"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=ignored-qualifiers"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=implicit-function-declaration"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=implicit-int"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=int-to-pointer-cast"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=missing-braces"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=multichar"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=nonnull"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=parentheses"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-arith"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-sign"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-to-int-cast"
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=return-type"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=sequence-point"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=switch"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=trigraphs"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=unknown-pragmas"
+ _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=write-strings"
# Turn off the following warnings that -Wall turns on:
# -Wno-unused - lots of violations in third-party code
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
@@ -1231,37 +1269,66 @@ else
_DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT'
fi
if test "$GNU_CXX"; then
# Turn on gcc/clang warnings:
# https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
#
# -Wall - turn on a lot of warnings
+ # -Wchar-subscripts - catches array index using signed char
+ # -Wcomment - catches nested comments
# -Wconversion-null - catches conversions between NULL and non-pointer types
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+ # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
+ # -Wignored-qualifiers - catches returns types with qualifiers like const
# -Wint-to-pointer-cast - catches cast to pointer from integer of different size
+ # -Wmissing-braces - catches aggregate initializers missing nested braces
# -Woverloaded-virtual - function declaration hides virtual function from base class
+ # -Wparentheses - catches `if (a=b)` and operator precedence bugs
# -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
+ # -Wpointer-to-int-cast - catches casts from pointer to different sized int
+ # -Wreorder - catches ctor initializer list not matching class definition order
# -Wreturn-type - catches missing returns, zero false positives
+ # -Wsequence-point - catches undefined order behavior like `a = a++`
# -Wsign-compare - catches comparison of signed and unsigned types
+ # -Wswitch - catches switches without all enum cases or default case
+ # -Wtrigraphs - catches unlikely use of trigraphs
# -Wtype-limits - catches overflow bugs, few false positives
+ # -Wunknown-pragmas - catches unexpected #pragma directives
+ # -Wunused-label - catches unused goto labels
+ # -Wunused-value - catches unused expression results
+ # -Wwrite-strings - catches non-const char* pointers to string literals
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
- _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
- _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
- _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wpointer-arith"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wignored-qualifiers"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
# Treat some warnings as errors:
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=char-subscripts"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=comment"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=empty-body"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=overloaded-virtual"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=pointer-arith"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=reorder"
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
-
- MOZ_CXX_SUPPORTS_WARNING(-W, error=conversion-null, ac_cxx_has_werror_conversion_null)
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=switch"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unknown-pragmas"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-value"
+ _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=write-strings"
+
+ MOZ_CXX_SUPPORTS_WARNING(-Werror=, conversion-null, ac_cxx_has_werror_conversion_null)
# Turn off the following warnings that -Wall turns on:
# -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang