value flow: fix fp when gotos are used

This commit is contained in:
Daniel Marjamäki 2014-01-13 16:07:25 +01:00
parent bfc67a536a
commit 7981e3d38f
2 changed files with 16 additions and 0 deletions

View File

@ -296,6 +296,13 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
break;
}
}
// goto label
if (Token::Match(tok2, "[;{}] %var% :")) {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " stopping on goto label");
break;
}
}
}
}

View File

@ -272,6 +272,15 @@ private:
" $if ($x==$123){}\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (debug) ValueFlow bailout: variable x, condition is defined in macro\n", errout.str());
// bailout: goto label (TODO: handle gotos more intelligently)
bailout("void f(int x) {\n"
" if (x == 123) { goto out; }\n"
" a=x;\n" // <- x is not 123
"out:"
" if (x==123){}\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (debug) ValueFlow bailout: variable x stopping on goto label\n", errout.str());
}
void valueFlowForLoop() {