From aab6ac5d7705dca85d2f34aa9033dada815cb0a7 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 23 Jul 2020 16:47:34 +0000 Subject: [PATCH] review some compiler and language definition checks Signed-off-by: Ivailo Monev --- src/core/global/qglobal.h | 71 +++++++++--------------- src/core/plugin/qplugin.h | 9 +-- tests/auto/qvariant/tst_qvariant.cpp | 4 +- tests/auto/qwaitcondition/tst_qwaitcondition.cpp | 10 ---- 4 files changed, 28 insertions(+), 66 deletions(-) diff --git a/src/core/global/qglobal.h b/src/core/global/qglobal.h index 0232bacb6..671a66203 100644 --- a/src/core/global/qglobal.h +++ b/src/core/global/qglobal.h @@ -130,12 +130,10 @@ # error Unable to detect target endianness #endif -#ifdef __cplusplus #include // std::swap #include // std::uintptr_t -#endif -#if defined(__cplusplus) && !defined(QT_NO_USING_NAMESPACE) +#if !defined(QT_NO_USING_NAMESPACE) # define QT_NAMESPACE Katie # define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name @@ -153,7 +151,7 @@ namespace QT_NAMESPACE {} QT_USE_NAMESPACE # endif -#else /* QT_NO_USING_NAMESPACE && __cplusplus */ +#else /* QT_NO_USING_NAMESPACE */ # define QT_NAMESPACE # define QT_PREPEND_NAMESPACE(name) ::name @@ -165,7 +163,7 @@ QT_USE_NAMESPACE # define QT_BEGIN_INCLUDE_NAMESPACE # define QT_END_INCLUDE_NAMESPACE -#endif /* QT_NO_USING_NAMESPACE && __cplusplus */ +#endif /* QT_NO_USING_NAMESPACE */ #define QT_BEGIN_HEADER #define QT_END_HEADER @@ -254,6 +252,14 @@ QT_USE_NAMESPACE CLANG - C++ front-end for the LLVM compiler Should be sorted most to least authoritative. + + Paper Macro SD-6 macro + N2672 Q_COMPILER_INITIALIZER_LISTS + N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS __cpp_rvalue_references = 200610 + + For any future version of the C++ standard, we use only the SD-6 macro. + For full listing, see + http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */ #if defined(__GNUC__) # define Q_CC_GNU @@ -264,12 +270,23 @@ QT_USE_NAMESPACE # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result)) # define Q_LIKELY(expr) __builtin_expect(!!(expr), true) # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) +# define Q_FUNC_INFO __PRETTY_FUNCTION__ # if !defined(QT_MOC_CPP) # define Q_PACKED __attribute__ ((__packed__)) # ifndef __ARM_EABI__ # define QT_NO_ARM_EABI # endif # endif +# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) + /* C++0x features supported in GCC 4.3: */ +# define Q_COMPILER_RVALUE_REFS + /* C++0x features supported in GCC 4.4: */ +# define Q_COMPILER_INITIALIZER_LISTS +# /* C++0x features supported in GCC 4.6: */ +# ifdef __EXCEPTIONS +# define Q_COMPILER_EXCEPTIONS +# endif +# endif #elif defined(__clang__) # define Q_CC_CLANG @@ -284,39 +301,10 @@ QT_USE_NAMESPACE # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result)) # define Q_LIKELY(expr) __builtin_expect(!!(expr), true) # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) +# define Q_FUNC_INFO __PRETTY_FUNCTION__ # if !defined(QT_MOC_CPP) # define Q_PACKED __attribute__ ((__packed__)) # endif - -#else -# error "Katie has not been tested with this compiler" -#endif - -/* - * C++11 support - * - * Paper Macro SD-6 macro - * N2672 Q_COMPILER_INITIALIZER_LISTS - * N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS __cpp_rvalue_references = 200610 - * - * For any future version of the C++ standard, we use only the SD-6 macro. - * For full listing, see - * http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations - */ - -#if defined(Q_CC_GNU) -# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L - /* C++0x features supported in GCC 4.3: */ -# define Q_COMPILER_RVALUE_REFS - /* C++0x features supported in GCC 4.4: */ -# define Q_COMPILER_INITIALIZER_LISTS -# /* C++0x features supported in GCC 4.6: */ -# ifdef __EXCEPTIONS -# define Q_COMPILER_EXCEPTIONS -# endif -# endif - -#elif defined(Q_CC_CLANG) # if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) /* Detect C++ features using __has_feature(), see http://clang.llvm.org/docs/LanguageExtensions.html#cxx11 */ # if __has_feature(cxx_generalized_initializers) @@ -329,6 +317,9 @@ QT_USE_NAMESPACE # define Q_COMPILER_EXCEPTIONS # endif # endif + +#else +# error "Katie has not been tested with this compiler" #endif #define Q_OUTOFLINE_TEMPLATE @@ -381,8 +372,6 @@ typedef quint64 qulonglong; do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0) -#if defined(__cplusplus) - /* Useful type definitions for Qt */ @@ -644,12 +633,6 @@ Q_CORE_EXPORT void qBadAlloc(); template inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; } -#if defined(Q_CC_GNU) || defined(Q_CC_CLANG) -# define Q_FUNC_INFO __PRETTY_FUNCTION__ -#else -# define Q_FUNC_INFO __func__ -#endif - enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg }; Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf); @@ -1140,6 +1123,4 @@ Q_CORE_EXPORT int qrand(); QT_END_NAMESPACE QT_END_HEADER -#endif /* __cplusplus */ - #endif /* QGLOBAL_H */ diff --git a/src/core/plugin/qplugin.h b/src/core/plugin/qplugin.h index d08fad358..d89e52fc8 100644 --- a/src/core/plugin/qplugin.h +++ b/src/core/plugin/qplugin.h @@ -40,14 +40,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE - -#ifndef Q_EXTERN_C -# ifdef __cplusplus -# define Q_EXTERN_C extern "C" -# else -# define Q_EXTERN_C extern -# endif -#endif +#define Q_EXTERN_C extern "C" typedef QObject *(*QtPluginInstanceFunction)(); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 1bb22c848..f0fabdc29 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2179,9 +2179,7 @@ void tst_QVariant::userType() data3 = qvariant_cast(myCarrier); QCOMPARE(data3.number, 1); QCOMPARE(data3.text, (const char *)"eins"); -#ifndef Q_CC_SUN QCOMPARE(instanceCount, 4); -#endif } @@ -3030,7 +3028,7 @@ void tst_QVariant::task256984_setValue() void tst_QVariant::numericalConvert() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_ARCH_X86_64) QSKIP("Known to fail due to a GCC bug on at least Ubuntu 10.04 32-bit - check QTBUG-8959", SkipAll); #endif QVariant vfloat(float(5.3)); diff --git a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp index 32a189b14..535827c16 100644 --- a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp @@ -40,12 +40,7 @@ #include #include -#if defined(Q_OS_SYMBIAN) -// Symbian Open C has a bug that causes very short waits to fail sometimes -#define COND_WAIT_TIME 50 -#else #define COND_WAIT_TIME 1 -#endif //TESTED_CLASS= @@ -319,12 +314,7 @@ void tst_QWaitCondition::wait_QReadWriteLock() thread[x].readWriteLock.lockForRead(); thread[x].start(); // wait for thread to start -#if defined(Q_OS_SYMBIAN) && defined(Q_CC_WINSCW) - // Symbian emulator startup simultaneously with this thread causes additional delay - QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 10000)); -#else QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 1000)); -#endif thread[x].readWriteLock.unlock(); } -- 2.11.0