diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-08-11 17:48:47 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-08-18 09:20:23 +0000 |
commit | e9b3cd548cd3e9f872344f518c01387dc6af814b (patch) | |
tree | 3ec3fcc6f911b4580244c07396c1ad20dee0d8d1 /src/libs/3rdparty/cplusplus/Parser.cpp | |
parent | 8761b7c20c13858b1c2bb759f32f4e1be282aa60 (diff) |
CPlusPlus: Fix crash on weird-looking construct
This was misparsed as a function with an initializer (e.g. "= default"),
and then the empty id caused trouble later on.
Fixes: QTCREATORBUG-29386
Change-Id: I85a35db544e11ad85f50e3a15b1a071b36e79cd0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.cpp')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 6bf19f5982..395556777d 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -3020,6 +3020,11 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp if (!_languageFeatures.cxx11Enabled || LA(2) == T_NUMERIC_LITERAL) { parseInitializer(node->initializer, &node->equal_token); } else { + if (LA(2) != T_NUMERIC_LITERAL && LA(2) != T_DEFAULT && LA(2) != T_DELETE) { + error(cursor(), "expected 'default', 'delete' or '0', got '%s'", tok(2).spell()); + return false; + } + node->equal_token = consumeToken(); IdExpressionAST *id_expr = new (_pool) IdExpressionAST; |