From 590aeea8f88739132cf6567f9cccfeae1bfba6ad Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Wed, 20 Nov 2019 01:02:25 -0500 Subject: [PATCH] Fix #9483 (Assertion `tok && tok->str() == ">"' failed) (#2381) --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytemplate.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 70dedeb0a..d4e4c22fa 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -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(">"); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index fb2b6d5d4..9fadc6467 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -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 struct S> {..}; TEST_CASE(template_specialization_2); // #7868 - template specialization template struct S> {..}; 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 ())...>> 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 struct S> {..}; const char code[] = "template struct C {};\n" "template struct S {a};\n"