Add test for simplecpp#314 (#5438)
This commit is contained in:
parent
e6632d93e3
commit
775af5ec70
|
@ -5235,12 +5235,10 @@ static void valueFlowConditionExpressions(TokenList &tokenlist, const SymbolData
|
||||||
{
|
{
|
||||||
for (const Scope * scope : symboldatabase.functionScopes) {
|
for (const Scope * scope : symboldatabase.functionScopes) {
|
||||||
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
|
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
|
||||||
if (incompleteTok->isIncompleteVar()) {
|
|
||||||
if (settings.debugwarnings)
|
if (settings.debugwarnings)
|
||||||
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str());
|
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
if (!Token::simpleMatch(tok, "if ("))
|
if (!Token::simpleMatch(tok, "if ("))
|
||||||
|
|
|
@ -169,6 +169,18 @@ def test_slow_array_many_strings(tmpdir):
|
||||||
cppcheck([filename]) # should not take more than ~1 second
|
cppcheck([filename]) # should not take more than ~1 second
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.timeout(10)
|
||||||
|
def test_slow_long_line(tmpdir):
|
||||||
|
# simplecpp #314
|
||||||
|
filename = os.path.join(tmpdir, 'hang.c')
|
||||||
|
with open(filename, 'wt') as f:
|
||||||
|
f.write("#define A() static const int a[] = {\\\n")
|
||||||
|
for i in range(5000):
|
||||||
|
f.write(" -123, 456, -789,\\\n")
|
||||||
|
f.write("};\n")
|
||||||
|
cppcheck([filename]) # should not take more than ~1 second
|
||||||
|
|
||||||
|
|
||||||
def test_execute_addon_failure(tmpdir):
|
def test_execute_addon_failure(tmpdir):
|
||||||
test_file = os.path.join(tmpdir, 'test.cpp')
|
test_file = os.path.join(tmpdir, 'test.cpp')
|
||||||
with open(test_file, 'wt') as f:
|
with open(test_file, 'wt') as f:
|
||||||
|
|
Loading…
Reference in New Issue