Fixed #9892 (Crash: endless recursion in Token::typeDecl for expression 'auto combo = widget->combo = new Combo{};')
This commit is contained in:
parent
61145cf878
commit
e03a8e1dc1
|
@ -2162,7 +2162,7 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token * tok)
|
||||||
const Token * tok2 = var->declEndToken();
|
const Token * tok2 = var->declEndToken();
|
||||||
if (Token::Match(tok2, "; %varid% =", var->declarationId()))
|
if (Token::Match(tok2, "; %varid% =", var->declarationId()))
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
if (Token::simpleMatch(tok2, "=") && tok2->astOperand2()) {
|
if (Token::simpleMatch(tok2, "=") && Token::Match(tok2->astOperand2(), "!!=")) {
|
||||||
std::pair<const Token*, const Token*> r = typeDecl(tok2->astOperand2());
|
std::pair<const Token*, const Token*> r = typeDecl(tok2->astOperand2());
|
||||||
if (r.first)
|
if (r.first)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -430,6 +430,7 @@ private:
|
||||||
TEST_CASE(auto11); // #8964 - const auto startX = x;
|
TEST_CASE(auto11); // #8964 - const auto startX = x;
|
||||||
TEST_CASE(auto12); // #8993 - const std::string &x; auto y = x; if (y.empty()) ..
|
TEST_CASE(auto12); // #8993 - const std::string &x; auto y = x; if (y.empty()) ..
|
||||||
TEST_CASE(auto13);
|
TEST_CASE(auto13);
|
||||||
|
TEST_CASE(auto14);
|
||||||
|
|
||||||
TEST_CASE(unionWithConstructor);
|
TEST_CASE(unionWithConstructor);
|
||||||
|
|
||||||
|
@ -7789,6 +7790,18 @@ private:
|
||||||
ASSERT(tok->variable()->valueType()->pointer);
|
ASSERT(tok->variable()->valueType()->pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void auto14() { // #9892 - crash in Token::declType
|
||||||
|
GET_SYMBOL_DB("static void foo() {\n"
|
||||||
|
" auto combo = widget->combo = new Combo{};\n"
|
||||||
|
" combo->addItem();\n"
|
||||||
|
"}");
|
||||||
|
|
||||||
|
const Token *tok;
|
||||||
|
|
||||||
|
tok = Token::findsimplematch(tokenizer.tokens(), "combo =");
|
||||||
|
ASSERT(tok && !tok->valueType());
|
||||||
|
}
|
||||||
|
|
||||||
void unionWithConstructor() {
|
void unionWithConstructor() {
|
||||||
GET_SYMBOL_DB("union Fred {\n"
|
GET_SYMBOL_DB("union Fred {\n"
|
||||||
" Fred(int x) : i(x) { }\n"
|
" Fred(int x) : i(x) { }\n"
|
||||||
|
|
Loading…
Reference in New Issue