Add test cases, todos for #9790, #10358, #10462 (#3564)

* Add test cases, todos

* Format

* Remove dupes

* Format
This commit is contained in:
chrchr-github 2021-11-23 23:07:15 +01:00 committed by GitHub
parent 5b52f4946a
commit ed050659a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -234,6 +234,11 @@ private:
" assert(sizeof(struct { int a[x++]; })==sizeof(int));\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void foo() {\n" // #9790
" assert(kad_bucket_hash(&(kad_guid) { .bytes = { 0 } }, & (kad_guid){.bytes = { 0 }}) == -1);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};

View File

@ -4444,6 +4444,22 @@ private:
ASSERT(value.isKnown());
ASSERT_EQUALS(1, value.intvalue);
code = "bool f() {\n"
" const int s = int{};"
" return s == 0;\n" // <- known value
"}";
value = valueOfTok(code, "==");
TODO_ASSERT_EQUALS(true, false, value.isKnown());
TODO_ASSERT_EQUALS(1, 0, value.intvalue);
code = "bool f() {\n"
" const int s = int();"
" return s == 0;\n" // <- known value
"}";
value = valueOfTok(code, "==");
TODO_ASSERT_EQUALS(true, false, value.isKnown());
TODO_ASSERT_EQUALS(1, 0, value.intvalue);
// calculation with known result
code = "int f(int x) { a = x & 0; }"; // <- & is 0
value = valueOfTok(code, "&");
@ -6075,6 +6091,13 @@ private:
" diff = (buf-b);\n"
"}\n";
valueOfTok(code, "diff");
code = "void foo() {\n" // #10462
" std::tuple<float, float, float, float> t4(5.2f, 3.1f, 2.4f, 9.1f), t5(4, 6, 9, 27);\n"
" t4 = t5;\n"
" ASSERT(!(t4 < t5) && t4 <= t5);\n"
"}";
valueOfTok(code, "<=");
}
void valueFlowHang() {