Fix up a few more cases where templates ending in ">>" should be changed to end in "> >". (#1883)

This commit is contained in:
IOBYTE 2019-06-13 07:37:55 -04:00 committed by Daniel Marjamäki
parent 2a4b28c267
commit c0d8990e8b
2 changed files with 35 additions and 0 deletions

View File

@ -2825,6 +2825,12 @@ void Tokenizer::simplifyTemplates()
endTok->str(">");
endTok->insertToken(">");
}
} else if (Token::Match(tok, "class|struct|union|=|:|public|protected|private %name% <")) {
Token *endTok = tok->tokAt(2)->findClosingBracket();
if (Token::Match(endTok, ">> ;|{")) {
endTok->str(">");
endTok->insertToken(">");
}
}
}

View File

@ -343,6 +343,7 @@ private:
TEST_CASE(cpp0xtemplate2);
TEST_CASE(cpp0xtemplate3);
TEST_CASE(cpp0xtemplate4); // Ticket #6181: Mishandled C++11 syntax
TEST_CASE(cpp0xtemplate5); // Ticket #9154 change >> to > >
TEST_CASE(cpp14template); // Ticket #6708
TEST_CASE(arraySize);
@ -5266,6 +5267,34 @@ private:
"}");
}
void cpp0xtemplate5() { // #9154
{
const char *code = "struct s<x<u...>>;";
ASSERT_EQUALS("struct s < x < u . . . > > ;",
tokenizeAndStringify(code));
}
{
const char *code = "template <class f> using c = e<i<q<f,r>,b...>>;";
ASSERT_EQUALS("template < class f > using c = e < i < q < f , r > , b . . . > > ;",
tokenizeAndStringify(code));
}
{
const char *code = "struct s<x<u...>> { };";
ASSERT_EQUALS("struct s < x < u . . . > > { } ;",
tokenizeAndStringify(code));
}
{
const char *code = "struct q : s<x<u...>> { };";
ASSERT_EQUALS("struct q : s < x < u . . . > > { } ;",
tokenizeAndStringify(code));
}
{
const char *code = "struct q : private s<x<u...>> { };";
ASSERT_EQUALS("struct q : private s < x < u . . . > > { } ;",
tokenizeAndStringify(code));
}
}
void cpp14template() { // Ticket #6708
tokenizeAndStringify("template <typename T> "
"decltype(auto) forward(T& t) { return 0; }");