Merge pull request #484 from simartin/ticket_6181

Ticket #6181: Properly handle >> terminating template parameter lists.
This commit is contained in:
PKEuS 2014-12-21 12:21:17 +01:00
commit e03f49360f
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;