diff options
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 7 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 6ae785f417..14d1cd46dc 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -695,13 +695,10 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym next = arg.at(0); } - if (!expansion.isEmpty() && expansion.constLast().token == s.token) { - Symbol last = expansion.constLast(); + Symbol last = expansion.constLast(); + if (!expansion.isEmpty() && last.token == s.token && last.token != STRING_LITERAL) { expansion.pop_back(); - if (last.token == STRING_LITERAL || s.token == STRING_LITERAL) - that->error("Can't concatenate non identifier tokens"); - QByteArray lexem = last.lexem() + next.lexem(); expansion += Symbol(lineNum, last.token, lexem); } else { diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 2989ac4485..9fdd37ea9b 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -70,6 +70,12 @@ #include "non-gadget-parent-class.h" #include "grand-parent-gadget-class.h" +#ifdef Q_MOC_RUN +// check that moc can parse these constructs, they are being used in Windows winsock2.h header +#define STRING_HASH_HASH(x) ("foo" ## x ## "bar") +const char *string_hash_hash = STRING_HASH_HASH("baz"); +#endif + Q_DECLARE_METATYPE(const QMetaObject*); |