Ensure that Qt public headers compile with strict flags
authorDavid Faure <faure@kde.org>
Fri, 17 Feb 2012 08:05:39 +0000 (09:05 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 17 Feb 2012 15:42:28 +0000 (16:42 +0100)
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 <thiago.macieira@intel.com>
src/corelib/kernel/qmetatype.h
src/gui/accessible/qaccessible.h
tests/auto/other/headersclean/headersclean.pro
tests/auto/other/headersclean/tst_headersclean.cpp

index 1473231..4af77fc 100644 (file)
@@ -284,7 +284,7 @@ private:
                      Constructor constructor,
                      Destructor destructor,
                      uint sizeOf,
-                     uint typeFlags,
+                     uint theTypeFlags,
                      int typeId);
     QMetaType(const QMetaType &other);
     QMetaType &operator =(const QMetaType &);
@@ -621,7 +621,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
                             Constructor constructor,
                             Destructor destructor,
                             uint size,
-                            uint typeFlags,
+                            uint theTypeFlags,
                             int typeId)
     : m_creator(creator)
     , m_deleter(deleter)
@@ -630,7 +630,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
     , m_constructor(constructor)
     , m_destructor(destructor)
     , m_size(size)
-    , m_typeFlags(typeFlags)
+    , m_typeFlags(theTypeFlags)
     , m_extensionFlags(extensionFlags)
     , m_typeId(typeId)
 {
index 9fc13a8..a3661e6 100644 (file)
@@ -432,10 +432,10 @@ private:
 class Q_GUI_EXPORT QAccessibleEvent
 {
 public:
-    inline QAccessibleEvent(QAccessible::Event type, QObject *object, int child = -1)
-        : m_type(type), m_object(object), m_child(child)
+    inline QAccessibleEvent(QAccessible::Event typ, QObject *obj, int chld = -1)
+        : m_type(typ), m_object(obj), m_child(chld)
     {
-        Q_ASSERT(object);
+        Q_ASSERT(obj);
     }
 
     QAccessible::Event type() const { return m_type; }
index 814f19c..5444beb 100644 (file)
@@ -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
index 41992b8..81d0aa3 100644 (file)
@@ -39,7 +39,6 @@
 **
 ****************************************************************************/
 
-#define QT_NO_KEYWORDS
 #define signals int
 #define slots int
 #define emit public:;
 #define forever public:;
 
 #include <QtCore/QtCore>
+#include <QtConcurrent/QtConcurrent>
 #include <QtTest/QtTest>
 
 #include <QtNetwork/QtNetwork>
 #include <QtXml/QtXml>
 #include <QtSql/QtSql>
 #include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
+#include <QtPrintSupport/QtPrintSupport>
+#include <QtPlatformSupport/QtPlatformSupport>
 
 #ifndef QT_NO_OPENGL
 #include <QtOpenGL/QtOpenGL>