Value flow: added bailout on }

This commit is contained in:
Daniel Marjamäki 2014-01-06 11:27:56 +01:00
parent 39b47cc1e7
commit 58fb2e756b
2 changed files with 13 additions and 0 deletions

View File

@ -100,6 +100,12 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
if (var && tok2 == var->nameToken())
break;
}
if (tok2->str() == "}") {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "variable " + var->nameToken()->str() + " stopping on }");
break;
}
}
}
}

View File

@ -81,6 +81,13 @@ private:
"}";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
// bailout: if/else/etc
bailout("void f(int x) {\n"
" if (x != 123) { b = x; }\n"
" if (x == 123) {}\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (debug) ValueFlow bailout: variable x stopping on }\n", errout.str());
// bailout: assignment
bailout("void f(int x) {\n"
" x = y;\n"