From 6fd6f0998bc2348199d9fc2bd7e225f6a2bc4417 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 27 Apr 2012 20:51:55 +0200 Subject: [PATCH] Improvement to 5b8840c6b02bd648dc2b75e60145474ae12f8e67: handle also 'const struct|union' types as template parameters. --- lib/templatesimplifier.cpp | 6 +++++- test/testsimplifytokens.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 817f46967..e19f7fe3c 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -180,8 +180,12 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) if (level == 0) ++numberOfParameters; + // skip const + if (Token::Match(tok, "const %any%")) + tok = tok->next(); + // skip struct/union - if (Token::Match(tok, "struct|union|const %any%")) + if (Token::Match(tok, "struct|union %any%")) tok = tok->next(); // skip std:: diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 95081e678..7d3f9e3e6 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2291,6 +2291,7 @@ private: ASSERT_EQUALS(1U, templateParameters(" x;")); ASSERT_EQUALS(1U, templateParameters(" x;")); ASSERT_EQUALS(1U, templateParameters(" x;")); + ASSERT_EQUALS(1U, templateParameters(" x;")); }