Fix 10496: crash: endless recursion (symbolDatabaseCreateExprId => isSameExpr => isSameExpr ...) (#3467)
This commit is contained in:
parent
2ee920dc4e
commit
5c3b69fe96
|
@ -169,9 +169,9 @@ bool astHasToken(const Token* root, const Token * tok)
|
||||||
{
|
{
|
||||||
if (!root)
|
if (!root)
|
||||||
return false;
|
return false;
|
||||||
if (root == tok)
|
while (tok->astParent() && tok != root)
|
||||||
return true;
|
tok = tok->astParent();
|
||||||
return astHasToken(root->astOperand1(), tok) || astHasToken(root->astOperand2(), tok);
|
return root == tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool astHasVar(const Token * tok, nonneg int varid)
|
bool astHasVar(const Token * tok, nonneg int varid)
|
||||||
|
@ -833,6 +833,8 @@ std::vector<ReferenceToken> followAllReferences(const Token* tok,
|
||||||
errors.emplace_back(var->declEndToken(), "Passed to reference.");
|
errors.emplace_back(var->declEndToken(), "Passed to reference.");
|
||||||
return {{tok, std::move(errors)}};
|
return {{tok, std::move(errors)}};
|
||||||
} else if (Token::simpleMatch(var->declEndToken(), "=")) {
|
} else if (Token::simpleMatch(var->declEndToken(), "=")) {
|
||||||
|
if (astHasToken(var->declEndToken(), tok))
|
||||||
|
return std::vector<ReferenceToken>{};
|
||||||
errors.emplace_back(var->declEndToken(), "Assigned to reference.");
|
errors.emplace_back(var->declEndToken(), "Assigned to reference.");
|
||||||
const Token *vartok = var->declEndToken()->astOperand2();
|
const Token *vartok = var->declEndToken()->astOperand2();
|
||||||
if (vartok == tok || (!temporary && isTemporary(true, vartok, nullptr, true) &&
|
if (vartok == tok || (!temporary && isTemporary(true, vartok, nullptr, true) &&
|
||||||
|
|
|
@ -409,6 +409,7 @@ private:
|
||||||
TEST_CASE(checkIfCppCast);
|
TEST_CASE(checkIfCppCast);
|
||||||
TEST_CASE(checkRefQualifiers);
|
TEST_CASE(checkRefQualifiers);
|
||||||
TEST_CASE(checkConditionBlock);
|
TEST_CASE(checkConditionBlock);
|
||||||
|
TEST_CASE(checkUnknownCircularVar);
|
||||||
|
|
||||||
// #9052
|
// #9052
|
||||||
TEST_CASE(noCrash1);
|
TEST_CASE(noCrash1);
|
||||||
|
@ -6845,6 +6846,14 @@ private:
|
||||||
"}\n"));
|
"}\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkUnknownCircularVar()
|
||||||
|
{
|
||||||
|
ASSERT_NO_THROW(tokenizeAndStringify("void execute() {\n"
|
||||||
|
" const auto &bias = GEMM_CTX_ARG_STORAGE(bias);\n"
|
||||||
|
" auto &c = GEMM_CTX_ARG_STORAGE(c);\n"
|
||||||
|
"}\n"));
|
||||||
|
}
|
||||||
|
|
||||||
void noCrash1() {
|
void noCrash1() {
|
||||||
ASSERT_NO_THROW(tokenizeAndStringify(
|
ASSERT_NO_THROW(tokenizeAndStringify(
|
||||||
"struct A {\n"
|
"struct A {\n"
|
||||||
|
|
Loading…
Reference in New Issue