Skip to content

Commit 415be9c

Browse files
Fix #15192 syntaxError on a pack expansion of decltype in a qualified template default argument followed by >> (#9010)
1 parent 2d3487b commit 415be9c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎lib/templatesimplifier.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
439439
// Skip variadic types (Ticket #5774, #6059, #6172)
440440
if (Token::simpleMatch(tok, "...")) {
441441
if ((tok->previous()->isName() && !Token::Match(tok->tokAt(-2), "<|,|::")) ||
442-
(!tok->previous()->isName() && !Token::Match(tok->previous(), ">|&|&&|*")))
442+
(!tok->previous()->isName() && !Token::Match(tok->previous(), ">|&|&&|*|)")))
443443
return 0; // syntax error
444444
tok = tok->next();
445445
if (!tok)

‎test/testtokenize.cpp‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4697,6 +4697,23 @@ class TestTokenizer : public TestFixture {
46974697
tokenizeAndStringify(code));
46984698
ASSERT_EQUALS("", errout_str());
46994699
}
4700+
{
4701+
const char code[] = "namespace N {\n" // #15192
4702+
" template <typename... Ts>\n"
4703+
" struct S {};\n"
4704+
"}\n"
4705+
"template <typename... Ts, typename = N::S<decltype(Ts())...>>\n"
4706+
"void f() {}\n";
4707+
ASSERT_EQUALS("namespace N {\n"
4708+
"template < typename ... Ts >\n"
4709+
"struct S { } ;\n"
4710+
"}\n"
4711+
"template < typename ... Ts , typename = N :: S < decltype ( Ts ( ) ) ... > >\n"
4712+
"void f ( ) { }",
4713+
tokenizeAndStringify(code));
4714+
ASSERT_EQUALS("", errout_str());
4715+
}
4716+
47004717
}
47014718

47024719
void cpp03template1() {

0 commit comments

Comments
 (0)