value flow: fixed fp in switch
This commit is contained in:
parent
3625d179e5
commit
f58e1ab80e
|
@ -245,6 +245,10 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
|
||||||
if (Token::Match(tok2->previous(), ") {") &&
|
if (Token::Match(tok2->previous(), ") {") &&
|
||||||
!Token::Match(tok2->linkAt(-1)->previous(), "if|for|while ("))
|
!Token::Match(tok2->linkAt(-1)->previous(), "if|for|while ("))
|
||||||
break;
|
break;
|
||||||
|
} else if (tok2->str() == "break") {
|
||||||
|
if (settings->debugwarnings)
|
||||||
|
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " stopping on break");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,15 @@ private:
|
||||||
" if (x == 123) {}\n"
|
" if (x == 123) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (debug) ValueFlow bailout: global variable x\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (debug) ValueFlow bailout: global variable x\n", errout.str());
|
||||||
|
|
||||||
|
// bailout: switch
|
||||||
|
bailout("void f(int x, int y) {\n"
|
||||||
|
" switch (y) {\n"
|
||||||
|
" case 1: a=x; break;\n"
|
||||||
|
" case 2: if (x==5) {} break;\n"
|
||||||
|
" };\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:3]: (debug) ValueFlow bailout: variable x stopping on break\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowForLoop() {
|
void valueFlowForLoop() {
|
||||||
|
|
Loading…
Reference in New Issue