From a1d9873558cd04a000efb51aa665d6cf2ec555e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 14 Feb 2014 06:30:51 +0100 Subject: [PATCH] Fixed #5465 (crash: AST doesnt produce good output for 'class C:public ::a::b{..};') --- lib/tokenlist.cpp | 3 ++- test/testtokenize.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 6879086af..b45060764 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -443,7 +443,8 @@ static void compileTerm(Token *& tok, std::stack &op) } else if (tok->next() && tok->next()->str() == "<" && tok->next()->link() && !templatefunc) { op.push(tok); tok = tok->next()->link()->next(); - compileTerm(tok,op); + if (!Token::simpleMatch(tok, "{")) + compileTerm(tok,op); } else if (!Token::Match(tok->next(), "(|[") && !templatefunc) { op.push(tok); tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a2b93c4ee..07bd2862b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -10061,7 +10061,8 @@ private: static std::string testAst(const char code[]) { // tokenize given code.. - TokenList tokenList(NULL); + const Settings settings; + TokenList tokenList(&settings); std::istringstream istr(code); if (!tokenList.createTokens(istr,"test.cpp")) return "ERROR"; @@ -10193,6 +10194,8 @@ private: testAst("extern int for_each_commit_graft(int (*)(int*), void *);"); // don't crash testAst("for (;;) {}"); // don't crash ASSERT_EQUALS("xsizeofvoid(=", testAst("x=sizeof(void*)")); + + ASSERT_EQUALS("publica::b::", testAst("class C : public ::a::b { };")); } void asttemplate() const { // uninstantiated templates will have <,>,etc..