Don't use gcc extension for QByteArrayLiteral neither
authorLars Knoll <lars.knoll@nokia.com>
Mon, 11 Jun 2012 14:15:39 +0000 (16:15 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 20:57:22 +0000 (22:57 +0200)
This extension doesn't work for e.g. default arguments
in function declarations.

Change-Id: I32b7afa6e01b6af55fb2409179b4fd94cb04cd8d
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qbytearray.h
tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp

index 1e2a93d..489f5f2 100644 (file)
@@ -161,22 +161,6 @@ struct QByteArrayDataPtr
     }()) \
     /**/
 
-#elif defined(Q_CC_GNU)
-// We need to create a QByteArrayData in the .rodata section of memory
-// and the only way to do that is to create a "static const" variable.
-// To do that, we need the __extension__ {( )} trick which only GCC supports
-
-#  define QByteArrayLiteral(str) \
-    QByteArray(__extension__ ({ \
-        enum { Size = sizeof(str) - 1 }; \
-        static const QStaticByteArrayData<Size> qbytearray_literal = { \
-            Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(Size), \
-            str }; \
-        QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; \
-        holder; \
-    })) \
-    /**/
-
 #endif
 
 #ifndef QByteArrayLiteral
index 9bb3506..aa17a49 100644 (file)
@@ -1880,7 +1880,7 @@ void tst_QByteArray::movablity()
 
 void tst_QByteArray::literals()
 {
-#if defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU)
+#if defined(Q_COMPILER_LAMBDA)
     QByteArray str(QByteArrayLiteral("abcd"));
 
     QVERIFY(str.length() == 4);