From 57701103770d343dffd50bda60c160ef2ce77f8a Mon Sep 17 00:00:00 2001 From: Stefan van Kessel Date: Mon, 15 Nov 2021 20:37:46 +0100 Subject: [PATCH] Fixed #10432 (Only the first default argument was copied from the forward declaration;) (#3530) Co-authored-by: Stefan van Kessel --- lib/templatesimplifier.cpp | 1 - test/testsimplifytemplate.cpp | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 19a58e0d8..6fc4eaa84 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3466,7 +3466,6 @@ void TemplateSimplifier::fixForwardDeclaredDefaultArgumentValues() } if (end) TokenList::copyTokens(const_cast(params2[k]), params1[k]->next(), end->previous()); - break; } } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 6597edf1d..40e2903f9 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -4729,6 +4729,26 @@ private: ASSERT_EQUALS(exp, tok(code)); } + { // #10432 + const char code[] = "template\n" + "class Foo;\n" + "template\n" + "class Foo\n" + "{\n" + "public:\n" + " T operator[](int Index) const;\n" + "};\n" + "template\n" + "T Foo::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() {