From 0da4a99ad36c11ee18d36c353eb4256945dfdf7b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 24 Dec 2010 00:20:52 +0000 Subject: [PATCH] Non-type template parameter packs cannot have default arguments. llvm-svn: 122533 --- clang/lib/Sema/SemaTemplate.cpp | 8 ++++++++ clang/test/CXX/temp/temp.param/p9-0x.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 clang/test/CXX/temp/temp.param/p9-0x.cpp diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index a487825bb37c..ce0132ee8141 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -649,6 +649,14 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, // Check the well-formedness of the default template argument, if provided. if (Default) { + // C++0x [temp.param]p9: + // A default template-argument may be specified for any kind of + // template-parameter that is not a template parameter pack. + if (IsParameterPack) { + Diag(EqualLoc, diag::err_template_param_pack_default_arg); + return Param; + } + // Check for unexpanded parameter packs. if (DiagnoseUnexpandedParameterPack(Default, UPPC_DefaultArgument)) return Param; diff --git a/clang/test/CXX/temp/temp.param/p9-0x.cpp b/clang/test/CXX/temp/temp.param/p9-0x.cpp new file mode 100644 index 000000000000..42d1adf29729 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p9-0x.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// A default template-argument may be specified for any kind of +// template-parameter that is not a template parameter pack. +template // expected-error{{template parameter pack cannot have a default argument}} +struct X0; + +template // expected-error{{template parameter pack cannot have a default argument}} +struct X1; +