From: Anders Carlsson Date: Fri, 12 Jun 2009 22:30:13 +0000 (+0000) Subject: Parameter packs can't have default arguments. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c4c5c8e174e203da5f841f187bd290a76b34710;p=clang Parameter packs can't have default arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73262 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 899fd768dc..865b1ce4f3 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -833,6 +833,10 @@ def err_template_kw_refers_to_non_template : Error< def err_template_kw_refers_to_function_template : Error< "%0 following the 'template' keyword refers to a function template">; +// C++0x Variadic Templates +def err_template_param_pack_default_arg : Error< + "template parameter pack cannot have a default argument">; + def err_unexpected_typedef : Error< "unexpected type name %0: expected expression">; def err_unexpected_namespace : Error< diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 8058ad2d63..00d3e54565 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -187,6 +187,15 @@ void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam, = cast(TypeParam.getAs()); QualType Default = QualType::getFromOpaquePtr(DefaultT); + // 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 (Parm->isParameterPack()) { + Diag(DefaultLoc, diag::err_template_param_pack_default_arg); + Parm->setInvalidDecl(); + return; + } + // C++ [temp.param]p14: // A template-parameter shall not be used in its own default argument. // FIXME: Implement this check! Needs a recursive walk over the types. diff --git a/test/SemaTemplate/variadic-class-template-1.cpp b/test/SemaTemplate/variadic-class-template-1.cpp new file mode 100644 index 0000000000..b811423e1f --- /dev/null +++ b/test/SemaTemplate/variadic-class-template-1.cpp @@ -0,0 +1,3 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +template struct S { }; // expected-error{{template parameter pack cannot have a default argument}}