From 7e970eb58c71dc08981575c648a04d258dbf0684 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 17 Feb 2012 09:05:39 +0100 Subject: Ensure that Qt public headers compile with strict flags Those from http://wiki.qt-project.org/Coding_Conventions#Conventions_for_public_header_files (unfortunatey -Wold-style-cast cannot be used due to the glibc macro bswap_16) and many Qt defines that disable casts. Change-Id: I97ac707a101df9819e8c031fa75a31b30e20247f Reviewed-by: Thiago Macieira --- tests/auto/other/headersclean/headersclean.pro | 27 +++++++++++++++++++--- tests/auto/other/headersclean/tst_headersclean.cpp | 5 +++- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/other/headersclean/headersclean.pro b/tests/auto/other/headersclean/headersclean.pro index 814f19c865..5444bebfb9 100644 --- a/tests/auto/other/headersclean/headersclean.pro +++ b/tests/auto/other/headersclean/headersclean.pro @@ -1,7 +1,28 @@ CONFIG += testcase TARGET = tst_headersclean SOURCES += tst_headersclean.cpp -QT = core network xml sql testlib -contains(QT_CONFIG,dbus): QT += dbus -contains(QT_CONFIG,opengl): QT += opengl +# No need to link to all modules, only those actually used +QT = core testlib gui widgets + +*-g++*: QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror + +# The flags here come from http://wiki.qt-project.org/Coding_Conventions#Conventions_for_public_header_files +# -Wold-style-cast cannot be used, /usr/include/bits/byteswap.h defines the macro bswap_16 using C style casts :( +# -Wfloat-equal cannot be used, qrect.h and qvector2d.h do exact comparisons in isNull and operator==. Would need #pragmas. +*-g++*: QMAKE_CXXFLAGS += -Woverloaded-virtual -Wshadow -Wundef + +# Other nice flags +*-g++*: QMAKE_CXXFLAGS += -Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wpointer-arith -Wformat-security + +# Enable pedantic mode, but accept variadic macros and 'long long' usage. +*-g++*: QMAKE_CXXFLAGS += -Wno-long-long -Wno-variadic-macros -pedantic-errors + +QMAKE_CXXFLAGS += -DQT_NO_CAST_TO_ASCII \ + -DQT_NO_CAST_FROM_ASCII \ + -DQT_STRICT_ITERATORS \ + -DQT_NO_URL_CAST_FROM_STRING \ + -DQT_NO_CAST_FROM_BYTEARRAY \ + -DQT_NO_KEYWORDS \ + -DQT_USE_FAST_CONCATENATION \ + -DQT_USE_FAST_OPERATOR_PLUS diff --git a/tests/auto/other/headersclean/tst_headersclean.cpp b/tests/auto/other/headersclean/tst_headersclean.cpp index 41992b8d2a..81d0aa3a4a 100644 --- a/tests/auto/other/headersclean/tst_headersclean.cpp +++ b/tests/auto/other/headersclean/tst_headersclean.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#define QT_NO_KEYWORDS #define signals int #define slots int #define emit public:; @@ -47,12 +46,16 @@ #define forever public:; #include +#include #include #include #include #include #include +#include +#include +#include #ifndef QT_NO_OPENGL #include -- cgit v1.2.3