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..