summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-21 13:30:49 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-21 16:02:06 +0200
commit09c90c9fc3f30a4ef5166afa6c5c81aab7ac278e (patch)
tree36516187ba64ebbf0ca4ec96d85fc4176ca6ee4c /tests/auto/cmake
parent5486091a946b6ee7f023eeaa3220cf3a1d5728da (diff)
Make QStringLiteral always choke on non-literals
The fallback implementation of QStringLiteral did not (up to now) enforce the need to use a literal. So it was possible to write: const char *foo = "Hello"; QString s = QStringLiteral(foo); Which would do the wrong thing and create s == "Hel" on 32-bit platforms (sizeof(foo) == 4) or, wrose, s == "Hello\0XY" on 64-bit platforms (sizeof(foo) == 8, X and Y are garbage). This change enforces the need for a literal by producing errors on the above cases, as well as when foo is a char array variable. GCC: error: expected ‘)’ before ‘foo’ Clang (abbreviated): error: expected ')' namespace X { QString x() { const char foo[42] = "Hello"; return QStringLiteral(foo); } } ^ note: to match this '(' ^ ICC: error: expected a ")" namespace X { QString x() { const char foo[42] = "Hello"; return QStringLiteral(foo); } } ^ The first C++11 error currently is: error: expected primary-expression before ‘enum’ (GCC) error: expected a ")" (ICC) Change-Id: I317173421dbd7404987601230456471c93b122ed Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/cmake')
0 files changed, 0 insertions, 0 deletions