From a2322519929bd36a90422dccc0310b8230729197 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 14 Jun 2017 08:28:40 +0200 Subject: Moc: Don't error out when parsing namespace __identifier(...) Present for example in the Windows's Atlbase.h header. We should not abort the compilation, just ignore that construct Task-number: QTBUG-56634 Change-Id: Id6e4c9f03cb1cef46e330f4fbcae80ce4f3730c6 Reviewed-by: Simon Hausmann --- src/tools/moc/moc.cpp | 3 +++ tests/auto/tools/moc/namespace.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 36d84a61d8..4d3ccb8680 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -559,6 +559,9 @@ void Moc::parse() if (test(EQ)) { // namespace Foo = Bar::Baz; until(SEMIC); + } else if (test(LPAREN)) { + // Ignore invalid code such as: 'namespace __identifier("x")' (QTBUG-56634) + until(RPAREN); } else if (!test(SEMIC)) { NamespaceDef def; def.classname = nsName; diff --git a/tests/auto/tools/moc/namespace.h b/tests/auto/tools/moc/namespace.h index 6e04831589..43d00e82f3 100644 --- a/tests/auto/tools/moc/namespace.h +++ b/tests/auto/tools/moc/namespace.h @@ -74,4 +74,8 @@ namespace FooNamespace { } } +#ifdef Q_MOC_RUN +namespace __identifier("") {} // QTBUG-56634 +#endif + #endif // NAMESPACE_H -- cgit v1.2.3