[cairo] [PATCH] qt: Suppress warnings in qt backend build

Ravi Nanjundappa nravi.n at samsung.com
Thu Sep 4 23:45:02 PDT 2014


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 at samsung.com>
---
 build/configure.ac.warnings |   13 +++++++------
 src/cairo-qt-surface.cpp    |    9 ++++++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/build/configure.ac.warnings b/build/configure.ac.warnings
index 2c4e34d..8aeae3b 100644
--- a/build/configure.ac.warnings
+++ b/build/configure.ac.warnings
@@ -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.
@@ -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])
 ])
diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index ce05dba..3034e56 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -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;
@@ -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)
 {
@@ -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)
@@ -1048,7 +1051,7 @@ struct PatternToBrushConverter {
 	}
     }
 
-    ~PatternToBrushConverter () {
+    ~PatternToBrushConverter () __attribute__ ((noinline)){
 	if (mAcquiredImageParent)
 	    _cairo_surface_release_source_image (mAcquiredImageParent, mAcquiredImage, mAcquiredImageExtra);
     }
-- 
1.7.9.5



More information about the cairo mailing list