Skip to content

Commit 5770110

Browse files
Fixed #10432 (Only the first default argument was copied from the forward declaration;) (#3530)
Co-authored-by: Stefan van Kessel <stefan.vankessel@muehlbauer.de>
1 parent 2bf7294 commit 5770110

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

lib/templatesimplifier.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,6 @@ void TemplateSimplifier::fixForwardDeclaredDefaultArgumentValues()
34663466
}
34673467
if (end)
34683468
TokenList::copyTokens(const_cast<Token *>(params2[k]), params1[k]->next(), end->previous());
3469-
break;
34703469
}
34713470
}
34723471

test/testsimplifytemplate.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,6 +4729,26 @@ class TestSimplifyTemplate : public TestFixture {
47294729

47304730
ASSERT_EQUALS(exp, tok(code));
47314731
}
4732+
{ // #10432
4733+
const char code[] = "template<int A = 128, class T = wchar_t>\n"
4734+
"class Foo;\n"
4735+
"template<int A, class T>\n"
4736+
"class Foo\n"
4737+
"{\n"
4738+
"public:\n"
4739+
" T operator[](int Index) const;\n"
4740+
"};\n"
4741+
"template<int A, class T>\n"
4742+
"T Foo<A, T>::operator[](int Index) const\n"
4743+
"{\n"
4744+
" return T{};\n"
4745+
"}\n"
4746+
"Foo<> f;";
4747+
const char exp[] = "class Foo<128,wchar_t> ; Foo<128,wchar_t> f ; "
4748+
"class Foo<128,wchar_t> { public: wchar_t operator[] ( int Index ) const ; } ; "
4749+
"wchar_t Foo<128,wchar_t> :: operator[] ( int Index ) const { return wchar_t { } ; }";
4750+
ASSERT_EQUALS(exp, tok(code));
4751+
}
47324752
}
47334753

47344754
void template_default_type() {

0 commit comments

Comments
 (0)