diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 36d84a61d8e..4d3ccb86802 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 6e048315897..43d00e82f3e 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