Skip to content

Commit

Permalink
qt: Suppress warnings in qt backend build
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ravi Nanjundappa authored and Bryce Harrington committed Sep 11, 2014
1 parent 29a8b4e commit 3b9d7e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
13 changes: 7 additions & 6 deletions build/configure.ac.warnings
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ dnl MAYBE_WARN in an ignorable way (like adding whitespace)
# -Wlogical-op causes too much noise from strcmp("literal", str)

MAYBE_WARN="-Wall -Wextra \
-Wold-style-definition -Wdeclaration-after-statement \
-Wmissing-declarations -Werror-implicit-function-declaration \
-Wnested-externs -Wpointer-arith -Wwrite-strings \
-Wsign-compare -Wstrict-prototypes -Wmissing-prototypes \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wbad-function-cast -Wvolatile-register-var \
-Wpointer-arith -Wwrite-strings -Wsign-compare -Wpacked
-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"

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 unknow each time another warning happen.
Expand Down Expand Up @@ -66,7 +67,7 @@ AC_CACHE_CHECK([for supported warning flags], cairo_cv_warn_cflags, [
CAIRO_CC_TRY_FLAG([-W$W -Wno-$W],, [WARN_CFLAGS="$WARN_CFLAGS -Wno-$W"])
done
cairo_cv_warn_cflags=$WARN_CFLAGS
cairo_cv_warn_maybe=$MAYBE_WARN
cairo_cv_warn_maybe="$MAYBE_WARN $MAYBE_C_SPECIFIC_WARN"

AC_MSG_CHECKING([which warning flags were supported])
])
Expand Down
9 changes: 6 additions & 3 deletions src/cairo-qt-surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ _qimage_format_from_cairo_format (cairo_format_t fmt)
#else
return QImage::Format_MonoLSB;
#endif
case CAIRO_FORMAT_RGB30:
return QImage::Format_Mono;
}

return QImage::Format_Mono;
Expand Down Expand Up @@ -386,7 +388,7 @@ _cairo_path_to_qpainterpath_close_path (void *closure)
return CAIRO_STATUS_SUCCESS;
}

static inline QPainterPath
static QPainterPath
path_to_qt (const cairo_path_fixed_t *path,
const cairo_matrix_t *ctm_inverse = NULL)
{
Expand Down Expand Up @@ -849,7 +851,8 @@ _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
*/

struct PatternToBrushConverter {
PatternToBrushConverter (const cairo_pattern_t *pattern) :
PatternToBrushConverter (const cairo_pattern_t *pattern)
__attribute__ ((noinline)) :
mAcquiredImageParent(0),
mAcquiredImage(0),
mAcquiredImageExtra(0)
Expand Down Expand Up @@ -1048,7 +1051,7 @@ struct PatternToBrushConverter {
}
}

~PatternToBrushConverter () {
~PatternToBrushConverter () __attribute__ ((noinline)){
if (mAcquiredImageParent)
_cairo_surface_release_source_image (mAcquiredImageParent, mAcquiredImage, mAcquiredImageExtra);
}
Expand Down

0 comments on commit 3b9d7e5

Please sign in to comment.