From e30852200efbc8ae71c32e548992e4f055dd530f Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Fri, 29 Apr 2011 09:19:22 -0400 Subject: [PATCH] fix tokenizer bug where 'class B : private ::A { };' was tokenized to 'class B : private: : A { } ;' --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 2152927ba..88699caf4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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") { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d23e5c63e..4e85e9268 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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() { {