Fixed #4409 (Cppcheck 1.58 dev hangs when checking mhz.c of lmbench3 (attached code))
This commit is contained in:
parent
76c8887f5f
commit
a3ee72a51d
|
@ -6406,15 +6406,18 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign
|
|||
break;
|
||||
if (!structname.empty()) {
|
||||
tok3->deleteNext(2);
|
||||
ret = true;
|
||||
}
|
||||
tok3 = tok3->next();
|
||||
if (tok3->str() != value)
|
||||
ret = true;
|
||||
tok3->str(value);
|
||||
tok3->varId(valueVarId);
|
||||
if (tok3->previous()->str() == "*" && valueIsPointer) {
|
||||
tok3 = tok3->previous();
|
||||
tok3->deleteThis();
|
||||
ret = true;
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok3, "= {")) {
|
||||
|
|
|
@ -165,6 +165,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariables48); // ticket #3754 - wrong simplification in for loop header
|
||||
TEST_CASE(simplifyKnownVariables49); // #3691 - continue in switch
|
||||
TEST_CASE(simplifyKnownVariables50); // #4066 sprintf changes
|
||||
TEST_CASE(simplifyKnownVariables51); // #4409 hang
|
||||
TEST_CASE(simplifyKnownVariablesIfEq1); // if (a==5) => a is 5 in the block
|
||||
TEST_CASE(simplifyKnownVariablesIfEq2); // if (a==5) { buf[a++] = 0; }
|
||||
TEST_CASE(simplifyKnownVariablesBailOutAssign1);
|
||||
|
@ -2558,6 +2559,15 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyKnownVariables51() { // #4409 hang
|
||||
const char code[] = "void mhz_M(int enough) {\n"
|
||||
" TYPE *x=&x, **p=x, **q = NULL;\n"
|
||||
" BENCH1(q = _mhz_M(n); n = 1;)\n"
|
||||
" use_pointer(q);\n"
|
||||
"}";
|
||||
tokenizeAndStringify(code, true); // don't hang
|
||||
}
|
||||
|
||||
void simplifyKnownVariablesIfEq1() {
|
||||
const char code[] = "void f(int x) {\n"
|
||||
" if (x==5) {\n"
|
||||
|
|
Loading…
Reference in New Issue