diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index b3ec12591..b8cde1f38 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5235,11 +5235,9 @@ static void valueFlowConditionExpressions(TokenList &tokenlist, const SymbolData { for (const Scope * scope : symboldatabase.functionScopes) { if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) { - if (incompleteTok->isIncompleteVar()) { - if (settings.debugwarnings) - bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str()); - break; - } + if (settings.debugwarnings) + bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str()); + break; } for (Token* tok = const_cast(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { diff --git a/test/cli/test-other.py b/test/cli/test-other.py index b5fbccb9f..1db9aa27f 100644 --- a/test/cli/test-other.py +++ b/test/cli/test-other.py @@ -169,6 +169,18 @@ def test_slow_array_many_strings(tmpdir): 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): test_file = os.path.join(tmpdir, 'test.cpp') with open(test_file, 'wt') as f: @@ -219,4 +231,4 @@ void f() { args = [test_file] _, _, stderr = cppcheck(args) - assert stderr == '{}:0:0: error: Bailing from out analysis: Checking file failed: converting \'1f\' to integer failed - not an integer [internalError]\n\n^\n'.format(test_file) \ No newline at end of file + assert stderr == '{}:0:0: error: Bailing from out analysis: Checking file failed: converting \'1f\' to integer failed - not an integer [internalError]\n\n^\n'.format(test_file)