Don't error out on preprocessor concatenation of two strings
"foo" ## "bar" doesn't make a lot of sense, but MSVC allows them (although gcc errors out on them). Simply ignore the ## in this case instead of aborting with an error. Fixes parsing of the Windows winsock2.h header. Task-number: QTBUG-54560 Change-Id: I84cd5fbb56a006cf379430708c955cf0da475cff Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
31b6760e64
commit
c32ef0a725
@ -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 {
|
||||
|
@ -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*);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user