From 4c7a8c5497f00d7ffd9def6016fbbe1e09fbcf97 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sun, 14 Dec 2014 14:58:54 +0100 Subject: [PATCH] Ticket #6181: Properly handle >> terminating template parameter lists. --- lib/templatesimplifier.cpp | 2 ++ test/testtokenize.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 8a79b84aa..500648de7 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -1315,6 +1315,8 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( ++indentlevel5; else if (indentlevel5 > 0 && Token::Match(tok5, "> [,>]")) --indentlevel5; + else if (indentlevel5 > 0 && tok5->str() == ">>") + indentlevel5 -= 2; else if (indentlevel5 == 0) { if (tok5->str() != ",") { if (!typetok || diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index fe16099c6..3ea94d15a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -338,6 +338,7 @@ private: TEST_CASE(cpp0xtemplate1); TEST_CASE(cpp0xtemplate2); TEST_CASE(cpp0xtemplate3); + TEST_CASE(cpp0xtemplate4); // Ticket #6181: Mishandled C++11 syntax TEST_CASE(arraySize); @@ -826,7 +827,7 @@ private: "void z() {\n" " vector VI;\n" "}\n"; - ASSERT_THROW(tokenizeAndStringify(code, true), InternalError); + tokenizeAndStringify(code, true); } void tokenize34() { // #6121 @@ -5207,6 +5208,13 @@ private: tokenizeAndStringify(code)); } + void cpp0xtemplate4() { // #6181 + tokenizeAndStringify("class A; " + "template class Disposer; " + "template > class Shim {}; " + "class B : public Shim {};"); + } + std::string arraySize_(const std::string &code) { errout.str(""); Settings settings;