aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-12 22:30:13 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-12 22:30:13 +0000
commit9c4c5c8e174e203da5f841f187bd290a76b34710 (patch)
tree6b829063dfb57fd5629538138ed081a9f6986ee3
parent6d845ae1baf77691bca080e0762a1d45ee017f70 (diff)
Parameter packs can't have default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73262 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--lib/Sema/SemaTemplate.cpp9
-rw-r--r--test/SemaTemplate/variadic-class-template-1.cpp3
3 files changed, 16 insertions, 0 deletions
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<TemplateTypeParmDecl>(TypeParam.getAs<Decl>());
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<typename... Args = int> struct S { }; // expected-error{{template parameter pack cannot have a default argument}}