This commit is contained in:
chrchr-github 2022-07-30 16:15:32 +02:00 committed by GitHub
parent 36d98a8b5a
commit c878285a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -1830,6 +1830,16 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f() { throw(1); }\n"); // #8958
ASSERT_EQUALS("", errout.str());
check("class C {\n" // #9002
"public:\n"
" static int f() { return 1; }\n"
"};\n"
"void g() { C::f(); }\n");
ASSERT_EQUALS("", errout.str());
settings.severity = severity_old;
settings.checkLibrary = false;
}

View File

@ -896,6 +896,11 @@ private:
" s[x*s.size()] = 1;\n"
"}");
ASSERT_EQUALS("test.cpp:2:error:Out of bounds access of s, index 'x*s.size()' is out of bounds.\n", errout.str());
checkNormal("bool f(std::string_view& sv) {\n" // #10031
" return sv[sv.size()] == '\\0';\n"
"}\n");
ASSERT_EQUALS("test.cpp:2:error:Out of bounds access of sv, index 'sv.size()' is out of bounds.\n", errout.str());
}
void outOfBoundsIterator() {
check("int f() {\n"
@ -1575,6 +1580,17 @@ private:
ASSERT_EQUALS(
"[test.cpp:6] -> [test.cpp:6]: (error) Same iterator is used with containers 'g()' that are temporaries or defined in different scopes.\n",
errout.str());
check("std::set<long> f() {\n" // #5804
" std::set<long> s;\n"
" return s;\n"
"}\n"
"void g() {\n"
" for (std::set<long>::iterator it = f().begin(); it != f().end(); ++it) {}\n"
"}\n");
ASSERT_EQUALS(
"[test.cpp:6] -> [test.cpp:6]: (error) Same iterator is used with containers 'f()' that are temporaries or defined in different scopes.\n",
errout.str());
}
void iterator20() {