This commit is contained in:
parent
9a290c959f
commit
7075b6e61d
|
@ -2059,6 +2059,8 @@ void TemplateSimplifier::expandTemplate(
|
|||
Token * const beforeTypeToken = mTokenList.back();
|
||||
bool pointerType = false;
|
||||
const bool isVariadicTemplateArg = templateDeclaration.isVariadic() && itype + 1 == typeParametersInDeclaration.size();
|
||||
if (isVariadicTemplateArg && mTypesUsedInTemplateInstantiation.size() > 1 && !Token::simpleMatch(tok3->next(), "..."))
|
||||
continue;
|
||||
if (isVariadicTemplateArg && Token::Match(tok3, "%name% ... %name%"))
|
||||
tok3 = tok3->tokAt(2);
|
||||
const std::string endStr(isVariadicTemplateArg ? ">" : ",>");
|
||||
|
|
|
@ -279,6 +279,7 @@ private:
|
|||
TEST_CASE(template_variadic_1); // #9144
|
||||
TEST_CASE(template_variadic_2); // #4349
|
||||
TEST_CASE(template_variadic_3); // #6172
|
||||
TEST_CASE(template_variadic_4);
|
||||
|
||||
TEST_CASE(template_variable_1);
|
||||
TEST_CASE(template_variable_2);
|
||||
|
@ -6133,6 +6134,25 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void template_variadic_4() { // #11763
|
||||
const char code[] = "template <int... N>\n"
|
||||
"class E {\n"
|
||||
" template <int... I>\n"
|
||||
" int f(int n, std::integer_sequence<int, I...>) {\n"
|
||||
" return (((I == n) ? N : 0) + ...);\n"
|
||||
" }\n"
|
||||
"};\n"
|
||||
"E<1, 3> e;\n";
|
||||
const char expected[] = "class E<1,3> ; E<1,3> e ; "
|
||||
"class E<1,3> { "
|
||||
"template < int ... I > "
|
||||
"int f ( int n , std :: integer_sequence < int , I ... > ) { "
|
||||
"return ( ( ( I == n ) ? : 0 ) + ... ) ; "
|
||||
"} "
|
||||
"} ;";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void template_variable_1() {
|
||||
{
|
||||
const char code[] = "template <int N> const int foo = N*N;\n"
|
||||
|
|
Loading…
Reference in New Issue