Fix #10307 FP functionStatic with class template and east-const / #10471 FP constParameter with std::array and east-const (#3963)
This commit is contained in:
parent
ea63b8e2bb
commit
a9f29fbc09
|
@ -4556,7 +4556,7 @@ bool Scope::isVariableDeclaration(const Token* const tok, const Token*& vartok,
|
|||
if (!localVarTok)
|
||||
return false;
|
||||
|
||||
if (localVarTok->str() == "const")
|
||||
while (Token::Match(localVarTok, "const|*|&"))
|
||||
localVarTok = localVarTok->next();
|
||||
|
||||
if (Token::Match(localVarTok, "%name% ;|=") || (localVarTok && localVarTok->varId() && localVarTok->strAt(1) == ":")) {
|
||||
|
@ -6373,7 +6373,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
|||
} else if (const Library::Container *container = settings->library.detectContainer(type)) {
|
||||
valuetype->type = ValueType::Type::CONTAINER;
|
||||
valuetype->container = container;
|
||||
while (Token::Match(type, "%type%|::|<")) {
|
||||
while (Token::Match(type, "%type%|::|<") && type->str() != "const") {
|
||||
if (type->str() == "<" && type->link()) {
|
||||
if (container->type_templateArgNo >= 0) {
|
||||
const Token *templateType = type->next();
|
||||
|
|
|
@ -193,6 +193,7 @@ private:
|
|||
TEST_CASE(const74); // ticket #10671
|
||||
TEST_CASE(const75); // ticket #10065
|
||||
TEST_CASE(const76); // ticket #10825
|
||||
TEST_CASE(const77); // ticket #10307
|
||||
TEST_CASE(const_handleDefaultParameters);
|
||||
TEST_CASE(const_passThisToMemberOfOtherClass);
|
||||
TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
|
||||
|
@ -6031,6 +6032,15 @@ private:
|
|||
errout.str());
|
||||
}
|
||||
|
||||
void const77() { // #10307
|
||||
checkConst("template <typename T>\n"
|
||||
"struct S {\n"
|
||||
" std::vector<T> const* f() const { return p; }\n"
|
||||
" std::vector<T> const* p;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void const_handleDefaultParameters() {
|
||||
checkConst("struct Foo {\n"
|
||||
" void foo1(int i, int j = 0) {\n"
|
||||
|
|
|
@ -2978,6 +2978,12 @@ private:
|
|||
" return *p;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10471
|
||||
check("void f(std::array<int, 1> const& i) {\n"
|
||||
" if (i[0] == 0) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantAssignmentTest() {
|
||||
|
|
Loading…
Reference in New Issue