Fixed #5403 (Value flow: FP because post increment/decrement is not handled correctly)

This commit is contained in:
Daniel Marjamäki 2014-01-25 18:31:02 +01:00
parent bc9ad08831
commit df0995edf5
2 changed files with 8 additions and 1 deletions

View File

@ -526,7 +526,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger,
}
// bailout increment/decrement for now..
if (Token::Match(tok2->previous(), "++|-- %var%") || Token::Match(tok, "%var% ++|--")) {
if (Token::Match(tok2->previous(), "++|-- %var%") || Token::Match(tok2, "%var% ++|--")) {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "increment/decrement of " + tok2->str());
break;

View File

@ -491,6 +491,13 @@ private:
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 9));
code = "void f() {\n"
" static int x = 2;\n"
" x++;\n"
" return x;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 2));
// function
code = "void f() {\n"
" char *x = 0;\n"