* Add test for #6541, avoid duplicate warning * Add test for #5475 * Fix test * Merge * Add test for #8666 * Fix #11239 checkLibraryCheckType with asm goto() (invalid varid) * Format * Add tests for #1201, #2654 * Fix test * Add test for #6379
This commit is contained in:
parent
441f9b9509
commit
32c7b919ba
|
@ -5395,6 +5395,21 @@ private:
|
||||||
" return p[10];\n"
|
" return p[10];\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("struct X {\n" // #2654
|
||||||
|
" int a;\n"
|
||||||
|
" char b;\n"
|
||||||
|
"};\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" X s;\n"
|
||||||
|
" int* y = &s.a;\n"
|
||||||
|
" (void)y[0];\n"
|
||||||
|
" (void)y[1];\n"
|
||||||
|
" (void)y[2];\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:9]: (error) The address of local variable 'a' is accessed at non-zero index.\n"
|
||||||
|
"[test.cpp:7] -> [test.cpp:10]: (error) The address of local variable 'a' is accessed at non-zero index.\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkPipeParameterSize() { // #3521
|
void checkPipeParameterSize() { // #3521
|
||||||
|
|
|
@ -8382,6 +8382,15 @@ private:
|
||||||
" *reg = 34;\n"
|
" *reg = 34;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("test.cpp:2:style:C-style pointer casting\n", errout.str());
|
ASSERT_EQUALS("test.cpp:2:style:C-style pointer casting\n", errout.str());
|
||||||
|
|
||||||
|
check("void f(std::map<int, int>& m, int key, int value) {\n" // #6379
|
||||||
|
" m[key] = value;\n"
|
||||||
|
" m[key] = value;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("test.cpp:3:style:Variable 'm[key]' is reassigned a value before the old one has been used.\n"
|
||||||
|
"test.cpp:2:note:m[key] is assigned\n"
|
||||||
|
"test.cpp:3:note:m[key] is overwritten\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void redundantVarAssignment_trivial() {
|
void redundantVarAssignment_trivial() {
|
||||||
|
|
|
@ -5871,6 +5871,14 @@ private:
|
||||||
true);
|
true);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Using sort with iterator 'v.begin()' that is always empty.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Using sort with iterator 'v.begin()' that is always empty.\n", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n" // #1201
|
||||||
|
" std::vector<int> v1{ 0, 1 };\n"
|
||||||
|
" std::vector<int> v2;\n"
|
||||||
|
" std::copy(v1.begin(), v1.end(), v2.begin());\n"
|
||||||
|
"}\n",
|
||||||
|
true);
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (style) Using copy with iterator 'v2.begin()' that is always empty.\n", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
" v.insert(v.end(), 1);\n"
|
" v.insert(v.end(), 1);\n"
|
||||||
|
|
Loading…
Reference in New Issue