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; ++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;