diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-02-28 11:09:50 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-03-03 11:10:54 +0000 |
commit | 47d375bbb419accc1b5af8c588a6fa86a52f1f52 (patch) | |
tree | eeef21abeda34b6baea52dd898ac8397f3ca440b /src/libs/3rdparty/cplusplus/Parser.cpp | |
parent | 7214d794209d3c5770d481615a428de88fa99873 (diff) |
CPlusPlus: Support requires clause in parser
Change-Id: Ice6a7a287453516a1cfc296e2c9f16160b3ea130
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.cpp')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index ed023b15f0..004bee40e7 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -1247,6 +1247,8 @@ bool Parser::parseTemplateDeclaration(DeclarationAST *&node) ast->less_token = consumeToken(); if (maybeSplitGreaterGreaterToken() || LA() == T_GREATER || parseTemplateParameterList(ast->template_parameter_list)) match(T_GREATER, &ast->greater_token); + if (!parseRequiresClauseOpt(ast->requiresClause)) + return false; } while (LA()) { @@ -1402,6 +1404,20 @@ bool Parser::parseRequirement() return true; } +bool Parser::parseRequiresClauseOpt(RequiresClauseAST *&node) +{ + if (!_languageFeatures.cxx20Enabled) + return true; + if (LA() != T_REQUIRES) + return true; + const auto ast = new (_pool) RequiresClauseAST; + ast->requires_token = consumeToken(); + if (!parseLogicalOrExpression(ast->constraint)) + return false; + node = ast; + return true; +} + bool Parser::parseRequiresExpression(ExpressionAST *&node) { if (!_languageFeatures.cxx20Enabled) @@ -2999,6 +3015,8 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp } else if (node->core_declarator && node->core_declarator->asDecompositionDeclarator()) { error(cursor(), "structured binding needs initializer"); return false; + } else if (!parseRequiresClauseOpt(node->requiresClause)) { + return false; } return true; } |