[cfe-commits] r122533 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.param/p9-0x.cpp
Douglas Gregor
dgregor at apple.com
Thu Dec 23 16:20:52 PST 2010
Author: dgregor
Date: Thu Dec 23 18:20:52 2010
New Revision: 122533
URL: http://llvm.org/viewvc/llvm-project?rev=122533&view=rev
Log:
Non-type template parameter packs cannot have default arguments.
Added:
cfe/trunk/test/CXX/temp/temp.param/p9-0x.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=122533&r1=122532&r2=122533&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Dec 23 18:20:52 2010
@@ -649,6 +649,14 @@
// 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;
Added: cfe/trunk/test/CXX/temp/temp.param/p9-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p9-0x.cpp?rev=122533&view=auto
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.param/p9-0x.cpp (added)
+++ cfe/trunk/test/CXX/temp/temp.param/p9-0x.cpp Thu Dec 23 18:20:52 2010
@@ -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;
+
More information about the cfe-commits
mailing list