Skip to content

Commit 775af5e

Browse files
Add test for simplecpp#314 (#5438)
1 parent e6632d9 commit 775af5e

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

lib/valueflow.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5235,11 +5235,9 @@ static void valueFlowConditionExpressions(TokenList &tokenlist, const SymbolData
52355235
{
52365236
for (const Scope * scope : symboldatabase.functionScopes) {
52375237
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
5238-
if (incompleteTok->isIncompleteVar()) {
5239-
if (settings.debugwarnings)
5240-
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str());
5241-
break;
5242-
}
5238+
if (settings.debugwarnings)
5239+
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str());
5240+
break;
52435241
}
52445242

52455243
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {

test/cli/test-other.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ def test_slow_array_many_strings(tmpdir):
169169
cppcheck([filename]) # should not take more than ~1 second
170170

171171

172+
@pytest.mark.timeout(10)
173+
def test_slow_long_line(tmpdir):
174+
# simplecpp #314
175+
filename = os.path.join(tmpdir, 'hang.c')
176+
with open(filename, 'wt') as f:
177+
f.write("#define A() static const int a[] = {\\\n")
178+
for i in range(5000):
179+
f.write(" -123, 456, -789,\\\n")
180+
f.write("};\n")
181+
cppcheck([filename]) # should not take more than ~1 second
182+
183+
172184
def test_execute_addon_failure(tmpdir):
173185
test_file = os.path.join(tmpdir, 'test.cpp')
174186
with open(test_file, 'wt') as f:
@@ -219,4 +231,4 @@ def test_internal_error(tmpdir):
219231
args = [test_file]
220232

221233
_, _, stderr = cppcheck(args)
222-
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)
234+
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)

0 commit comments

Comments
 (0)