value flow: fix fp when gotos are used
This commit is contained in:
parent
bfc67a536a
commit
7981e3d38f
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue