Add support for nested namespaces (C++17)

Task-number: QTCREATORBUG-16774
Change-Id: I3de3ac65810213e21c9a3bafef2474d252e191f7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Colin Duquesnoy
2018-02-04 16:24:57 +01:00
parent 7cf1ba2855
commit 2a016d05b2
6 changed files with 34 additions and 2 deletions

View File

@@ -863,7 +863,8 @@ bool Parser::parseStaticAssertDeclaration(DeclarationAST *&node)
bool Parser::parseNamespace(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
if (LA() != T_NAMESPACE && !(_languageFeatures.cxx11Enabled && LA() == T_INLINE && LA(2) == T_NAMESPACE))
if (LA() != T_NAMESPACE && !(_languageFeatures.cxx11Enabled && LA() == T_INLINE && LA(2) == T_NAMESPACE)
&& !isNestedNamespace())
return false;
unsigned inline_token = 0;
@@ -892,7 +893,9 @@ bool Parser::parseNamespace(DeclarationAST *&node)
if (LA() == T_IDENTIFIER)
ast->identifier_token = consumeToken();
parseOptionalAttributeSpecifierSequence(ast->attribute_list);
if (LA() == T_LBRACE) {
if (isNestedNamespace()) {
parseNestedNamespace(ast->linkage_body);
} else if (LA() == T_LBRACE) {
parseLinkageBody(ast->linkage_body);
} else { // attempt to do error recovery
unsigned pos = cursor();
@@ -923,6 +926,22 @@ bool Parser::parseNamespace(DeclarationAST *&node)
return true;
}
bool Parser::isNestedNamespace() const
{
return _languageFeatures.cxx11Enabled && LA() == T_COLON_COLON && LA(2) == T_IDENTIFIER;
}
bool Parser::parseNestedNamespace(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
DeclarationAST *ast = 0;
if (isNestedNamespace() && parseNamespace(ast)) {
node = ast;
return true;
}
return false;
}
bool Parser::parseUsing(DeclarationAST *&node)
{
DEBUG_THIS_RULE();