Non-type template parameter packs cannot have default arguments.

llvm-svn: 122533
This commit is contained in:
Douglas Gregor 2010-12-24 00:20:52 +00:00
parent eb5a39deb2
commit 0da4a99ad3
2 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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<typename ...Types = int> // expected-error{{template parameter pack cannot have a default argument}}
struct X0;
template<int ...Values = 0> // expected-error{{template parameter pack cannot have a default argument}}
struct X1;