diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-06-04 08:34:32 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-06-04 08:34:32 +0000 | 
| commit | 2e87ca218f5d11b72a00e820cfd43a472247fe68 (patch) | |
| tree | ae130867cb87addca03132113ee906069683adcb /clang/lib/Sema | |
| parent | b1cd7dac3d77fa20853254f7d9794f396ee98272 (diff) | |
| download | bcm5719-llvm-2e87ca218f5d11b72a00e820cfd43a472247fe68.tar.gz bcm5719-llvm-2e87ca218f5d11b72a00e820cfd43a472247fe68.zip | |
When checking for equality of template parameter lists, a template
type parameter pack is distinct from a template type parameter.
llvm-svn: 105464
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 29 | 
1 files changed, 26 insertions, 3 deletions
| diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 40bbb152690..b02fc05892a 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3237,9 +3237,32 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,        return false;      } -    if (isa<TemplateTypeParmDecl>(*OldParm)) { -      // Okay; all template type parameters are equivalent (since we -      // know we're at the same index). +    if (TemplateTypeParmDecl *OldTTP +                                  = dyn_cast<TemplateTypeParmDecl>(*OldParm)) { +      // Template type parameters are equivalent if either both are template +      // type parameter packs or neither are (since we know we're at the same  +      // index). +      TemplateTypeParmDecl *NewTTP = cast<TemplateTypeParmDecl>(*NewParm); +      if (OldTTP->isParameterPack() != NewTTP->isParameterPack()) { +        // FIXME: Implement the rules in C++0x [temp.arg.template]p5 that +        // allow one to match a template parameter pack in the template +        // parameter list of a template template parameter to one or more +        // template parameters in the template parameter list of the  +        // corresponding template template argument.         +        if (Complain) { +          unsigned NextDiag = diag::err_template_parameter_pack_non_pack; +          if (TemplateArgLoc.isValid()) { +            Diag(TemplateArgLoc, +                 diag::err_template_arg_template_params_mismatch); +            NextDiag = diag::note_template_parameter_pack_non_pack; +          } +          Diag(NewTTP->getLocation(), NextDiag) +            << 0 << NewTTP->isParameterPack(); +          Diag(OldTTP->getLocation(), diag::note_template_parameter_pack_here) +            << 0 << OldTTP->isParameterPack(); +        } +        return false; +      }      } else if (NonTypeTemplateParmDecl *OldNTTP                   = dyn_cast<NonTypeTemplateParmDecl>(*OldParm)) {        // The types of non-type template parameters must agree. | 

