Fix #9483 (Assertion `tok && tok->str() == ">"' failed) (#2381)

This commit is contained in:
IOBYTE 2019-11-20 01:02:25 -05:00 committed by Daniel Marjamäki
parent f6a2034a4c
commit 590aeea8f8
2 changed files with 8 additions and 1 deletions

View File

@ -246,7 +246,7 @@ void TemplateSimplifier::fixAngleBrackets()
}
} else if (Token::Match(tok, "class|struct|union|=|:|public|protected|private %name% <")) {
Token *endTok = tok->tokAt(2)->findClosingBracket();
if (Token::Match(endTok, ">> ;|{")) {
if (Token::Match(endTok, ">> ;|{|%type%")) {
endTok->str(">");
endTok->insertToken(">");
}

View File

@ -190,6 +190,7 @@ private:
TEST_CASE(template150); // syntax error
TEST_CASE(template151); // crash
TEST_CASE(template152); // #9467
TEST_CASE(template153); // #9483
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
@ -3652,6 +3653,12 @@ private:
ASSERT_EQUALS(exp, tok(code));
}
void template153() { // #9483
const char code[] = "template <class = b<decltype(a<h>())...>> void i();";
const char exp[] = "template < class = b < decltype ( a < h > ( ) ) ... > > void i ( ) ;";
ASSERT_EQUALS(exp, tok(code));
}
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
const char code[] = "template <typename T> struct C {};\n"
"template <typename T> struct S {a};\n"