diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-03 17:16:23 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-03 17:16:23 +0000 |
commit | b70126a328f89937f46db42f9e3cba1592887c91 (patch) | |
tree | d3957ff32069747c3538d9b30f6fb1d090b8bfb7 /lib/Sema/SemaTemplate.cpp | |
parent | 23a4ddf7875cff6ee70f6dee0d2a9956ae9b5473 (diff) |
When a pack expansion occurs in the template argument list of an alias
template without a corresponding parameter pack, don't immediately
substitute the alias template. This is under discussion in the C++
committee, and may become ill-formed, but for now we match GCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 7cd604d585..eca491f733 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1918,15 +1918,17 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // Check that the template argument list is well-formed for this // template. SmallVector<TemplateArgument, 4> Converted; + bool ExpansionIntoFixedList = false; if (CheckTemplateArgumentList(Template, TemplateLoc, TemplateArgs, - false, Converted)) + false, Converted, &ExpansionIntoFixedList)) return QualType(); QualType CanonType; bool InstantiationDependent = false; - if (TypeAliasTemplateDecl *AliasTemplate - = dyn_cast<TypeAliasTemplateDecl>(Template)) { + TypeAliasTemplateDecl *AliasTemplate = 0; + if (!ExpansionIntoFixedList && + (AliasTemplate = dyn_cast<TypeAliasTemplateDecl>(Template))) { // Find the canonical type for this type alias template specialization. TypeAliasDecl *Pattern = AliasTemplate->getTemplatedDecl(); if (Pattern->isInvalidDecl()) @@ -2891,7 +2893,11 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, - SmallVectorImpl<TemplateArgument> &Converted) { + SmallVectorImpl<TemplateArgument> &Converted, + bool *ExpansionIntoFixedList) { + if (ExpansionIntoFixedList) + *ExpansionIntoFixedList = false; + TemplateParameterList *Params = Template->getTemplateParameters(); unsigned NumParams = Params->size(); unsigned NumArgs = TemplateArgs.size(); @@ -2901,7 +2907,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, bool HasParameterPack = NumParams > 0 && Params->getParam(NumParams - 1)->isTemplateParameterPack(); - + // C++ [temp.arg]p1: // [...] The type and form of each template-argument specified in // a template-id shall match the type and form specified for the @@ -3088,6 +3094,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, ArgumentPack.size())); ArgumentPack.clear(); } + } else if (ExpansionIntoFixedList) { + // We have expanded a pack into a fixed list. + *ExpansionIntoFixedList = true; } return Invalid; |