Bug 711895 - Tweak the warning options used for GCC builds. r=waldo, derf.

--HG--
extra : rebase_source : bbe982c5feceac25fb4c0ccd03ced3a874205c38
This commit is contained in:
Nicholas Nethercote 2011-12-28 19:59:19 -08:00
parent 23223c0145
commit cc36bb0b51
12 changed files with 196 additions and 41 deletions

View File

@ -1864,15 +1864,20 @@ if test "$GNU_CC"; then
_MOZ_RTTI_FLAGS_ON=-frtti
_MOZ_RTTI_FLAGS_OFF=-fno-rtti
# Turn on GNU specific features
# -Wall - turn on all warnings
# -pedantic - make compiler warn about non-ANSI stuff, and
# be a little bit stricter
# -Wdeclaration-after-statement - MSVC doesn't like these
# Warnings slamm took out for now (these were giving more noise than help):
# -Wbad-function-cast - warns when casting a function to a new return type
# -Wshadow - removed because it generates more noise than help --pete
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Werror=declaration-after-statement - MSVC doesn't like these
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement -Wempty-body"
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Woverlength-strings - we exceed the minimum maximum length all the time
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-overlength-strings"
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1888,12 +1893,26 @@ if test "$GNU_CC"; then
dnl Turn pedantic on but disable the warnings for long long
_PEDANTIC=1
if test -z "$INTEL_CC"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
fi
_DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
ac_cc_has_wtype_limits,
[
AC_LANG_SAVE
AC_LANG_C
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wtype-limits"
AC_TRY_COMPILE([],
[return(0);],
ac_cc_has_wtype_limits="yes",
ac_cc_has_wtype_limits="no")
CFLAGS="$_SAVE_CFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cc_has_wtype_limits" = "yes"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
fi
elif test "$SOLARIS_SUNPRO_CC"; then
DSO_CFLAGS=''
if test "$CPU_ARCH" = "sparc"; then
@ -1921,8 +1940,22 @@ fi
if test "$GNU_CXX"; then
# FIXME: Let us build with strict aliasing. bug 414641.
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
# Turn on GNU specific features
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Woverloaded-virtual - ???
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wempty-body"
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Woverlength-strings - we exceed the minimum maximum length all the time
# -Wctor-dtor-privacy - ???
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-overlength-strings -Wno-ctor-dtor-privacy"
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -2023,6 +2056,24 @@ if test "$GNU_CXX"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
fi
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
ac_has_wtype_limits,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wtype-limits"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wtype_limits="yes",
ac_has_wtype_limits="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wtype_limits" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
fi
else
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
fi

View File

@ -102,8 +102,7 @@ protected:
const txExpandedName key()
{
NS_ASSERTION(mCurrentPos >= 0 &&
mCurrentPos < mMap.mItems.Length(),
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
"invalid position in txExpandedNameMap::iterator");
return txExpandedName(mMap.mItems[mCurrentPos].mNamespaceID,
mMap.mItems[mCurrentPos].mLocalName);
@ -112,8 +111,7 @@ protected:
protected:
void* itemValue()
{
NS_ASSERTION(mCurrentPos >= 0 &&
mCurrentPos < mMap.mItems.Length(),
NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
"invalid position in txExpandedNameMap::iterator");
return mMap.mItems[mCurrentPos].mValue;
}

View File

@ -0,0 +1,40 @@
diff --git a/gfx/ycbcr/yuv_convert.cpp b/gfx/ycbcr/yuv_convert.cpp
--- a/gfx/ycbcr/yuv_convert.cpp
+++ b/gfx/ycbcr/yuv_convert.cpp
@@ -337,16 +337,17 @@ NS_GFX_(void) ScaleYCbCrToRGB32(const ui
source_dx_uv >> kFractionBits);
}
}
else {
ScaleYUVToRGB32Row_C(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
}
#else
+ (void)source_dx_uv;
ScaleYUVToRGB32Row(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
#endif
}
}
// MMX used for FastConvertYUVToRGB32Row and FilterRows requires emms.
if (has_mmx)
EMMS();
diff --git a/gfx/ycbcr/yuv_row.h b/gfx/ycbcr/yuv_row.h
--- a/gfx/ycbcr/yuv_row.h
+++ b/gfx/ycbcr/yuv_row.h
@@ -129,14 +129,14 @@ extern SIMD_ALIGNED(int16 kCoefficientsR
#if defined(ARCH_CPU_X86) && !defined(ARCH_CPU_X86_64)
#if defined(_MSC_VER)
#define EMMS() __asm emms
#pragma warning(disable: 4799)
#else
#define EMMS() asm("emms")
#endif
#else
-#define EMMS()
+#define EMMS() ((void)0)
#endif
} // extern "C"
#endif // MEDIA_BASE_YUV_ROW_H_

