Fixed #10432 (Only the first default argument was copied from the forward declaration;) (#3530)

Co-authored-by: Stefan van Kessel <stefan.vankessel@muehlbauer.de>
This commit is contained in:
Stefan van Kessel 2021-11-15 20:37:46 +01:00 committed by GitHub
parent 2bf7294d5b
commit 5770110377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -3466,7 +3466,6 @@ void TemplateSimplifier::fixForwardDeclaredDefaultArgumentValues()
}
if (end)
TokenList::copyTokens(const_cast<Token *>(params2[k]), params1[k]->next(), end->previous());
break;
}
}

View File

@ -4729,6 +4729,26 @@ private:
ASSERT_EQUALS(exp, tok(code));
}
{ // #10432
const char code[] = "template<int A = 128, class T = wchar_t>\n"
"class Foo;\n"
"template<int A, class T>\n"
"class Foo\n"
"{\n"
"public:\n"
" T operator[](int Index) const;\n"
"};\n"
"template<int A, class T>\n"
"T Foo<A, T>::operator[](int Index) const\n"
"{\n"
" return T{};\n"
"}\n"
"Foo<> f;";
const char exp[] = "class Foo<128,wchar_t> ; Foo<128,wchar_t> f ; "
"class Foo<128,wchar_t> { public: wchar_t operator[] ( int Index ) const ; } ; "
"wchar_t Foo<128,wchar_t> :: operator[] ( int Index ) const { return wchar_t { } ; }";
ASSERT_EQUALS(exp, tok(code));
}
}
void template_default_type() {