diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 421334599..136d311b2 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -738,16 +738,16 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco std::list::const_iterator var; for (var = type->varlist.begin(); var != type->varlist.end(); ++var) { - // don't warn if variable static or const - if (!var->isStatic() && !var->isConst()) { + // don't warn if variable static or const, pointer or referece + if (!var->isStatic() && !var->isConst() && !var->isPointer() && !var->isReference()) { const Token *tok1 = var->typeStartToken(); - // check for std:: type that is not a pointer or reference - if (Token::simpleMatch(tok1, "std ::") && !Token::Match(var->nameToken()->previous(), "*|&")) + // check for std:: type + if (Token::simpleMatch(tok1, "std ::")) memsetError(tok, tok->str(), "'std::" + tok1->strAt(2) + "'", type->classDef->str()); - // check for known type that is not a pointer or reference - else if (var->type() && !Token::Match(var->nameToken()->previous(), "*|&")) + // check for known type + else if (var->type()) checkMemsetType(start, tok, var->type()); } } diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index f2c88906f..3435f56d2 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -102,13 +102,11 @@ void CheckStl::iterators() // report an error if (container && tok2->varId() != container->varId()) { // skip error message if container is a set.. - if (tok2->varId() > 0) { - const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId()); - const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL; + const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId()); + const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL; - if (Token::Match(decltok, "const| std :: set")) - continue; // No warning - } + if (Token::Match(decltok, "const| std :: set")) + continue; // No warning // skip error message if the iterator is erased/inserted by value if (itTok->previous()->str() == "*")