fix tokenizer bug where 'class B : private ::A { };' was tokenized to 'class B : private: : A { } ;'

This commit is contained in:
Robert Reif 2011-04-29 09:19:22 -04:00
parent bd03768415
commit e30852200e
2 changed files with 7 additions and 1 deletions

View File

@ -2148,7 +2148,7 @@ bool Tokenizer::tokenize(std::istream &code,
tok->deleteNext();
}
else if ((c1 == 'p' || c1 == '_') && tok->next()->str() == ":")
else if ((c1 == 'p' || c1 == '_') && tok->next()->str() == ":" && tok->strAt(2) != ":")
{
if (tok->str() == "private" || tok->str() == "protected" || tok->str() == "public" || tok->str() == "__published")
{

View File

@ -50,6 +50,7 @@ private:
TEST_CASE(tokenize14); // tokenize "0X10" => 16
TEST_CASE(tokenize15); // tokenize ".123"
TEST_CASE(tokenize16); // #2612 - segfault for "<><<"
TEST_CASE(tokenize17); // #2759
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -541,6 +542,11 @@ private:
tokenizeAndStringify("<><<");
}
void tokenize17() // #2759
{
ASSERT_EQUALS("class B : private :: A { } ;", tokenizeAndStringify("class B : private ::A { };"));
}
void wrong_syntax()
{
{