Skip to content

Commit d95f3bc

Browse files
Update testvalueflow.cpp
1 parent 8e62a24 commit d95f3bc

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/testvalueflow.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5635,6 +5635,28 @@ class TestValueFlow : public TestFixture {
56355635
value = valueOfTok(code, ", 1");
56365636
ASSERT_EQUALS(0, value.intvalue);
56375637
ASSERT_EQUALS(false, value.isKnown());
5638+
5639+
// #13959
5640+
const Settings settingsOld = settings;
5641+
settings = settingsBuilder(settingsOld).c(Standards::C23).build();
5642+
code = "void f(int* p) {\n" // #11894
5643+
" if (p == nullptr)\n"
5644+
" return;\n"
5645+
" if (p) {}\n"
5646+
"}\n";
5647+
value = valueOfTok(code, "p ) { }", &settings, /*cpp*/ false);
5648+
ASSERT_EQUALS(1, value.intvalue);
5649+
ASSERT_EQUALS(true, value.isKnown());
5650+
5651+
settings = settingsBuilder(settingsOld).c(Standards::C17).build();
5652+
code = "void f(int* p) {\n" // #11894
5653+
" if (p == nullptr)\n"
5654+
" return;\n"
5655+
" if (p) {}\n"
5656+
"}\n";
5657+
value = valueOfTok(code, "p ) { }", &settings, /*cpp*/ false);
5658+
ASSERT(value == ValueFlow::Value());
5659+
settings = settingsOld;
56385660
}
56395661

56405662
void valueFlowSizeofForwardDeclaredEnum() {

0 commit comments

Comments
 (0)