Fix 11889: FP knownArgument with array element (#5395)
This commit is contained in:
parent
6c0a5a5859
commit
ffbcfae988
|
@ -3704,8 +3704,7 @@ static bool isVariableExpression(const Token* tok)
|
||||||
return isVariableExpression(tok->astOperand1()) &&
|
return isVariableExpression(tok->astOperand1()) &&
|
||||||
isVariableExpression(tok->astOperand2());
|
isVariableExpression(tok->astOperand2());
|
||||||
if (Token::simpleMatch(tok, "["))
|
if (Token::simpleMatch(tok, "["))
|
||||||
return isVariableExpression(tok->astOperand1()) &&
|
return isVariableExpression(tok->astOperand1());
|
||||||
tok->astOperand2() && tok->astOperand2()->hasKnownIntValue();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11053,6 +11053,20 @@ private:
|
||||||
" if (g(k(i))) {}\n"
|
" if (g(k(i))) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #11889
|
||||||
|
check("struct S {\n"
|
||||||
|
" int a[5];\n"
|
||||||
|
" void f(int i);\n"
|
||||||
|
"}\n"
|
||||||
|
"void g(int);\n"
|
||||||
|
"void S::f(int i) {\n"
|
||||||
|
" if (a[i] == 1) {\n"
|
||||||
|
" a[i] = 0;\n"
|
||||||
|
" g(a[i]);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void knownArgumentHiddenVariableExpression() {
|
void knownArgumentHiddenVariableExpression() {
|
||||||
|
|
Loading…
Reference in New Issue