diff options
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/PCH/cxx-variadic-templates-with-default-params.cpp | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 9bcd9a01649..b249da99462 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -3016,6 +3016,8 @@ static void inheritDefaultTemplateArguments(ASTContext &Context, for (unsigned I = 0, N = FromTP->size(); I != N; ++I) { NamedDecl *FromParam = FromTP->getParam(N - I - 1); + if (FromParam->isParameterPack()) + continue; NamedDecl *ToParam = ToTP->getParam(N - I - 1); if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) { diff --git a/clang/test/PCH/cxx-variadic-templates-with-default-params.cpp b/clang/test/PCH/cxx-variadic-templates-with-default-params.cpp new file mode 100644 index 00000000000..2c1482091db --- /dev/null +++ b/clang/test/PCH/cxx-variadic-templates-with-default-params.cpp @@ -0,0 +1,26 @@ +// Test this without pch. +// RUN: %clang_cc1 -std=c++11 -include %s -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t %s +// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s + +// expected-no-diagnostics + +// PR25271: Ensure that default template arguments prior to a parameter pack +// successfully round-trip. +#ifndef HEADER +#define HEADER +template<unsigned T=123, unsigned... U> +class dummy; + +template<unsigned T, unsigned... U> +class dummy { + int field[T]; +}; +#else +void f() { + dummy<> x; + (void)x; +} +#endif |