Tokenizer::setVarId : don't give operator function variable id 'operator new []('. Ticket: #1997

This commit is contained in:
Daniel Marjamäki 2010-08-31 20:15:24 +02:00
parent fbe11b9bb9
commit 513826d8c2
2 changed files with 30 additions and 15 deletions

View File

@ -3034,6 +3034,9 @@ void Tokenizer::setVarId()
if (varname == "operator" && Token::Match(tok2, "=|+|-|*|/|[| ]| ("))
continue;
if (varname == "new" && Token::Match(tok2->tokAt(-2), "operator new (|["))
continue;
// Is it a function?
if (tok2->str() == "(")
{

View File

@ -2450,10 +2450,8 @@ private:
void varid26()
{
const std::string code("list<int (*)()> functions;\n");
const std::string expected("\n\n##file 0\n"
"1: list < int ( * ) ( ) > functions@1 ;\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
@ -2685,21 +2683,35 @@ private:
void varid_operator()
{
const std::string actual = tokenizeDebugListing(
"class Foo\n"
"{\n"
"public:\n"
" void operator=(const Foo &);\n"
"};\n");
{
const std::string actual = tokenizeDebugListing(
"class Foo\n"
"{\n"
"public:\n"
" void operator=(const Foo &);\n"
"};\n");
const std::string expected("\n\n##file 0\n"
"1: class Foo\n"
"2: {\n"
"3: public:\n"
"4: void operator = ( const Foo & ) ;\n"
"5: } ;\n");
const std::string expected("\n\n##file 0\n"
"1: class Foo\n"
"2: {\n"
"3: public:\n"
"4: void operator = ( const Foo & ) ;\n"
"5: } ;\n");
ASSERT_EQUALS(expected, actual);
ASSERT_EQUALS(expected, actual);
}
{
const std::string actual = tokenizeDebugListing(
"struct Foo {\n"
" void * operator new [](int);\n"
"};\n");
const std::string expected("\n\n##file 0\n"
"1: struct Foo {\n"
"2: void * operator new [ ] ( int ) ;\n"
"3: } ;\n");
ASSERT_EQUALS(expected, actual);
}
}
void varid_throw() // ticket #1723