From fbffaade2eae3fcb9d9356f39121613849f1a3d8 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 2 Sep 2010 19:09:06 +0200 Subject: [PATCH] Fixed #2011 (Parser error in template function) --- lib/tokenize.cpp | 5 ++++- test/testsimplifytokens.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e29fee76e..7a58ccb63 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -992,11 +992,14 @@ void Tokenizer::simplifyTypedef() tok = specEnd->next(); } } - else if (Token::Match(tok->tokAt(offset), "( ::| %var% :: *|&| const|volatile| const|volatile| %type% ) (")) + else if (Token::Match(tok->tokAt(offset), "( ::| %var% :: *|&| const|volatile| const|volatile| %type% ) (") || + Token::Match(tok->tokAt(offset), "( ::| %var% < %type% > :: *|&| const|volatile| const|volatile| %type% ) (")) { namespaceStart = tok->tokAt(offset + 1); if (tok->tokAt(offset + 1)->str() == "::") offset++; + if (tok->tokAt(offset + 2)->str() == "<") + offset += 3; namespaceEnd = tok->tokAt(offset + 2); functionPtr = tok->tokAt(offset + 3)->str() == "*"; functionRef = tok->tokAt(offset + 3)->str() == "&"; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 6eba86ee3..9a9cc6647 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -213,6 +213,7 @@ private: TEST_CASE(simplifyTypedef56); // ticket #1829 TEST_CASE(simplifyTypedef57); // ticket #1846 TEST_CASE(simplifyTypedef58); // ticket #1963 + TEST_CASE(simplifyTypedef59); // ticket #2011 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -4374,6 +4375,20 @@ private: } } + void simplifyTypedef59() // ticket #2011 + { + const char code[] = "template class SomeTemplateClass {\n" + " typedef void (SomeTemplateClass::*MessageDispatcherFunc)(SerialInputMessage&);\n" + "};\n"; + // The expected result.. + const std::string expected("; ;"); + ASSERT_EQUALS(expected, sizeof_(code)); + + // Check for output.. + checkSimplifyTypedef(code); + ASSERT_EQUALS("", errout.str()); + } + void simplifyTypedefFunction1() { {