[cfe-commits] r73262 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaTemplate.cpp test/SemaTemplate/variadic-class-template-1.cpp

Douglas Gregor dgregor at apple.com
Fri Jun 12 15:47:58 PDT 2009


On Jun 12, 2009, at 3:30 PM, Anders Carlsson wrote:

> 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.

Right!

> 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;
> +  }
> +

I don't think we need to set the decl as invalid here, do we? Dropping  
the default argument is enough to make sure we can type-check the rest  
of the code.

/me wonders if we should add a code-modification hint to remove the  
default parameter

	- Doug



More information about the cfe-commits mailing list