]> granicus.if.org Git - clang/commitdiff
Non-type template parameter packs cannot have default arguments.
authorDouglas Gregor <dgregor@apple.com>
Fri, 24 Dec 2010 00:20:52 +0000 (00:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 24 Dec 2010 00:20:52 +0000 (00:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122533 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.param/p9-0x.cpp [new file with mode: 0644]

index a487825bb37c710576cb6411d7ebbc0f4cca49bc..ce0132ee81416acbe93ed18881efed5ccd985c0f 100644 (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;
diff --git a/test/CXX/temp/temp.param/p9-0x.cpp b/test/CXX/temp/temp.param/p9-0x.cpp
new file mode 100644 (file)
index 0000000..42d1adf
--- /dev/null
@@ -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;
+