value flow: fixed fp in switch

This commit is contained in:
Daniel Marjamäki 2014-01-11 21:21:00 +01:00
parent 3625d179e5
commit f58e1ab80e
2 changed files with 13 additions and 0 deletions

View File

@ -245,6 +245,10 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
if (Token::Match(tok2->previous(), ") {") &&
!Token::Match(tok2->linkAt(-1)->previous(), "if|for|while ("))
break;
} else if (tok2->str() == "break") {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " stopping on break");
break;
}
}
}

View File

@ -210,6 +210,15 @@ private:
" if (x == 123) {}\n"
"}");
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() {