parent
38d45c1b9c
commit
9d51b4450b
|
@ -127,8 +127,8 @@ private:
|
|||
TEST_CASE(duplicateConditionalAssign);
|
||||
|
||||
TEST_CASE(checkAssignmentInCondition);
|
||||
|
||||
TEST_CASE(compareOutOfTypeRange);
|
||||
TEST_CASE(knownConditionCast); // #9976
|
||||
}
|
||||
|
||||
void check(const char code[], Settings *settings, const char* filename = "test.cpp") {
|
||||
|
@ -4335,6 +4335,13 @@ private:
|
|||
"}", &settingsUnix64);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void knownConditionCast() { // #9976
|
||||
check("void f(int i) {\n"
|
||||
" if (i < 0 || (unsigned)i > 5) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestCondition)
|
||||
|
|
|
@ -255,6 +255,8 @@ private:
|
|||
TEST_CASE(sameExpressionPointers);
|
||||
|
||||
TEST_CASE(checkOverlappingWrite);
|
||||
|
||||
TEST_CASE(constVariableArrayMember); // #10371
|
||||
}
|
||||
|
||||
void check(const char code[], const char *filename = nullptr, bool experimental = false, bool inconclusive = true, bool runSimpleChecks=true, bool verbose=false, Settings* settings = nullptr) {
|
||||
|
@ -9489,6 +9491,16 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Overlapping read/write in strcpy() is undefined behavior\n", errout.str());
|
||||
}
|
||||
|
||||
void constVariableArrayMember() { // #10371
|
||||
check("class Foo {\n"
|
||||
"public:\n"
|
||||
" Foo();\n"
|
||||
" int GetVal() const { return m_Arr[0]; }\n"
|
||||
" int m_Arr[1];\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestOther)
|
||||
|
|
Loading…
Reference in New Issue