Ticket #6181: Properly handle >> terminating template parameter lists.

This commit is contained in:
Simon Martin 2014-12-14 14:58:54 +01:00
parent 6b78ae7c46
commit 4c7a8c5497
2 changed files with 11 additions and 1 deletions

View File

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

View File

@ -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<int> 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 T> class Disposer; "
"template <typename T, class D = Disposer<T>> class Shim {}; "
"class B : public Shim<A> {};");
}
std::string arraySize_(const std::string &code) {
errout.str("");
Settings settings;