View File

@ -25,3 +25,5 @@ convert.patch contains the following changes:
win64.patch: SSE2 optimization for Microsoft Visual C++ x64 version
TypeFromSize.patch: Bug 656185 - Add a method to detect YUVType from plane sizes.
QuellGccWarnings.patch: Bug 711895 - Avoid some GCC compilation warnings.

View File

@ -9,3 +9,4 @@ cp $1/media/base/yuv_row_posix.cc yuv_row_c.cpp
patch -p3 <convert.patch
patch -p3 <win64.patch
patch -p3 <TypeFromSize.patch
patch -p3 <QuellGccWarnings.patch

View File

@ -342,6 +342,7 @@ NS_GFX_(void) ScaleYCbCrToRGB32(const uint8* y_buf,
dest_pixel, width, source_dx);
}
#else
(void)source_dx_uv;
ScaleYUVToRGB32Row(y_ptr, u_ptr, v_ptr,
dest_pixel, width, source_dx);
#endif

View File

@ -134,7 +134,7 @@ extern SIMD_ALIGNED(int16 kCoefficientsRgbY[768][4]);
#define EMMS() asm("emms")
#endif
#else
#define EMMS()
#define EMMS() ((void)0)
#endif
} // extern "C"

View File

@ -1806,14 +1806,20 @@ if test "$GNU_CC"; then
_MOZ_RTTI_FLAGS_ON=-frtti
_MOZ_RTTI_FLAGS_OFF=-fno-rtti
# Turn on GNU specific features
# -Wall - turn on all warnings
# -pedantic - make compiler warn about non-ANSI stuff, and
# be a little bit stricter
# Warnings slamm took out for now (these were giving more noise than help):
# -Wbad-function-cast - warns when casting a function to a new return type
# -Wshadow - removed because it generates more noise than help --pete
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Wdeclaration-after-statement - MSVC doesn't like these
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement -Wempty-body"
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Woverlength-strings - we exceed the minimum maximum length all the time
#
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-overlength-strings"
if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1829,12 +1835,26 @@ if test "$GNU_CC"; then
dnl Turn pedantic on but disable the warnings for long long
_PEDANTIC=1
if test -z "$INTEL_CC"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
fi
_DEFINES_CFLAGS='-include $(DEPTH)/js-confdefs.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
ac_cc_has_wtype_limits,
[
AC_LANG_SAVE
AC_LANG_C
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wtype-limits"
AC_TRY_COMPILE([],
[return(0);],
ac_cc_has_wtype_limits="yes",
ac_cc_has_wtype_limits="no")
CFLAGS="$_SAVE_CFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cc_has_wtype_limits" = "yes"; then
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
fi
elif test "$SOLARIS_SUNPRO_CC"; then
DSO_CFLAGS=''
if test "$CPU_ARCH" = "sparc"; then
@ -1860,8 +1880,21 @@ else
fi
if test "$GNU_CXX"; then
# Turn on GNU specific features
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
# Turn on GNU-specific warnings:
# -Wall - turn on a lot of warnings
# -pedantic - this is turned on below
# -Wpointer-arith - enabled with -pedantic, but good to have even if not
# -Woverloaded-virtual - ???
# -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wempty-body"
# Turn off the following warnings that -Wall/-pedantic turn on:
# -Woverlength-strings - we exceed the minimum maximum length all the time
# -Wctor-dtor-privacy - ???
#
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-overlength-strings -Wno-ctor-dtor-privacy"
if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
# Don't use -Wcast-align with ICC or clang
case "$CPU_ARCH" in
@ -1962,6 +1995,24 @@ if test "$GNU_CXX"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
fi
AC_CACHE_CHECK(whether the compiler supports -Wtype-limits,
ac_has_wtype_limits,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wtype-limits"
AC_TRY_COMPILE([],
[return(0);],
ac_has_wtype_limits="yes",
ac_has_wtype_limits="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_has_wtype_limits" = "yes"; then
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wtype-limits"
fi
else
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_JS_CONFDEFS_H_ $(ACDEFINES)'
fi

View File

@ -404,11 +404,24 @@ DoGetElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *hole, Value *
return true;
}
template<typename IndexType>
static void
AssertGreaterThanZero(IndexType index)
{
JS_ASSERT(index >= 0);
}
template<>
void
AssertGreaterThanZero(jsuint index)
{
}
template<typename IndexType>
static JSBool
GetElement(JSContext *cx, JSObject *obj, IndexType index, JSBool *hole, Value *vp)
{
JS_ASSERT(index >= 0);
AssertGreaterThanZero(index);
if (obj->isDenseArray() && index < obj->getDenseArrayInitializedLength() &&
!(*vp = obj->getDenseArrayElement(uint32_t(index))).isMagic(JS_ARRAY_HOLE)) {
*hole = JS_FALSE;

View File

@ -1342,7 +1342,7 @@ JSRuntime::setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind)
void
JSRuntime::reduceGCTriggerBytes(uint32_t amount) {
JS_ASSERT(amount > 0);
JS_ASSERT(gcTriggerBytes - amount >= 0);
JS_ASSERT(gcTriggerBytes >= amount);
if (gcTriggerBytes - amount < GC_ALLOCATION_THRESHOLD * GC_HEAP_GROWTH_FACTOR)
return;
gcTriggerBytes -= amount;
@ -1361,7 +1361,7 @@ JSCompartment::setGCLastBytes(size_t lastBytes, JSGCInvocationKind gckind)
void
JSCompartment::reduceGCTriggerBytes(uint32_t amount) {
JS_ASSERT(amount > 0);
JS_ASSERT(gcTriggerBytes - amount >= 0);
JS_ASSERT(gcTriggerBytes >= amount);
if (gcTriggerBytes - amount < GC_ALLOCATION_THRESHOLD * GC_HEAP_GROWTH_FACTOR)
return;
gcTriggerBytes -= amount;

View File

@ -1687,9 +1687,7 @@ class TypedArrayTemplate
{
JS_ASSERT(tarray);
JS_ASSERT(0 <= begin);
JS_ASSERT(begin <= getLength(tarray));
JS_ASSERT(0 <= end);
JS_ASSERT(end <= getLength(tarray));
JSObject *bufobj = getBuffer(tarray);

View File

@ -71,11 +71,11 @@ private:
nsRect mRects[2];
public:
nsRect& Overflow(size_t aIndex) {
NS_ASSERTION(0 <= aIndex && aIndex < 2, "index out of range");
NS_ASSERTION(aIndex < 2, "index out of range");
return mRects[aIndex];
}
const nsRect& Overflow(size_t aIndex) const {
NS_ASSERTION(0 <= aIndex && aIndex < 2, "index out of range");
NS_ASSERTION(aIndex < 2, "index out of range");
return mRects[aIndex];
}