[cfe-commits] r73262 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaTemplate.cpp test/SemaTemplate/variadic-class-template-1.cpp
Anders Carlsson
andersca at mac.com
Fri Jun 12 15:30:13 PDT 2009
Author: andersca
Date: Fri Jun 12 17:30:13 2009
New Revision: 73262
URL: http://llvm.org/viewvc/llvm-project?rev=73262&view=rev
Log:
Parameter packs can't have default arguments.
Added:
cfe/trunk/test/SemaTemplate/variadic-class-template-1.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=73262&r1=73261&r2=73262&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 12 17:30:13 2009
@@ -833,6 +833,10 @@
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<
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=73262&r1=73261&r2=73262&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jun 12 17:30:13 2009
@@ -187,6 +187,15 @@
= 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.
Added: cfe/trunk/test/SemaTemplate/variadic-class-template-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/variadic-class-template-1.cpp?rev=73262&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/variadic-class-template-1.cpp (added)
+++ cfe/trunk/test/SemaTemplate/variadic-class-template-1.cpp Fri Jun 12 17:30:13 2009
@@ -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}}
More information about the cfe-commits
mailing list