diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 9e6b70968..8a79b84aa 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -240,8 +240,8 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) if (Token::Match(tok, "& ::| %var%")) tok = tok->next(); - // Skip 'typename...' (Ticket #5774) - if (Token::simpleMatch(tok, "typename . . .")) { + // Skip 'typename...' and 'class...' (Ticket #5774, #6059) + if (Token::Match(tok, "typename|class . . .")) { tok = tok->tokAt(4); continue; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a4fc9cd8a..97f864e35 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4410,7 +4410,7 @@ private: tokenizer.tokenize(istr, "test.cpp"); // shouldn't segfault } - void syntax_error_templates_3() { // Ticket #5605, #5759, #5762, #5774, #5823 + void syntax_error_templates_3() { // Ticket #5605, #5759, #5762, #5774, #5823, #6059 tokenizeAndStringify("foo() template struct tuple Args> tuple { } main() { foo(); }"); tokenizeAndStringify("( ) template < T1 = typename = unused> struct Args { } main ( ) { foo < int > ( ) ; }"); tokenizeAndStringify("() template < T = typename = x > struct a {} { f () }"); @@ -4432,6 +4432,10 @@ private: " C() : _a(0), _b(0) {} " " int _a, _b; " "};"); + tokenizeAndStringify("template struct A { " + " static int i; " + "}; " + "void f() { A::i = 0; }"); } void template_member_ptr() { // Ticket #5786