Fixed #1612 (false positive: The function can be const)

This commit is contained in:
Robert Reif 2010-04-18 07:53:39 +02:00 committed by Daniel Marjamäki
parent 6db4ab68ef
commit d90f59051c
2 changed files with 20 additions and 0 deletions

View File

@ -2249,6 +2249,12 @@ void Tokenizer::setVarId()
if (Token::Match(tok, "class|struct %type% :|{|;"))
continue;
if (Token::Match(tok, "using namespace %type% ;"))
{
tok = tok->next();
continue;
}
if (Token::Match(tok, "else|return|typedef|delete|sizeof"))
continue;

View File

@ -113,6 +113,7 @@ private:
TEST_CASE(const16); // ticket #1551
TEST_CASE(const17); // ticket #1552
TEST_CASE(const18); // ticket #1563
TEST_CASE(const19); // ticket #1612
TEST_CASE(constoperator1); // operator< can often be const
TEST_CASE(constoperator2); // operator<<
TEST_CASE(constincdec); // increment/decrement => non-const
@ -3217,6 +3218,19 @@ private:
ASSERT_EQUALS("", errout.str());
}
void const19()
{
// ticket #1612
checkConst("using namespace std;\n"
"class Fred {\n"
"private:\n"
" std::string s;\n"
"public:\n"
" void set(std::string ss) { s = ss; }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
// increment/decrement => not const
void constincdec()
{