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; ++indentlevel5;
else if (indentlevel5 > 0 && Token::Match(tok5, "> [,>]")) else if (indentlevel5 > 0 && Token::Match(tok5, "> [,>]"))
--indentlevel5; --indentlevel5;
else if (indentlevel5 > 0 && tok5->str() == ">>")
indentlevel5 -= 2;
else if (indentlevel5 == 0) { else if (indentlevel5 == 0) {
if (tok5->str() != ",") { if (tok5->str() != ",") {
if (!typetok || if (!typetok ||

View File

@ -338,6 +338,7 @@ private:
TEST_CASE(cpp0xtemplate1); TEST_CASE(cpp0xtemplate1);
TEST_CASE(cpp0xtemplate2); TEST_CASE(cpp0xtemplate2);
TEST_CASE(cpp0xtemplate3); TEST_CASE(cpp0xtemplate3);
TEST_CASE(cpp0xtemplate4); // Ticket #6181: Mishandled C++11 syntax
TEST_CASE(arraySize); TEST_CASE(arraySize);
@ -826,7 +827,7 @@ private:
"void z() {\n" "void z() {\n"
" vector<int> VI;\n" " vector<int> VI;\n"
"}\n"; "}\n";
ASSERT_THROW(tokenizeAndStringify(code, true), InternalError); tokenizeAndStringify(code, true);
} }
void tokenize34() { // #6121 void tokenize34() { // #6121
@ -5207,6 +5208,13 @@ private:
tokenizeAndStringify(code)); 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) { std::string arraySize_(const std::string &code) {
errout.str(""); errout.str("");
Settings settings; Settings settings;