cairo/build/configure.ac.warnings

100 lines
4.1 KiB
Text
Raw Normal View History

dnl Use lots of warning flags with with gcc and compatible compilers
dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked. So there's no need to do anything
dnl else. If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)
# -Wcast-align generates lots of false positive reports we need to
# cast image data from uint8_t to uin32_t.
# -Wlogical-op causes too much noise from strcmp("literal", str)
MAYBE_WARN="-Wall -Wextra \
-Wmissing-declarations -Werror-implicit-function-declaration \
-Wpointer-arith -Wwrite-strings -Wsign-compare -Wpacked \
qt: Suppress warnings in qt backend build This patch fixes majorly 2 kinds of warning issues: (1) cc1plus: warning: command line option '-Wold-style-definition' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wdeclaration-after-statement' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wnested-externs' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wstrict-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wmissing-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wbad-function-cast' is valid for C/ObjC but not for C++ [enabled by default] Solution: Enable these warnings only for C compiler and not for C++ (2) cairo-qt-surface.cpp: In function 'cairo_int_status_t _cairo_qt_surface_fill(void*, cairo_operator_t, const cairo_pattern_t*, const cairo_path_fixed_t*, cairo_fill_rule_t, double, cairo_antialias_t, const cairo_clip_t*)': cairo-qt-surface.cpp:852:5: warning: inlining failed in call to 'PatternToBrushConverter::PatternToBrushConverter(const cairo_pattern_t*)': --param max-inline-insns-single limit reached [-Winline] cairo-qt-surface.cpp:1339:38: warning: called from here [-Winline] cairo-qt-surface.cpp:390:1: warning: inlining failed in call to 'QPainterPath _ZL10path_to_qtPK17_cairo_path_fixedPK13_cairo_matrix.part.13()': call is unlikely and code size would grow [-Winline] cairo-qt-surface.cpp:1306:1: warning: called from here [-Winline] cairo-qt-surface.cpp:1051:5: warning: inlining failed in call to 'PatternToBrushConverter::~PatternToBrushConverter()': call is unlikely and code size would grow [-Winline] Solution: Add __attribute__ ((noinline)) to the function as mentioned in http://stackoverflow.com/questions/11724235/warning-for-template-with-g-o2-or-os-o-o1 (Edit 3) Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-09-05 12:15:02 +05:30
-Wswitch-enum -Wmissing-format-attribute -Wvolatile-register-var \
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
-Wno-missing-field-initializers -Wno-unused-parameter \
-Wno-attributes -Wno-long-long -Winline"
qt: Suppress warnings in qt backend build This patch fixes majorly 2 kinds of warning issues: (1) cc1plus: warning: command line option '-Wold-style-definition' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wdeclaration-after-statement' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wnested-externs' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wstrict-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wmissing-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wbad-function-cast' is valid for C/ObjC but not for C++ [enabled by default] Solution: Enable these warnings only for C compiler and not for C++ (2) cairo-qt-surface.cpp: In function 'cairo_int_status_t _cairo_qt_surface_fill(void*, cairo_operator_t, const cairo_pattern_t*, const cairo_path_fixed_t*, cairo_fill_rule_t, double, cairo_antialias_t, const cairo_clip_t*)': cairo-qt-surface.cpp:852:5: warning: inlining failed in call to 'PatternToBrushConverter::PatternToBrushConverter(const cairo_pattern_t*)': --param max-inline-insns-single limit reached [-Winline] cairo-qt-surface.cpp:1339:38: warning: called from here [-Winline] cairo-qt-surface.cpp:390:1: warning: inlining failed in call to 'QPainterPath _ZL10path_to_qtPK17_cairo_path_fixedPK13_cairo_matrix.part.13()': call is unlikely and code size would grow [-Winline] cairo-qt-surface.cpp:1306:1: warning: called from here [-Winline] cairo-qt-surface.cpp:1051:5: warning: inlining failed in call to 'PatternToBrushConverter::~PatternToBrushConverter()': call is unlikely and code size would grow [-Winline] Solution: Add __attribute__ ((noinline)) to the function as mentioned in http://stackoverflow.com/questions/11724235/warning-for-template-with-g-o2-or-os-o-o1 (Edit 3) Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-09-05 12:15:02 +05:30
MAYBE_C_SPECIFIC_WARN="-Wold-style-definition \
-Wdeclaration-after-statement -Wstrict-prototypes \
-Wmissing-prototypes -Wbad-function-cast -Wnested-externs"
# New -Wno options should be added here
# gcc-4.4 and later accept every -Wno- option but may complain later that this
# option is unknown each time another warning happens.
# -Wunused-but-set-variable is too noisy at present
NO_WARN="unused-but-set-variable"
dnl Sun Studio 12 likes to rag at us for abusing enums like
dnl having cairo_status_t variables hold cairo_int_status_t
dnl values. It's bad, we know. Now please be quiet.
MAYBE_WARN="$MAYBE_WARN -erroff=E_ENUM_TYPE_MISMATCH_ARG \
-erroff=E_ENUM_TYPE_MISMATCH_OP"
dnl We also abuse the warning-flag facility to enable other compiler
dnl options. Namely, the following:
MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common"
dnl Also to turn various gcc/glibc-specific preprocessor checks
MAYBE_WARN="$MAYBE_WARN -Wp,-D_FORTIFY_SOURCE=2"
# invalidate cached value if MAYBE_WARN has changed
if test "x$cairo_cv_warn_maybe" != "x$MAYBE_WARN"; then
unset cairo_cv_warn_cflags
fi
AC_CACHE_CHECK([for supported warning flags], cairo_cv_warn_cflags, [
echo
WARN_CFLAGS=""
# Some warning options are not supported by all versions of
# gcc, so test all desired options against the current
# compiler.
#
# Note that there are some order dependencies
# here. Specifically, an option that disables a warning will
# have no net effect if a later option then enables that
# warnings, (perhaps implicitly). So we put some grouped
# options (-Wall and -Wextra) up front and the -Wno options
# last.
for W in $MAYBE_WARN; do
CAIRO_CC_TRY_FLAG([$W],, [WARN_CFLAGS="$WARN_CFLAGS $W"])
done
for W in $NO_WARN; do
CAIRO_CC_TRY_FLAG([-W$W -Wno-$W],, [WARN_CFLAGS="$WARN_CFLAGS -Wno-$W"])
done
cairo_cv_warn_cflags=$WARN_CFLAGS
qt: Suppress warnings in qt backend build This patch fixes majorly 2 kinds of warning issues: (1) cc1plus: warning: command line option '-Wold-style-definition' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wdeclaration-after-statement' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wnested-externs' is valid for C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wstrict-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wmissing-prototypes' is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option '-Wbad-function-cast' is valid for C/ObjC but not for C++ [enabled by default] Solution: Enable these warnings only for C compiler and not for C++ (2) cairo-qt-surface.cpp: In function 'cairo_int_status_t _cairo_qt_surface_fill(void*, cairo_operator_t, const cairo_pattern_t*, const cairo_path_fixed_t*, cairo_fill_rule_t, double, cairo_antialias_t, const cairo_clip_t*)': cairo-qt-surface.cpp:852:5: warning: inlining failed in call to 'PatternToBrushConverter::PatternToBrushConverter(const cairo_pattern_t*)': --param max-inline-insns-single limit reached [-Winline] cairo-qt-surface.cpp:1339:38: warning: called from here [-Winline] cairo-qt-surface.cpp:390:1: warning: inlining failed in call to 'QPainterPath _ZL10path_to_qtPK17_cairo_path_fixedPK13_cairo_matrix.part.13()': call is unlikely and code size would grow [-Winline] cairo-qt-surface.cpp:1306:1: warning: called from here [-Winline] cairo-qt-surface.cpp:1051:5: warning: inlining failed in call to 'PatternToBrushConverter::~PatternToBrushConverter()': call is unlikely and code size would grow [-Winline] Solution: Add __attribute__ ((noinline)) to the function as mentioned in http://stackoverflow.com/questions/11724235/warning-for-template-with-g-o2-or-os-o-o1 (Edit 3) Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-09-05 12:15:02 +05:30
cairo_cv_warn_maybe="$MAYBE_WARN $MAYBE_C_SPECIFIC_WARN"
AC_MSG_CHECKING([which warning flags were supported])
])
WARN_CFLAGS="$cairo_cv_warn_cflags"
CAIRO_CFLAGS="$CAIRO_CFLAGS $WARN_CFLAGS"
# We only wish to enable attribute(warn_unused_result) if we can prevent
# gcc from generating thousands of warnings about the misapplication of the
# attribute to void functions and variables.
AC_CACHE_CHECK([how to enable unused result warnings], cairo_cv_warn_unused_result, [
AC_REQUIRE([AC_PROG_GREP])
cairo_cv_warn_unused_result=""
if echo $WARN_CFLAGS | $GREP -e '-Wno-attributes' >/dev/null; then
CAIRO_CC_TRY_FLAG_SILENT(
[-Wno-attributes],
[__attribute__((__warn_unused_result__)) void f (void) {}
__attribute__((__warn_unused_result__)) int g;],
[cairo_cv_warn_unused_result="__attribute__((__warn_unused_result__))"])
fi
])
AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$cairo_cv_warn_unused_result],
[Define to the value your compiler uses to support the warn-unused-result attribute])
dnl check linker flags
AC_CACHE_CHECK([how to allow undefined symbols in shared libraries used by test suite], cairo_cv_test_undefined_ldflags,
[CAIRO_CC_TRY_FLAG_SILENT([-Wl,--allow-shlib-undefined], [],
[cairo_cv_test_undefined_ldflags="-Wl,--allow-shlib-undefined]")])
CAIRO_TEST_UNDEFINED_LDFLAGS="$cairo_cv_test_undefined_ldflags"
AC_SUBST(CAIRO_TEST_UNDEFINED_LDFLAGS)