* Fix #10828 Internal error. Token::Match called with varid 0 * Fix test
This commit is contained in:
parent
441b437cea
commit
d79d6e60db
|
@ -6083,7 +6083,8 @@ static void valueFlowForLoopSimplify(Token* const bodyStart,
|
|||
getProgramMemory(tok2->astTop(), expr, ValueFlow::Value(value), settings))))
|
||||
break;
|
||||
|
||||
else if (Token::simpleMatch(tok2, ") {") && Token::findmatch(tok2->link(), "%varid%", tok2, vartok->varId())) {
|
||||
else if (Token::simpleMatch(tok2, ") {")) {
|
||||
if (vartok->varId() && Token::findmatch(tok2->link(), "%varid%", tok2, vartok->varId())) {
|
||||
if (Token::findmatch(tok2, "continue|break|return", tok2->linkAt(1), vartok->varId())) {
|
||||
if (settings->debugwarnings)
|
||||
bailout(tokenlist, errorLogger, tok2, "For loop variable bailout on conditional continue|break|return");
|
||||
|
@ -6098,12 +6099,10 @@ static void valueFlowForLoopSimplify(Token* const bodyStart,
|
|||
bailout(tokenlist, errorLogger, tok2, "For loop variable bailout on conditional continue|break|return");
|
||||
break;
|
||||
}
|
||||
|
||||
tok2 = tok2->linkAt(2);
|
||||
}
|
||||
}
|
||||
|
||||
else if (Token::simpleMatch(tok2, ") {")) {
|
||||
else {
|
||||
if (settings->debugwarnings)
|
||||
bailout(tokenlist, errorLogger, tok2, "For loop skipping {} code");
|
||||
tok2 = tok2->linkAt(1);
|
||||
|
@ -6111,6 +6110,7 @@ static void valueFlowForLoopSimplify(Token* const bodyStart,
|
|||
tok2 = tok2->linkAt(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void valueFlowForLoopSimplifyAfter(Token* fortok,
|
||||
|
|
|
@ -4171,6 +4171,19 @@ private:
|
|||
" }\n"
|
||||
"}\n";
|
||||
testValueOfX(code, 0, 0); // <- don't throw
|
||||
|
||||
code = "struct C {\n" // #10828
|
||||
" int& v() { return i; }\n"
|
||||
" int& w() { return j; }\n"
|
||||
" int i{}, j{};\n"
|
||||
"};\n"
|
||||
"void f() {\n"
|
||||
" C c;\n"
|
||||
" for (c.w() = 0; c.w() < 2; c.w()++) {\n"
|
||||
" for (c.v() = 0; c.v() < 24; c.v()++) {}\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
testValueOfX(code, 0, 0); // <- don't throw
|
||||
}
|
||||
|
||||
void valueFlowSubFunction() {
|
||||
|
|
Loading…
Reference in New Issue