Fixed #1498 (false positive: The function 'V<unsigned>::vSet' can be const)

This commit is contained in:
Daniel Marjamäki 2010-03-19 19:34:26 +01:00
parent 0fb680d887
commit f687e85be5
2 changed files with 28 additions and 0 deletions

View File

@ -4373,6 +4373,16 @@ void Tokenizer::unsignedint()
else else
tok->insertToken("int"); tok->insertToken("int");
} }
// simplify template arguments..
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (Token::simpleMatch(tok, "< unsigned >"))
tok->next()->str("int");
else if (Token::Match(tok, "< unsigned %type% >") &&
tok->tokAt(2)->isStandardType())
tok->deleteNext();
}
} }

View File

@ -179,6 +179,8 @@ private:
// unsigned i; => unsigned int i; // unsigned i; => unsigned int i;
TEST_CASE(unsigned1); TEST_CASE(unsigned1);
TEST_CASE(unsigned2); TEST_CASE(unsigned2);
TEST_CASE(unsigned3); // template arguments
TEST_CASE(testUpdateClassList); TEST_CASE(testUpdateClassList);
TEST_CASE(createLinks); TEST_CASE(createLinks);
TEST_CASE(signed1); TEST_CASE(signed1);
@ -2741,6 +2743,22 @@ private:
ASSERT_EQUALS(expected, tokenizeAndStringify(code)); ASSERT_EQUALS(expected, tokenizeAndStringify(code));
} }
// simplify "unsigned" when using templates..
void unsigned3()
{
{
const char code[] = "; foo<unsigned>();";
const char expected[] = "; foo<int> ( ) ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
{
const char code[] = "; foo<unsigned int>();";
const char expected[] = "; foo<int> ( ) ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}
}
void tokenizeAndUpdateClassList(const char code[]) void tokenizeAndUpdateClassList(const char code[])
{ {
// tokenize.. // tokenize..