diff options
author | Claus Steuer <claus755@gmail.com> | 2015-07-22 11:08:01 +0200 |
---|---|---|
committer | Claus Steuer <claus755@gmail.com> | 2015-10-03 17:24:45 +0000 |
commit | 158b07c9c84c8bcd77620f36fe6f1e3eb8d7f224 (patch) | |
tree | 843867c4d879e1f4f759661289e584ecd8383148 /src/libs/3rdparty/cplusplus/Parser.cpp | |
parent | b1f6974954bfb135a4dd6c0747dec896ef7d8102 (diff) |
C++: Support noexcept operator
The code model failed to parse the noexcept operator which is often
used in noexcept specifiers, e.g.: "void f() noexcept(noexcept(g()));"
Consequently some c++11 headers such as unordered_map, array
and unordered_set could not be parsed and no code completition was
available. I have created the NoExceptOperatorExpressionAST class
which is created whenever a noexcept token is found in an
expression with operator precedence. The noExcept test case
in the cplusplus/cxx11 test now contains a function that
uses the noexcept operator.
Fixed noexcept operator parsing
Added the test requested by Sergey Shambir, which then revealed that
i had not implemeneted the noexpect operator parsing according to the
c++ specification.
As stated here http://cpp0x.centaur.ath.cx/expr.unary.noexcept.html
the noexcept operator is a unary-expression that contains an
expression (and not a constant-expression). This should now be fixed.
Change-Id: Id4a99a43b660bd83e7680274491d99a698b57094
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.cpp')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index da67e51b63..6fccebb015 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -5238,6 +5238,14 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node) return true; } + + case T_NOEXCEPT: { + if (!_languageFeatures.cxx11Enabled) + break; + + return parseNoExceptOperatorExpression(node); + } + default: break; } // switch @@ -5674,6 +5682,19 @@ bool Parser::parseThrowExpression(ExpressionAST *&node) return false; } +bool Parser::parseNoExceptOperatorExpression(ExpressionAST *&node) +{ + DEBUG_THIS_RULE(); + if (_languageFeatures.cxx11Enabled && LA() == T_NOEXCEPT) { + NoExceptOperatorExpressionAST *ast = new (_pool) NoExceptOperatorExpressionAST; + ast->noexcept_token = consumeToken(); + parseExpression(ast->expression); + node = ast; + return true; + } + return false; +} + bool Parser::lookAtObjCSelector() const { switch (LA()) { |