From 859c6381ccfa4ba159580113c203b5af50843a90 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sun, 14 Dec 2014 13:50:32 +0100 Subject: [PATCH] Ticket #6172: Properly grok %type%... template parameters. --- lib/templatesimplifier.cpp | 4 ++-- test/testsimplifytemplate.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 8a79b84aa..1f4b35af9 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...' and 'class...' (Ticket #5774, #6059) - if (Token::Match(tok, "typename|class . . .")) { + // Skip variadic types (Ticket #5774, #6059, #6172) + if (Token::Match(tok, "%type% . . .")) { tok = tok->tokAt(4); continue; } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index dcd21fa94..9e858c991 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -85,6 +85,7 @@ private: TEST_CASE(template48); // #6134 - 100% CPU upon invalid code TEST_CASE(template49); // #6237 - template instantiation TEST_CASE(template50); // #4272 - simple partial specialization + TEST_CASE(template51); // #6172 - crash upon valid code TEST_CASE(template_unhandled); TEST_CASE(template_default_parameter); TEST_CASE(template_default_type); @@ -917,7 +918,16 @@ private: ASSERT_EQUALS(expected, tok(code)); } - + void template51() { // #6172 + tok("template struct A { " + " static void foo() { " + " int i = N; " + " } " + "}; " + "void bar() { " + " A<0>::foo(); " + "}"); + } void template_default_parameter() { {