diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-06-03 14:07:52 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-06 22:53:07 +0000 |
commit | 94a2aec05bcd40194354107eb8264bf28cbd2b19 (patch) | |
tree | 35fa372b912c86119b2fe1dab2a3fea7bb0b06fe /src | |
parent | 74111ce590ec8b40ee48e828c238bbfb1bf41aaa (diff) |
moc: Don't error out when defining a keyword
Normaly, in C++ It's not valid to define a keyword, but it turns out that some
system header do, so we just silently accept it.
[ChangeLog][moc] moc no longer errors out if a C++ keyword is #define'ed
Task-number: QTBUG-61204
Change-Id: Ia4d3ff9c77b6ff261b6140c220cfb81bd13f1d6d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 32c94639ab..9a06fb38d0 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -1109,19 +1109,18 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) } case PP_DEFINE: { - next(IDENTIFIER); + next(); QByteArray name = lexem(); + if (name.isEmpty() || !is_ident_start(name[0])) + error(); Macro macro; macro.isVariadic = false; - Token t = next(); - if (t == LPAREN) { + if (test(LPAREN)) { // we have a function macro macro.isFunction = true; parseDefineArguments(¯o); - } else if (t == PP_WHITESPACE){ - macro.isFunction = false; } else { - error("Moc: internal error"); + macro.isFunction = false; } int start = index; until(PP_NEWLINE); @@ -1160,7 +1159,7 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) continue; } case PP_UNDEF: { - next(IDENTIFIER); + next(); QByteArray name = lexem(); until(PP_NEWLINE); macros.remove(name); |