<div dir="ltr">Fixed in r293333.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 January 2017 at 13:27, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It's a pre-existing bug with some PS4-specific TLS handling ("thread_local auto a;" is sufficient to trigger the assert). A fix is on the way.<br><div class="gmail_extra"><br><div class="gmail_quote">On 27 January 2017 at 11:00, Galina Kistanova via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Richard,<br><br>This commit broke test on few our builders:<br><br>Failing Tests (1):<br> Clang :: Parser/cxx1z-class-template-ar<wbr>gument-deduction.cpp<br><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/llvm-clang-lld-x86_64-<wbr>scei-ps4-ubuntu-fast</a><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/llvm-clang-lld-x86_64-<wbr>scei-ps4-windows10pro-fast</a><br><br>Please have a look at this?<br><br>Thanks<br><br>Galina<br><br><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 12:40 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: rsmith<br>
Date: Thu Jan 26 14:40:47 2017<br>
New Revision: 293207<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=293207&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=293207&view=rev</a><br>
Log:<br>
PR0091R3: Implement parsing support for using templates as types.<br>
<br>
This change adds a new type node, DeducedTemplateSpecializationT<wbr>ype, to<br>
represent a type template name that has been used as a type. This is modeled<br>
around AutoType, and shares a common base class for representing a deduced<br>
placeholder type.<br>
<br>
We allow deduced class template types in a few more places than the standard<br>
does: in conditions and for-range-declarators, and in new-type-ids. This is<br>
consistent with GCC and with discussion on the core reflector. This patch<br>
does not yet support deduced class template types being named in typename<br>
specifiers.<br>
<br>
Added:<br>
cfe/trunk/test/Parser/cxx1z-cl<wbr>ass-template-argument-deductio<wbr>n.cpp<br>
Modified:<br>
cfe/trunk/include/clang/AST/AS<wbr>TContext.h<br>
cfe/trunk/include/clang/AST/Re<wbr>cursiveASTVisitor.h<br>
cfe/trunk/include/clang/AST/Ty<wbr>pe.h<br>
cfe/trunk/include/clang/AST/Ty<wbr>peLoc.h<br>
cfe/trunk/include/clang/AST/Ty<wbr>peNodes.def<br>
cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
cfe/trunk/include/clang/Parse/<wbr>Parser.h<br>
cfe/trunk/include/clang/Sema/D<wbr>eclSpec.h<br>
cfe/trunk/include/clang/Sema/S<wbr>ema.h<br>
cfe/trunk/include/clang/Serial<wbr>ization/ASTBitCodes.h<br>
cfe/trunk/lib/AST/ASTContext.c<wbr>pp<br>
cfe/trunk/lib/AST/ASTImporter.<wbr>cpp<br>
cfe/trunk/lib/AST/ExprConstant<wbr>.cpp<br>
cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp<br>
cfe/trunk/lib/AST/MicrosoftMan<wbr>gle.cpp<br>
cfe/trunk/lib/AST/Type.cpp<br>
cfe/trunk/lib/AST/TypePrinter.<wbr>cpp<br>
cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp<br>
cfe/trunk/lib/CodeGen/CodeGenF<wbr>unction.cpp<br>
cfe/trunk/lib/CodeGen/CodeGenT<wbr>ypes.cpp<br>
cfe/trunk/lib/CodeGen/ItaniumC<wbr>XXABI.cpp<br>
cfe/trunk/lib/Parse/ParseDecl.<wbr>cpp<br>
cfe/trunk/lib/Parse/ParseDeclC<wbr>XX.cpp<br>
cfe/trunk/lib/Parse/ParseExprC<wbr>XX.cpp<br>
cfe/trunk/lib/Parse/Parser.cpp<br>
cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>
cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p<br>
cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp<br>
cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp<br>
cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp<br>
cfe/trunk/lib/Sema/SemaTemplat<wbr>eDeduction.cpp<br>
cfe/trunk/lib/Sema/SemaType.cp<wbr>p<br>
cfe/trunk/lib/Sema/TreeTransfo<wbr>rm.h<br>
cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp<br>
cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp<br>
cfe/trunk/test/CXX/dcl.dcl/dcl<wbr>.spec/dcl.type/dcl.spec.auto/p<wbr>5.cpp<br>
cfe/trunk/test/CXX/drs/dr5xx.c<wbr>pp<br>
cfe/trunk/test/Parser/backtrac<wbr>k-off-by-one.cpp<br>
cfe/trunk/test/SemaTemplate/te<wbr>mp_arg.cpp<br>
cfe/trunk/test/SemaTemplate/ty<wbr>pename-specifier-3.cpp<br>
cfe/trunk/tools/libclang/CInde<wbr>x.cpp<br>
cfe/trunk/tools/libclang/CXTyp<wbr>e.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/AS<wbr>TContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/ASTContext.h?rev=293207&r1<wbr>=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/AS<wbr>TContext.h (original)<br>
+++ cfe/trunk/include/clang/AST/AS<wbr>TContext.h Thu Jan 26 14:40:47 2017<br>
@@ -167,6 +167,8 @@ class ASTContext : public RefCountedBase<br>
mutable llvm::FoldingSet<DependentUnar<wbr>yTransformType><br>
DependentUnaryTransformTypes;<br>
mutable llvm::FoldingSet<AutoType> AutoTypes;<br>
+ mutable llvm::FoldingSet<DeducedTempla<wbr>teSpecializationType><br>
+ DeducedTemplateSpecializationT<wbr>ypes;<br>
mutable llvm::FoldingSet<AtomicType> AtomicTypes;<br>
llvm::FoldingSet<AttributedTy<wbr>pe> AttributedTypes;<br>
mutable llvm::FoldingSet<PipeType> PipeTypes;<br>
@@ -1412,6 +1414,11 @@ public:<br>
/// \brief C++11 deduction pattern for 'auto &&' type.<br>
QualType getAutoRRefDeductType() const;<br>
<br>
+ /// \brief C++1z deduced class template specialization type.<br>
+ QualType getDeducedTemplateSpecializati<wbr>onType(TemplateName Template,<br>
+ QualType DeducedType,<br>
+ bool IsDependent) const;<br>
+<br>
/// \brief Return the unique reference to the type for the specified TagDecl<br>
/// (struct/union/class/enum) decl.<br>
QualType getTagDeclType(const TagDecl *Decl) const;<br>
<br>
Modified: cfe/trunk/include/clang/AST/Re<wbr>cursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/RecursiveASTVisitor.h?rev=<wbr>293207&r1=293206&r2=293207&vie<wbr>w=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/Re<wbr>cursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/Re<wbr>cursiveASTVisitor.h Thu Jan 26 14:40:47 2017<br>
@@ -1008,6 +1008,10 @@ DEF_TRAVERSE_TYPE(UnaryTransfo<wbr>rmType, {<br>
})<br>
<br>
DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDedu<wbr>cedType())); })<br>
+DEF_TRAVERSE_TYPE(DeducedTemp<wbr>lateSpecializationType, {<br>
+ TRY_TO(TraverseTemplateName(T-<wbr>>getTemplateName()));<br>
+ TRY_TO(TraverseType(T->getDedu<wbr>cedType()));<br>
+})<br>
<br>
DEF_TRAVERSE_TYPE(RecordType, {})<br>
DEF_TRAVERSE_TYPE(EnumType, {})<br>
@@ -1232,6 +1236,11 @@ DEF_TRAVERSE_TYPELOC(AutoType, {<br>
TRY_TO(TraverseType(TL.getTyp<wbr>ePtr()->getDeducedType()));<br>
})<br>
<br>
+DEF_TRAVERSE_TYPELOC(DeducedT<wbr>emplateSpecializationType, {<br>
+ TRY_TO(TraverseTemplateName(TL<wbr>.getTypePtr()->getTemplateName<wbr>()));<br>
+ TRY_TO(TraverseType(TL.getType<wbr>Ptr()->getDeducedType()));<br>
+})<br>
+<br>
DEF_TRAVERSE_TYPELOC(RecordTy<wbr>pe, {})<br>
DEF_TRAVERSE_TYPELOC(EnumType<wbr>, {})<br>
DEF_TRAVERSE_TYPELOC(Template<wbr>TypeParmType, {})<br>
<br>
Modified: cfe/trunk/include/clang/AST/Ty<wbr>pe.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/Type.h?rev=293207&r1=29320<wbr>6&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/Ty<wbr>pe.h (original)<br>
+++ cfe/trunk/include/clang/AST/Ty<wbr>pe.h Thu Jan 26 14:40:47 2017<br>
@@ -1785,7 +1785,8 @@ public:<br>
}<br>
<br>
/// \brief Determine whether this type is an undeduced type, meaning that<br>
- /// it somehow involves a C++11 'auto' type which has not yet been deduced.<br>
+ /// it somehow involves a C++11 'auto' type or similar which has not yet been<br>
+ /// deduced.<br>
bool isUndeducedType() const;<br>
<br>
/// \brief Whether this type is a variably-modified type (C99 6.7.5).<br>
@@ -1862,10 +1863,17 @@ public:<br>
/// not refer to a CXXRecordDecl, returns NULL.<br>
const CXXRecordDecl *getPointeeCXXRecordDecl() const;<br>
<br>
+ /// Get the DeducedType whose type will be deduced for a variable with<br>
+ /// an initializer of this type. This looks through declarators like pointer<br>
+ /// types, but not through decltype or typedefs.<br>
+ DeducedType *getContainedDeducedType() const;<br>
+<br>
/// Get the AutoType whose type will be deduced for a variable with<br>
/// an initializer of this type. This looks through declarators like pointer<br>
/// types, but not through decltype or typedefs.<br>
- AutoType *getContainedAutoType() const;<br>
+ AutoType *getContainedAutoType() const {<br>
+ return dyn_cast_or_null<AutoType>(get<wbr>ContainedDeducedType());<br>
+ }<br>
<br>
/// Determine whether this type was written with a leading 'auto'<br>
/// corresponding to a trailing return type (possibly for a nested<br>
@@ -4094,43 +4102,38 @@ public:<br>
}<br>
};<br>
<br>
-/// \brief Represents a C++11 auto or C++14 decltype(auto) type.<br>
+/// \brief Common base class for placeholders for types that get replaced by<br>
+/// placeholder type deduction: C++11 auto, C++14 decltype(auto), C++17 deduced<br>
+/// class template types, and (eventually) constrained type names from the C++<br>
+/// Concepts TS.<br>
///<br>
/// These types are usually a placeholder for a deduced type. However, before<br>
/// the initializer is attached, or (usually) if the initializer is<br>
-/// type-dependent, there is no deduced type and an auto type is canonical. In<br>
+/// type-dependent, there is no deduced type and the type is canonical. In<br>
/// the latter case, it is also a dependent type.<br>
-class AutoType : public Type, public llvm::FoldingSetNode {<br>
- AutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent)<br>
- : Type(Auto, DeducedType.isNull() ? QualType(this, 0) : DeducedType,<br>
- /*Dependent=*/IsDependent, /*InstantiationDependent=*/IsD<wbr>ependent,<br>
- /*VariablyModified=*/false, /*ContainsParameterPack=*/fals<wbr>e) {<br>
- if (!DeducedType.isNull()) {<br>
- if (DeducedType->isDependentType(<wbr>))<br>
+class DeducedType : public Type {<br>
+protected:<br>
+ DeducedType(TypeClass TC, QualType DeducedAsType, bool IsDependent,<br>
+ bool IsInstantiationDependent, bool ContainsParameterPack)<br>
+ : Type(TC, DeducedAsType.isNull() ? QualType(this, 0) : DeducedAsType,<br>
+ IsDependent, IsInstantiationDependent,<br>
+ /*VariablyModified=*/false, ContainsParameterPack) {<br>
+ if (!DeducedAsType.isNull()) {<br>
+ if (DeducedAsType->isDependentTyp<wbr>e())<br>
setDependent();<br>
- if (DeducedType->isInstantiationD<wbr>ependentType())<br>
+ if (DeducedAsType->isInstantiatio<wbr>nDependentType())<br>
setInstantiationDependent();<br>
- if (DeducedType->containsUnexpand<wbr>edParameterPack())<br>
+ if (DeducedAsType->containsUnexpa<wbr>ndedParameterPack())<br>
setContainsUnexpandedParamete<wbr>rPack();<br>
}<br>
- AutoTypeBits.Keyword = (unsigned)Keyword;<br>
}<br>
<br>
- friend class ASTContext; // ASTContext creates these<br>
-<br>
public:<br>
- bool isDecltypeAuto() const {<br>
- return getKeyword() == AutoTypeKeyword::DecltypeAuto;<br>
- }<br>
- AutoTypeKeyword getKeyword() const {<br>
- return (AutoTypeKeyword)AutoTypeBits.<wbr>Keyword;<br>
- }<br>
-<br>
bool isSugared() const { return !isCanonicalUnqualified(); }<br>
QualType desugar() const { return getCanonicalTypeInternal(); }<br>
<br>
- /// \brief Get the type deduced for this auto type, or null if it's either<br>
- /// not been deduced or was deduced to a dependent type.<br>
+ /// \brief Get the type deduced for this placeholder type, or null if it's<br>
+ /// either not been deduced or was deduced to a dependent type.<br>
QualType getDeducedType() const {<br>
return !isCanonicalUnqualified() ? getCanonicalTypeInternal() : QualType();<br>
}<br>
@@ -4138,6 +4141,31 @@ public:<br>
return !isCanonicalUnqualified() || isDependentType();<br>
}<br>
<br>
+ static bool classof(const Type *T) {<br>
+ return T->getTypeClass() == Auto ||<br>
+ T->getTypeClass() == DeducedTemplateSpecialization;<br>
+ }<br>
+};<br>
+<br>
+/// \brief Represents a C++11 auto or C++14 decltype(auto) type.<br>
+class AutoType : public DeducedType, public llvm::FoldingSetNode {<br>
+ AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword,<br>
+ bool IsDeducedAsDependent)<br>
+ : DeducedType(Auto, DeducedAsType, IsDeducedAsDependent,<br>
+ IsDeducedAsDependent, /*ContainsPack=*/false) {<br>
+ AutoTypeBits.Keyword = (unsigned)Keyword;<br>
+ }<br>
+<br>
+ friend class ASTContext; // ASTContext creates these<br>
+<br>
+public:<br>
+ bool isDecltypeAuto() const {<br>
+ return getKeyword() == AutoTypeKeyword::DecltypeAuto;<br>
+ }<br>
+ AutoTypeKeyword getKeyword() const {<br>
+ return (AutoTypeKeyword)AutoTypeBits.<wbr>Keyword;<br>
+ }<br>
+<br>
void Profile(llvm::FoldingSetNodeID &ID) {<br>
Profile(ID, getDeducedType(), getKeyword(), isDependentType());<br>
}<br>
@@ -4154,6 +4182,43 @@ public:<br>
}<br>
};<br>
<br>
+/// \brief Represents a C++17 deduced template specialization type.<br>
+class DeducedTemplateSpecializationT<wbr>ype : public DeducedType,<br>
+ public llvm::FoldingSetNode {<br>
+ /// The name of the template whose arguments will be deduced.<br>
+ TemplateName Template;<br>
+<br>
+ DeducedTemplateSpecializationT<wbr>ype(TemplateName Template,<br>
+ QualType DeducedAsType,<br>
+ bool IsDeducedAsDependent)<br>
+ : DeducedType(DeducedTemplateSpe<wbr>cialization, DeducedAsType,<br>
+ IsDeducedAsDependent || Template.isDependent(),<br>
+ IsDeducedAsDependent || Template.isInstantiationDepend<wbr>ent(),<br>
+ Template.containsUnexpandedPar<wbr>ameterPack()),<br>
+ Template(Template) {}<br>
+<br>
+ friend class ASTContext; // ASTContext creates these<br>
+<br>
+public:<br>
+ /// Retrieve the name of the template that we are deducing.<br>
+ TemplateName getTemplateName() const { return Template;}<br>
+<br>
+ void Profile(llvm::FoldingSetNodeID &ID) {<br>
+ Profile(ID, getTemplateName(), getDeducedType(), isDependentType());<br>
+ }<br>
+<br>
+ static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Template,<br>
+ QualType Deduced, bool IsDependent) {<br>
+ Template.Profile(ID);<br>
+ ID.AddPointer(Deduced.getAsOpa<wbr>quePtr());<br>
+ ID.AddBoolean(IsDependent);<br>
+ }<br>
+<br>
+ static bool classof(const Type *T) {<br>
+ return T->getTypeClass() == DeducedTemplateSpecialization;<br>
+ }<br>
+};<br>
+<br>
/// \brief Represents a type template specialization; the template<br>
/// must be a class template, a type alias template, or a template<br>
/// template parameter. A template which cannot be resolved to one of<br>
@@ -5857,8 +5922,8 @@ inline bool Type::isBooleanType() const<br>
}<br>
<br>
inline bool Type::isUndeducedType() const {<br>
- const AutoType *AT = getContainedAutoType();<br>
- return AT && !AT->isDeduced();<br>
+ auto *DT = getContainedDeducedType();<br>
+ return DT && !DT->isDeduced();<br>
}<br>
<br>
/// \brief Determines whether this is a type for which one can define<br>
<br>
Modified: cfe/trunk/include/clang/AST/Ty<wbr>peLoc.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/TypeLoc.h?rev=293207&r1=29<wbr>3206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/Ty<wbr>peLoc.h (original)<br>
+++ cfe/trunk/include/clang/AST/Ty<wbr>peLoc.h Thu Jan 26 14:40:47 2017<br>
@@ -1827,9 +1827,25 @@ public:<br>
}<br>
};<br>
<br>
-class AutoTypeLoc : public InheritingConcreteTypeLoc<Type<wbr>SpecTypeLoc,<br>
- AutoTypeLoc,<br>
- AutoType> {<br>
+class DeducedTypeLoc<br>
+ : public InheritingConcreteTypeLoc<Type<wbr>SpecTypeLoc, DeducedTypeLoc,<br>
+ DeducedType> {};<br>
+<br>
+class AutoTypeLoc<br>
+ : public InheritingConcreteTypeLoc<Dedu<wbr>cedTypeLoc, AutoTypeLoc, AutoType> {<br>
+};<br>
+<br>
+class DeducedTemplateSpecializationT<wbr>ypeLoc<br>
+ : public InheritingConcreteTypeLoc<Dedu<wbr>cedTypeLoc,<br>
+ DeducedTemplateSpecialization<wbr>TypeLoc,<br>
+ DeducedTemplateSpecialization<wbr>Type> {<br>
+public:<br>
+ SourceLocation getTemplateNameLoc() const {<br>
+ return getNameLoc();<br>
+ }<br>
+ void setTemplateNameLoc(SourceLocat<wbr>ion Loc) {<br>
+ setNameLoc(Loc);<br>
+ }<br>
};<br>
<br>
struct ElaboratedLocInfo {<br>
<br>
Modified: cfe/trunk/include/clang/AST/Ty<wbr>peNodes.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeNodes.def?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/TypeNodes.def?rev=293207&r<wbr>1=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/Ty<wbr>peNodes.def (original)<br>
+++ cfe/trunk/include/clang/AST/Ty<wbr>peNodes.def Thu Jan 26 14:40:47 2017<br>
@@ -96,7 +96,9 @@ DEPENDENT_TYPE(TemplateTypePar<wbr>m, Type)<br>
NON_CANONICAL_TYPE(SubstTempl<wbr>ateTypeParm, Type)<br>
DEPENDENT_TYPE(SubstTemplateT<wbr>ypeParmPack, Type)<br>
NON_CANONICAL_UNLESS_DEPENDEN<wbr>T_TYPE(TemplateSpecialization, Type)<br>
-TYPE(Auto, Type)<br>
+ABSTRACT_TYPE(Deduced, Type)<br>
+TYPE(Auto, DeducedType)<br>
+TYPE(DeducedTemplateSpecializ<wbr>ation, DeducedType)<br>
DEPENDENT_TYPE(InjectedClassN<wbr>ame, Type)<br>
DEPENDENT_TYPE(DependentName, Type)<br>
DEPENDENT_TYPE(DependentTempl<wbr>ateSpecialization, Type)<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Basic/DiagnosticSemaKinds.td?r<wbr>ev=293207&r1=293206&r2=293207&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td Thu Jan 26 14:40:47 2017<br>
@@ -1870,16 +1870,20 @@ def err_illegal_decl_array_of_auto : Err<br>
def err_new_array_of_auto : Error<<br>
"cannot allocate array of 'auto'">;<br>
def err_auto_not_allowed : Error<<br>
- "%select{'auto'|'decltype(auto<wbr>)'|'__auto_type'}0 not allowed "<br>
+ "%select{'auto'|'decltype(auto<wbr>)'|'__auto_type'|"<br>
+ "use of "<br>
+ "%select{class template|function template|variable template|alias template|"<br>
+ "template template parameter|template}2 %3 requires template arguments; "<br>
+ "argument deduction}0 not allowed "<br>
"%select{in function prototype"<br>
"|in non-static struct member|in struct member"<br>
"|in non-static union member|in union member"<br>
"|in non-static class member|in interface member"<br>
- "|in exception declaration|in template parameter|in block literal"<br>
+ "|in exception declaration|in template parameter until C++1z|in block literal"<br>
"|in template argument|in typedef|in type alias|in function return type"<br>
"|in conversion function type|here|in lambda parameter"<br>
- "|in type allocated by 'new'|in K&R-style function parameter}1"<br>
- "%select{|||||||| until C++1z||||||||||}1">;<br>
+ "|in type allocated by 'new'|in K&R-style function parameter"<br>
+ "|in template parameter|in friend declaration}1">;<br>
def err_auto_not_allowed_var_inst : Error<<br>
"'auto' variable template instantiation is not allowed">;<br>
def err_auto_var_requires_init : Error<<br>
@@ -1944,6 +1948,14 @@ def err_decltype_auto_compound_typ<wbr>e : Er<br>
def err_decltype_auto_initializer_<wbr>list : Error<<br>
"cannot deduce 'decltype(auto)' from initializer list">;<br>
<br>
+// C++1z deduced class template specialization types<br>
+def err_deduced_class_template_com<wbr>pound_type : Error<<br>
+ "cannot %select{form pointer to|form reference to|form array of|"<br>
+ "form function returning|use parentheses when declaring variable with}0 "<br>
+ "deduced class template specialization type">;<br>
+def err_deduced_class_template_not<wbr>_supported : Error<<br>
+ "deduction of template arguments for class templates is not yet supported">;<br>
+<br>
// C++1y deduced return types<br>
def err_auto_fn_deduction_failure : Error<<br>
"cannot deduce return type %0 from returned value of type %1">;<br>
<br>
Modified: cfe/trunk/include/clang/Parse/<wbr>Parser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Parse/Parser.h?rev=293207&r1=2<wbr>93206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Parse/<wbr>Parser.h (original)<br>
+++ cfe/trunk/include/clang/Parse/<wbr>Parser.h Thu Jan 26 14:40:47 2017<br>
@@ -1834,6 +1834,26 @@ private:<br>
llvm_unreachable("Missing DeclSpecContext case");<br>
}<br>
<br>
+ /// Is this a context in which we can perform class template argument<br>
+ /// deduction?<br>
+ static bool isClassTemplateDeductionContex<wbr>t(DeclSpecContext DSC) {<br>
+ switch (DSC) {<br>
+ case DSC_normal:<br>
+ case DSC_class:<br>
+ case DSC_top_level:<br>
+ case DSC_condition:<br>
+ case DSC_type_specifier:<br>
+ return true;<br>
+<br>
+ case DSC_objc_method_result:<br>
+ case DSC_template_type_arg:<br>
+ case DSC_trailing:<br>
+ case DSC_alias_declaration:<br>
+ return false;<br>
+ }<br>
+ llvm_unreachable("Missing DeclSpecContext case");<br>
+ }<br>
+<br>
/// Information on a C++0x for-range-initializer found while parsing a<br>
/// declaration which turns out to be a for-range-declaration.<br>
struct ForRangeInit {<br>
<br>
Modified: cfe/trunk/include/clang/Sema/D<wbr>eclSpec.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Sema/DeclSpec.h?rev=293207&r1=<wbr>293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/D<wbr>eclSpec.h (original)<br>
+++ cfe/trunk/include/clang/Sema/D<wbr>eclSpec.h Thu Jan 26 14:40:47 2017<br>
@@ -1709,6 +1709,7 @@ public:<br>
ObjCParameterContext,// An ObjC method parameter type.<br>
KNRTypeListContext, // K&R type definition list for formals.<br>
TypeNameContext, // Abstract declarator for types.<br>
+ FunctionalCastContext, // Type in a C++ functional cast expression.<br>
MemberContext, // Struct/Union field.<br>
BlockContext, // Declaration within a block in a function.<br>
ForContext, // Declaration within first part of a for loop.<br>
@@ -1911,6 +1912,7 @@ public:<br>
return false;<br>
<br>
case TypeNameContext:<br>
+ case FunctionalCastContext:<br>
case AliasDeclContext:<br>
case AliasTemplateContext:<br>
case PrototypeContext:<br>
@@ -1951,6 +1953,7 @@ public:<br>
return true;<br>
<br>
case TypeNameContext:<br>
+ case FunctionalCastContext:<br>
case CXXNewContext:<br>
case AliasDeclContext:<br>
case AliasTemplateContext:<br>
@@ -1983,6 +1986,7 @@ public:<br>
case CXXCatchContext:<br>
case ObjCCatchContext:<br>
case TypeNameContext:<br>
+ case FunctionalCastContext:<br>
case ConversionIdContext:<br>
case ObjCParameterContext:<br>
case ObjCResultContext:<br>
@@ -2021,6 +2025,7 @@ public:<br>
// These contexts don't allow any kind of non-abstract declarator.<br>
case KNRTypeListContext:<br>
case TypeNameContext:<br>
+ case FunctionalCastContext:<br>
case AliasDeclContext:<br>
case AliasTemplateContext:<br>
case LambdaExprParameterContext:<br>
@@ -2078,6 +2083,7 @@ public:<br>
case CXXCatchContext:<br>
case ObjCCatchContext:<br>
case TypeNameContext:<br>
+ case FunctionalCastContext: // FIXME<br>
case CXXNewContext:<br>
case AliasDeclContext:<br>
case AliasTemplateContext:<br>
@@ -2279,6 +2285,7 @@ public:<br>
case ConditionContext:<br>
case KNRTypeListContext:<br>
case TypeNameContext:<br>
+ case FunctionalCastContext:<br>
case AliasDeclContext:<br>
case AliasTemplateContext:<br>
case PrototypeContext:<br>
<br>
Modified: cfe/trunk/include/clang/Sema/S<wbr>ema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Sema/Sema.h?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/S<wbr>ema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/S<wbr>ema.h Thu Jan 26 14:40:47 2017<br>
@@ -1548,6 +1548,7 @@ public:<br>
ParsedType ObjectType = nullptr,<br>
bool IsCtorOrDtorName = false,<br>
bool WantNontrivialTypeSourceInfo = false,<br>
+ bool IsClassTemplateDeductionContex<wbr>t = true,<br>
IdentifierInfo **CorrectedII = nullptr);<br>
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);<br>
bool isMicrosoftMissingTypename(con<wbr>st CXXScopeSpec *SS, Scope *S);<br>
<br>
Modified: cfe/trunk/include/clang/Serial<wbr>ization/ASTBitCodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Serialization/ASTBitCodes.h?re<wbr>v=293207&r1=293206&r2=293207&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Serial<wbr>ization/ASTBitCodes.h (original)<br>
+++ cfe/trunk/include/clang/Serial<wbr>ization/ASTBitCodes.h Thu Jan 26 14:40:47 2017<br>
@@ -914,7 +914,9 @@ namespace clang {<br>
/// \brief A PipeType record.<br>
TYPE_PIPE = 43,<br>
/// \brief An ObjCTypeParamType record.<br>
- TYPE_OBJC_TYPE_PARAM = 44<br>
+ TYPE_OBJC_TYPE_PARAM = 44,<br>
+ /// \brief A DeducedTemplateSpecializationT<wbr>ype record.<br>
+ TYPE_DEDUCED_TEMPLATE_SPECIALI<wbr>ZATION = 45<br>
};<br>
<br>
/// \brief The type IDs for special types constructed by semantic<br>
<br>
Modified: cfe/trunk/lib/AST/ASTContext.c<wbr>pp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/ASTCon<wbr>text.cpp?rev=293207&r1=293206&<wbr>r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ASTContext.c<wbr>pp (original)<br>
+++ cfe/trunk/lib/AST/ASTContext.c<wbr>pp Thu Jan 26 14:40:47 2017<br>
@@ -1877,8 +1877,9 @@ TypeInfo ASTContext::getTypeInfoImpl(co<wbr>n<br>
return getTypeInfo(cast<SubstTemplate<wbr>TypeParmType>(T)-><br>
getReplacementType().getTypePt<wbr>r());<br>
<br>
- case Type::Auto: {<br>
- const AutoType *A = cast<AutoType>(T);<br>
+ case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation: {<br>
+ const DeducedType *A = cast<DeducedType>(T);<br>
assert(!A->getDeducedType().i<wbr>sNull() &&<br>
"cannot request the size of an undeduced or dependent auto type");<br>
return getTypeInfo(A->getDeducedType(<wbr>).getTypePtr());<br>
@@ -2765,6 +2766,7 @@ QualType ASTContext::getVariableArrayDe<wbr>c<br>
case Type::TemplateTypeParm:<br>
case Type::SubstTemplateTypeParmPac<wbr>k:<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::PackExpansion:<br>
llvm_unreachable("type should never be variably-modified");<br>
<br>
@@ -4435,6 +4437,28 @@ QualType ASTContext::getAutoType(QualTy<wbr>p<br>
return QualType(AT, 0);<br>
}<br>
<br>
+/// Return the uniqued reference to the deduced template specialization type<br>
+/// which has been deduced to the given type, or to the canonical undeduced<br>
+/// such type, or the canonical deduced-but-dependent such type.<br>
+QualType ASTContext::getDeducedTemplate<wbr>SpecializationType(<br>
+ TemplateName Template, QualType DeducedType, bool IsDependent) const {<br>
+ // Look in the folding set for an existing type.<br>
+ void *InsertPos = nullptr;<br>
+ llvm::FoldingSetNodeID ID;<br>
+ DeducedTemplateSpecializationT<wbr>ype::Profile(ID, Template, DeducedType,<br>
+ IsDependent);<br>
+ if (DeducedTemplateSpecialization<wbr>Type *DTST =<br>
+ DeducedTemplateSpecializationT<wbr>ypes.FindNodeOrInsertPos(ID, InsertPos))<br>
+ return QualType(DTST, 0);<br>
+<br>
+ DeducedTemplateSpecializationT<wbr>ype *DTST = new (*this, TypeAlignment)<br>
+ DeducedTemplateSpecializationT<wbr>ype(Template, DeducedType, IsDependent);<br>
+ Types.push_back(DTST);<br>
+ if (InsertPos)<br>
+ DeducedTemplateSpecializationT<wbr>ypes.InsertNode(DTST, InsertPos);<br>
+ return QualType(DTST, 0);<br>
+}<br>
+<br>
/// getAtomicType - Return the uniqued reference to the atomic type for<br>
/// the given value type.<br>
QualType ASTContext::getAtomicType(Qual<wbr>Type T) const {<br>
@@ -6333,6 +6357,7 @@ void ASTContext::getObjCEncodingFor<wbr>TypeI<br>
// We could see an undeduced auto type here during error recovery.<br>
// Just ignore it.<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
return;<br>
<br>
case Type::Pipe:<br>
@@ -8132,6 +8157,7 @@ QualType ASTContext::mergeTypes(QualTyp<wbr>e<br>
llvm_unreachable("Non-canonic<wbr>al and dependent types shouldn't get here");<br>
<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::LValueReference:<br>
case Type::RValueReference:<br>
case Type::MemberPointer:<br>
<br>
Modified: cfe/trunk/lib/AST/ASTImporter.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/ASTImp<wbr>orter.cpp?rev=293207&r1=293206<wbr>&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ASTImporter.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/AST/ASTImporter.<wbr>cpp Thu Jan 26 14:40:47 2017<br>
@@ -883,6 +883,20 @@ static bool IsStructurallyEquivalent(Str<br>
return false;<br>
break;<br>
<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation: {<br>
+ auto *DT1 = cast<DeducedTemplateSpecializa<wbr>tionType>(T1);<br>
+ auto *DT2 = cast<DeducedTemplateSpecializa<wbr>tionType>(T2);<br>
+ if (!IsStructurallyEquivalent(Con<wbr>text,<br>
+ DT1->getTemplateName(),<br>
+ DT2->getTemplateName()))<br>
+ return false;<br>
+ if (!IsStructurallyEquivalent(Con<wbr>text,<br>
+ DT1->getDeducedType(),<br>
+ DT2->getDeducedType()))<br>
+ return false;<br>
+ break;<br>
+ }<br>
+<br>
case Type::Record:<br>
case Type::Enum:<br>
if (!IsStructurallyEquivalent(Con<wbr>text,<br>
<br>
Modified: cfe/trunk/lib/AST/ExprConstant<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/ExprCo<wbr>nstant.cpp?rev=293207&r1=29320<wbr>6&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ExprConstant<wbr>.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprConstant<wbr>.cpp Thu Jan 26 14:40:47 2017<br>
@@ -7004,6 +7004,7 @@ static int EvaluateBuiltinClassifyType(c<br>
case Type::Vector:<br>
case Type::ExtVector:<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::ObjCObject:<br>
case Type::ObjCInterface:<br>
case Type::ObjCObjectPointer:<br>
<br>
Modified: cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/Itaniu<wbr>mMangle.cpp?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp (original)<br>
+++ cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1870,6 +1870,7 @@ bool CXXNameMangler::mangleUnresolv<wbr>edTyp<br>
case Type::Paren:<br>
case Type::Attributed:<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::PackExpansion:<br>
case Type::ObjCObject:<br>
case Type::ObjCInterface:<br>
@@ -3145,6 +3146,16 @@ void CXXNameMangler::mangleType(con<wbr>st Au<br>
mangleType(D);<br>
}<br>
<br>
+void CXXNameMangler::mangleType(con<wbr>st DeducedTemplateSpecializationT<wbr>ype *T) {<br>
+ // FIXME: This is not the right mangling. We also need to include a scope<br>
+ // here in some cases.<br>
+ QualType D = T->getDeducedType();<br>
+ if (D.isNull())<br>
+ mangleUnscopedTemplateName(T-><wbr>getTemplateName(), nullptr);<br>
+ else<br>
+ mangleType(D);<br>
+}<br>
+<br>
void CXXNameMangler::mangleType(con<wbr>st AtomicType *T) {<br>
// <type> ::= U <source-name> <type> # vendor extended type qualifier<br>
// (Until there's a standardized mangling...)<br>
<br>
Modified: cfe/trunk/lib/AST/MicrosoftMan<wbr>gle.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/Micros<wbr>oftMangle.cpp?rev=293207&r1=29<wbr>3206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/MicrosoftMan<wbr>gle.cpp (original)<br>
+++ cfe/trunk/lib/AST/MicrosoftMan<wbr>gle.cpp Thu Jan 26 14:40:47 2017<br>
@@ -2474,6 +2474,17 @@ void MicrosoftCXXNameMangler::mangl<wbr>eType<br>
<< Range;<br>
}<br>
<br>
+void MicrosoftCXXNameMangler::mangl<wbr>eType(<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T, Qualifiers, SourceRange Range) {<br>
+ assert(T->getDeducedType().isN<wbr>ull() && "expecting a dependent type!");<br>
+<br>
+ DiagnosticsEngine &Diags = Context.getDiags();<br>
+ unsigned DiagID = Diags.getCustomDiagID(Diagnost<wbr>icsEngine::Error,<br>
+ "cannot mangle this deduced class template specialization type yet");<br>
+ Diags.Report(Range.getBegin(), DiagID)<br>
+ << Range;<br>
+}<br>
+<br>
void MicrosoftCXXNameMangler::mangl<wbr>eType(const AtomicType *T, Qualifiers,<br>
SourceRange Range) {<br>
QualType ValueType = T->getValueType();<br>
<br>
Modified: cfe/trunk/lib/AST/Type.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/Type.c<wbr>pp?rev=293207&r1=293206&r2=293<wbr>207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/Type.cpp (original)<br>
+++ cfe/trunk/lib/AST/Type.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1559,25 +1559,29 @@ TagDecl *Type::getAsTagDecl() const {<br>
}<br>
<br>
namespace {<br>
- class GetContainedAutoVisitor :<br>
- public TypeVisitor<GetContainedAutoVi<wbr>sitor, Type*> {<br>
+ class GetContainedDeducedTypeVisitor :<br>
+ public TypeVisitor<GetContainedDeduce<wbr>dTypeVisitor, Type*> {<br>
bool Syntactic;<br>
public:<br>
- GetContainedAutoVisitor(bool Syntactic = false) : Syntactic(Syntactic) {}<br>
+ GetContainedDeducedTypeVisitor<wbr>(bool Syntactic = false)<br>
+ : Syntactic(Syntactic) {}<br>
<br>
- using TypeVisitor<GetContainedAutoVi<wbr>sitor, Type*>::Visit;<br>
+ using TypeVisitor<GetContainedDeduce<wbr>dTypeVisitor, Type*>::Visit;<br>
Type *Visit(QualType T) {<br>
if (T.isNull())<br>
return nullptr;<br>
return Visit(T.getTypePtr());<br>
}<br>
<br>
- // The 'auto' type itself.<br>
- Type *VisitAutoType(const AutoType *AT) {<br>
- return const_cast<AutoType*>(AT);<br>
+ // The deduced type itself.<br>
+ Type *VisitDeducedType(const DeducedType *AT) {<br>
+ return const_cast<DeducedType*>(AT);<br>
}<br>
<br>
// Only these types can contain the desired 'auto' type.<br>
+ Type *VisitElaboratedType(const ElaboratedType *T) {<br>
+ return Visit(T->getNamedType());<br>
+ }<br>
Type *VisitPointerType(const PointerType *T) {<br>
return Visit(T->getPointeeType());<br>
}<br>
@@ -1620,13 +1624,14 @@ namespace {<br>
};<br>
}<br>
<br>
-AutoType *Type::getContainedAutoType() const {<br>
- return cast_or_null<AutoType>(GetCont<wbr>ainedAutoVisitor().Visit(this)<wbr>);<br>
+DeducedType *Type::getContainedDeducedType<wbr>() const {<br>
+ return cast_or_null<DeducedType>(<br>
+ GetContainedDeducedTypeVisitor<wbr>().Visit(this));<br>
}<br>
<br>
bool Type::hasAutoForTrailingReturn<wbr>Type() const {<br>
return dyn_cast_or_null<FunctionType><wbr>(<br>
- GetContainedAutoVisitor(true).<wbr>Visit(this));<br>
+ GetContainedDeducedTypeVisitor<wbr>(true).Visit(this));<br>
}<br>
<br>
bool Type::hasIntegerRepresentation<wbr>() const {<br>
@@ -3378,6 +3383,7 @@ static CachedProperties computeCachedPro<br>
return CachedProperties(ExternalLinka<wbr>ge, false);<br>
<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
// Give non-deduced 'auto' types external linkage. We should only see them<br>
// here in error recovery.<br>
return CachedProperties(ExternalLinka<wbr>ge, false);<br>
@@ -3485,6 +3491,7 @@ static LinkageInfo computeLinkageInfo(co<br>
return LinkageInfo::external();<br>
<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
return LinkageInfo::external();<br>
<br>
case Type::Record:<br>
@@ -3621,7 +3628,8 @@ bool Type::canHaveNullability() const {<br>
<br>
// auto is considered dependent when it isn't deduced.<br>
case Type::Auto:<br>
- return !cast<AutoType>(type.getTypePt<wbr>r())->isDeduced();<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ return !cast<DeducedType>(type.getTyp<wbr>ePtr())->isDeduced();<br>
<br>
case Type::Builtin:<br>
switch (cast<BuiltinType>(type.getTyp<wbr>ePtr())->getKind()) {<br>
<br>
Modified: cfe/trunk/lib/AST/TypePrinter.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/TypePr<wbr>inter.cpp?rev=293207&r1=293206<wbr>&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/TypePrinter.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/AST/TypePrinter.<wbr>cpp Thu Jan 26 14:40:47 2017<br>
@@ -189,6 +189,7 @@ bool TypePrinter::canPrefixQualifie<wbr>rs(co<br>
case Type::Elaborated:<br>
case Type::TemplateTypeParm:<br>
case Type::SubstTemplateTypeParmPac<wbr>k:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::TemplateSpecialization:<br>
case Type::InjectedClassName:<br>
case Type::DependentName:<br>
@@ -887,6 +888,24 @@ void TypePrinter::printAutoAfter(co<wbr>nst A<br>
if (!T->getDeducedType().isNull()<wbr>)<br>
printAfter(T->getDeducedType(<wbr>), OS);<br>
}<br>
+<br>
+void TypePrinter::printDeducedTempl<wbr>ateSpecializationBefore(<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T, raw_ostream &OS) {<br>
+ // If the type has been deduced, print the deduced type.<br>
+ if (!T->getDeducedType().isNull()<wbr>) {<br>
+ printBefore(T->getDeducedType(<wbr>), OS);<br>
+ } else {<br>
+ IncludeStrongLifetimeRAII Strong(Policy);<br>
+ T->getTemplateName().print(OS, Policy);<br>
+ spaceBeforePlaceHolder(OS);<br>
+ }<br>
+}<br>
+void TypePrinter::printDeducedTempl<wbr>ateSpecializationAfter(<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T, raw_ostream &OS) {<br>
+ // If the type has been deduced, print the deduced type.<br>
+ if (!T->getDeducedType().isNull()<wbr>)<br>
+ printAfter(T->getDeducedType()<wbr>, OS);<br>
+}<br>
<br>
void TypePrinter::printAtomicBefore<wbr>(const AtomicType *T, raw_ostream &OS) {<br>
IncludeStrongLifetimeRAII Strong(Policy);<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/CodeGen/CG<wbr>DebugInfo.cpp?rev=293207&r1=29<wbr>3206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp Thu Jan 26 14:40:47 2017<br>
@@ -2618,6 +2618,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNod<br>
case Type::Attributed:<br>
case Type::Adjusted:<br>
case Type::Decayed:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::Elaborated:<br>
case Type::Paren:<br>
case Type::SubstTemplateTypeParm:<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenF<wbr>unction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/CodeGen/Co<wbr>deGenFunction.cpp?rev=293207&r<wbr>1=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/CodeGenF<wbr>unction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenF<wbr>unction.cpp Thu Jan 26 14:40:47 2017<br>
@@ -200,7 +200,8 @@ TypeEvaluationKind CodeGenFunction::getE<br>
llvm_unreachable("non-canonic<wbr>al or dependent type in IR-generation");<br>
<br>
case Type::Auto:<br>
- llvm_unreachable("undeduced auto type in IR-generation");<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ llvm_unreachable("undeduced type in IR-generation");<br>
<br>
// Various scalar types.<br>
case Type::Builtin:<br>
@@ -1899,6 +1900,7 @@ void CodeGenFunction::EmitVariablyM<wbr>odifi<br>
case Type::Typedef:<br>
case Type::Decltype:<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
// Stop walking: nothing to do.<br>
return;<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenT<wbr>ypes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/CodeGen/Co<wbr>deGenTypes.cpp?rev=293207&r1=2<wbr>93206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/CodeGenT<wbr>ypes.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenT<wbr>ypes.cpp Thu Jan 26 14:40:47 2017<br>
@@ -487,7 +487,8 @@ llvm::Type *CodeGenTypes::ConvertType(Qu<br>
break;<br>
}<br>
case Type::Auto:<br>
- llvm_unreachable("Unexpected undeduced auto type!");<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ llvm_unreachable("Unexpected undeduced type!");<br>
case Type::Complex: {<br>
llvm::Type *EltTy = ConvertType(cast<ComplexType>(<wbr>Ty)->getElementType());<br>
ResultType = llvm::StructType::get(EltTy, EltTy, nullptr);<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ItaniumC<wbr>XXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/CodeGen/It<wbr>aniumCXXABI.cpp?rev=293207&r1=<wbr>293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/ItaniumC<wbr>XXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ItaniumC<wbr>XXABI.cpp Thu Jan 26 14:40:47 2017<br>
@@ -2815,7 +2815,8 @@ void ItaniumRTTIBuilder::BuildVTabl<wbr>ePoin<br>
llvm_unreachable("References shouldn't get here");<br>
<br>
case Type::Auto:<br>
- llvm_unreachable("Undeduced auto type shouldn't get here");<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ llvm_unreachable("Undeduced type shouldn't get here");<br>
<br>
case Type::Pipe:<br>
llvm_unreachable("Pipe types shouldn't get here");<br>
@@ -3045,7 +3046,8 @@ llvm::Constant *ItaniumRTTIBuilder::Buil<br>
llvm_unreachable("References shouldn't get here");<br>
<br>
case Type::Auto:<br>
- llvm_unreachable("Undeduced auto type shouldn't get here");<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ llvm_unreachable("Undeduced type shouldn't get here");<br>
<br>
case Type::Pipe:<br>
llvm_unreachable("Pipe type shouldn't get here");<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Parse/Pars<wbr>eDecl.cpp?rev=293207&r1=293206<wbr>&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Parse/ParseDecl.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.<wbr>cpp Thu Jan 26 14:40:47 2017<br>
@@ -2884,7 +2884,8 @@ void Parser::ParseDeclarationSpecif<wbr>iers(<br>
Actions.getTypeName(*Next.get<wbr>IdentifierInfo(), Next.getLocation(),<br>
getCurScope(), &SS, false, false, nullptr,<br>
/*IsCtorOrDtorName=*/false,<br>
- /*NonTrivialSourceInfo=*/true)<wbr>;<br>
+ /*WantNonTrivialSourceInfo=*/t<wbr>rue,<br>
+ isClassTemplateDeductionContex<wbr>t(DSContext));<br>
<br>
// If the referenced identifier is not a type, then this declspec is<br>
// erroneous: We already checked about that it has no type specifier, and<br>
@@ -2998,9 +2999,10 @@ void Parser::ParseDeclarationSpecif<wbr>iers(<br>
continue;<br>
}<br>
<br>
- ParsedType TypeRep =<br>
- Actions.getTypeName(*Tok.getId<wbr>entifierInfo(),<br>
- Tok.getLocation(), getCurScope());<br>
+ ParsedType TypeRep = Actions.getTypeName(<br>
+ *Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), nullptr,<br>
+ false, false, nullptr, false, false,<br>
+ isClassTemplateDeductionContex<wbr>t(DSContext));<br>
<br>
// If this is not a typedef name, don't parse it as part of the declspec,<br>
// it must be an implicit int or an error.<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDeclC<wbr>XX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Parse/Pars<wbr>eDeclCXX.cpp?rev=293207&r1=293<wbr>206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Parse/ParseDeclC<wbr>XX.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDeclC<wbr>XX.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1144,10 +1144,11 @@ TypeResult Parser::ParseBaseTypeSpecifie<br>
<br>
// We have an identifier; check whether it is actually a type.<br>
IdentifierInfo *CorrectedII = nullptr;<br>
- ParsedType Type =<br>
- Actions.getTypeName(*Id, IdLoc, getCurScope(), &SS, true, false, nullptr,<br>
- /*IsCtorOrDtorName=*/false,<br>
- /*NonTrivialTypeSourceInfo=*/t<wbr>rue, &CorrectedII);<br>
+ ParsedType Type = Actions.getTypeName(<br>
+ *Id, IdLoc, getCurScope(), &SS, true, false, nullptr,<br>
+ /*IsCtorOrDtorName=*/false,<br>
+ /*NonTrivialTypeSourceInfo=*/t<wbr>rue,<br>
+ /*IsClassTemplateDeductionCont<wbr>ext*/ false, &CorrectedII);<br>
if (!Type) {<br>
Diag(IdLoc, diag::err_expected_class_name)<wbr>;<br>
return true;<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseExprC<wbr>XX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Parse/Pars<wbr>eExprCXX.cpp?rev=293207&r1=293<wbr>206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Parse/ParseExprC<wbr>XX.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseExprC<wbr>XX.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1639,9 +1639,10 @@ ExprResult Parser::ParseCXXThis() {<br>
/// typename-specifier '(' expression-list[opt] ')'<br>
/// [C++0x] typename-specifier braced-init-list<br>
///<br>
+/// In C++1z onwards, the type specifier can also be a template-name.<br>
ExprResult<br>
Parser::ParseCXXTypeConstruct<wbr>Expression(const DeclSpec &DS) {<br>
- Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);<br>
+ Declarator DeclaratorInfo(DS, Declarator::FunctionalCastCont<wbr>ext);<br>
ParsedType TypeRep = Actions.ActOnTypeName(getCurSc<wbr>ope(), DeclaratorInfo).get();<br>
<br>
assert((Tok.is(tok::l_paren) ||<br>
<br>
Modified: cfe/trunk/lib/Parse/Parser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Parse/Pars<wbr>er.cpp?rev=293207&r1=293206&r2<wbr>=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Parse/Parser.cpp (original)<br>
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1743,7 +1743,8 @@ bool Parser::TryAnnotateTypeOrScope<wbr>Token<br>
*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), &SS,<br>
false, NextToken().is(tok::period), nullptr,<br>
/*IsCtorOrDtorName=*/false,<br>
- /*NonTrivialTypeSourceInfo*/ true)) {<br>
+ /*NonTrivialTypeSourceInfo*/ true,<br>
+ /*IsClassTemplateDeductionCont<wbr>ext*/GreaterThanIsOperator)) {<br>
SourceLocation BeginLoc = Tok.getLocation();<br>
if (SS.isNotEmpty()) // it was a C++ qualified type name.<br>
BeginLoc = SS.getBeginLoc();<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaD<wbr>ecl.cpp?rev=293207&r1=293206&r<wbr>2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p Thu Jan 26 14:40:47 2017<br>
@@ -60,6 +60,11 @@ Sema::DeclGroupPtrTy Sema::ConvertDeclTo<br>
return DeclGroupPtrTy::make(DeclGroup<wbr>Ref(Ptr));<br>
}<br>
<br>
+static bool isTypeTemplate(NamedDecl *ND) {<br>
+ return isa<ClassTemplateDecl>(ND) || isa<TypeAliasTemplateDecl>(ND) ||<br>
+ isa<TemplateTemplateParmDecl><wbr>(ND);<br>
+}<br>
+<br>
namespace {<br>
<br>
class TypeNameValidatorCCC : public CorrectionCandidateCallback {<br>
@@ -67,7 +72,7 @@ class TypeNameValidatorCCC : public Corr<br>
TypeNameValidatorCCC(bool AllowInvalid, bool WantClass=false,<br>
bool AllowTemplates=false)<br>
: AllowInvalidDecl(AllowInvalid)<wbr>, WantClassName(WantClass),<br>
- AllowClassTemplates(AllowTempl<wbr>ates) {<br>
+ AllowTemplates(AllowTemplates) {<br>
WantExpressionKeywords = false;<br>
WantCXXNamedCasts = false;<br>
WantRemainingKeywords = false;<br>
@@ -76,7 +81,7 @@ class TypeNameValidatorCCC : public Corr<br>
bool ValidateCandidate(const TypoCorrection &candidate) override {<br>
if (NamedDecl *ND = candidate.getCorrectionDecl()) {<br>
bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);<br>
- bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND);<br>
+ bool AllowedTemplate = AllowTemplates && isTypeTemplate(ND);<br>
return (IsType || AllowedTemplate) &&<br>
(AllowInvalidDecl || !ND->isInvalidDecl());<br>
}<br>
@@ -86,7 +91,7 @@ class TypeNameValidatorCCC : public Corr<br>
private:<br>
bool AllowInvalidDecl;<br>
bool WantClassName;<br>
- bool AllowClassTemplates;<br>
+ bool AllowTemplates;<br>
};<br>
<br>
} // end anonymous namespace<br>
@@ -252,7 +257,13 @@ ParsedType Sema::getTypeName(const Ident<br>
ParsedType ObjectTypePtr,<br>
bool IsCtorOrDtorName,<br>
bool WantNontrivialTypeSourceInfo,<br>
+ bool IsClassTemplateDeductionContex<wbr>t,<br>
IdentifierInfo **CorrectedII) {<br>
+ // FIXME: Consider allowing this outside C++1z mode as an extension.<br>
+ bool AllowDeducedTemplate = IsClassTemplateDeductionContex<wbr>t &&<br>
+ getLangOpts().CPlusPlus1z && !IsCtorOrDtorName &&<br>
+ !isClassName && !HasTrailingDot;<br>
+<br>
// Determine where we will perform name lookup.<br>
DeclContext *LookupCtx = nullptr;<br>
if (ObjectTypePtr) {<br>
@@ -334,10 +345,11 @@ ParsedType Sema::getTypeName(const Ident<br>
case LookupResult::NotFound:<br>
case LookupResult::NotFoundInCurren<wbr>tInstantiation:<br>
if (CorrectedII) {<br>
- TypoCorrection Correction = CorrectTypo(<br>
- Result.getLookupNameInfo(), Kind, S, SS,<br>
- llvm::make_unique<TypeNameVali<wbr>datorCCC>(true, isClassName),<br>
- CTK_ErrorRecovery);<br>
+ TypoCorrection Correction =<br>
+ CorrectTypo(Result.getLookupNa<wbr>meInfo(), Kind, S, SS,<br>
+ llvm::make_unique<TypeNameVali<wbr>datorCCC>(<br>
+ true, isClassName, AllowDeducedTemplate),<br>
+ CTK_ErrorRecovery);<br>
IdentifierInfo *NewII = Correction.getCorrectionAsIden<wbr>tifierInfo();<br>
TemplateTy Template;<br>
bool MemberOfUnknownSpecialization;<br>
@@ -359,7 +371,8 @@ ParsedType Sema::getTypeName(const Ident<br>
ParsedType Ty = getTypeName(*NewII, NameLoc, S, NewSSPtr,<br>
isClassName, HasTrailingDot, ObjectTypePtr,<br>
IsCtorOrDtorName,<br>
- WantNontrivialTypeSourceInfo);<br>
+ WantNontrivialTypeSourceInfo,<br>
+ IsClassTemplateDeductionContex<wbr>t);<br>
if (Ty) {<br>
diagnoseTypo(Correction,<br>
PDiag(diag::err_unknown_type_o<wbr>r_class_name_suggest)<br>
@@ -391,7 +404,8 @@ ParsedType Sema::getTypeName(const Ident<br>
// Look to see if we have a type anywhere in the list of results.<br>
for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end();<br>
Res != ResEnd; ++Res) {<br>
- if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) {<br>
+ if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||<br>
+ (AllowDeducedTemplate && isTypeTemplate(*Res))) {<br>
if (!IIDecl ||<br>
(*Res)->getLocation().getRawE<wbr>ncoding() <<br>
IIDecl->getLocation().getRawE<wbr>ncoding())<br>
@@ -440,29 +454,13 @@ ParsedType Sema::getTypeName(const Ident<br>
<br>
T = Context.getTypeDeclType(TD);<br>
MarkAnyDeclReferenced(TD->get<wbr>Location(), TD, /*OdrUse=*/false);<br>
-<br>
- // NOTE: avoid constructing an ElaboratedType(Loc) if this is a<br>
- // constructor or destructor name (in such a case, the scope specifier<br>
- // will be attached to the enclosing Expr or Decl node).<br>
- if (SS && SS->isNotEmpty() && !IsCtorOrDtorName) {<br>
- if (WantNontrivialTypeSourceInfo) {<br>
- // Construct a type with type-source information.<br>
- TypeLocBuilder Builder;<br>
- Builder.pushTypeSpec(T).setNam<wbr>eLoc(NameLoc);<br>
-<br>
- T = getElaboratedType(ETK_None, *SS, T);<br>
- ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc<wbr>>(T);<br>
- ElabTL.setElaboratedKeywordLoc<wbr>(SourceLocation());<br>
- ElabTL.setQualifierLoc(SS->get<wbr>WithLocInContext(Context));<br>
- return CreateParsedType(T, Builder.getTypeSourceInfo(Cont<wbr>ext, T));<br>
- } else {<br>
- T = getElaboratedType(ETK_None, *SS, T);<br>
- }<br>
- }<br>
} else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(II<wbr>Decl)) {<br>
(void)DiagnoseUseOfDecl(IDecl<wbr>, NameLoc);<br>
if (!HasTrailingDot)<br>
T = Context.getObjCInterfaceType(I<wbr>Decl);<br>
+ } else if (AllowDeducedTemplate && isTypeTemplate(IIDecl)) {<br>
+ T = Context.getDeducedTemplateSpec<wbr>ializationType(<br>
+ TemplateName(cast<TemplateDecl<wbr>>(IIDecl)), QualType(), false);<br>
}<br>
<br>
if (T.isNull()) {<br>
@@ -470,6 +468,27 @@ ParsedType Sema::getTypeName(const Ident<br>
Result.suppressDiagnostics();<br>
return nullptr;<br>
}<br>
+<br>
+ // NOTE: avoid constructing an ElaboratedType(Loc) if this is a<br>
+ // constructor or destructor name (in such a case, the scope specifier<br>
+ // will be attached to the enclosing Expr or Decl node).<br>
+ if (SS && SS->isNotEmpty() && !IsCtorOrDtorName &&<br>
+ !isa<ObjCInterfaceDecl>(IIDecl<wbr>)) {<br>
+ if (WantNontrivialTypeSourceInfo) {<br>
+ // Construct a type with type-source information.<br>
+ TypeLocBuilder Builder;<br>
+ Builder.pushTypeSpec(T).setNam<wbr>eLoc(NameLoc);<br>
+<br>
+ T = getElaboratedType(ETK_None, *SS, T);<br>
+ ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc<wbr>>(T);<br>
+ ElabTL.setElaboratedKeywordLoc<wbr>(SourceLocation());<br>
+ ElabTL.setQualifierLoc(SS->get<wbr>WithLocInContext(Context));<br>
+ return CreateParsedType(T, Builder.getTypeSourceInfo(Cont<wbr>ext, T));<br>
+ } else {<br>
+ T = getElaboratedType(ETK_None, *SS, T);<br>
+ }<br>
+ }<br>
+<br>
return ParsedType::make(T);<br>
}<br>
<br>
@@ -647,6 +666,7 @@ void Sema::DiagnoseUnknownTypeName(<wbr>Ident<br>
if (Corrected.getCorrectionSpecif<wbr>ier())<br>
tmpSS.MakeTrivial(Context, Corrected.getCorrectionSpecifi<wbr>er(),<br>
SourceRange(IILoc));<br>
+ // FIXME: Support class template argument deduction here.<br>
SuggestedType =<br>
getTypeName(*Corrected.getCor<wbr>rectionAsIdentifierInfo(), IILoc, S,<br>
tmpSS.isSet() ? &tmpSS : SS, false, false, nullptr,<br>
@@ -9740,6 +9760,14 @@ QualType Sema::deduceVarTypeFromInitial<wbr>i<br>
<br>
VarDeclOrName VN{VDecl, Name};<br>
<br>
+ DeducedType *Deduced = Type->getContainedDeducedType(<wbr>);<br>
+ assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type");<br>
+<br>
+ if (isa<DeducedTemplateSpecializa<wbr>tionType>(Deduced)) {<br>
+ Diag(Init->getLocStart(), diag::err_deduced_class_templa<wbr>te_not_supported);<br>
+ return QualType();<br>
+ }<br>
+<br>
ArrayRef<Expr *> DeduceInits = Init;<br>
if (DirectInit) {<br>
if (auto *PL = dyn_cast<ParenListExpr>(Init))<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaE<wbr>xpr.cpp?rev=293207&r1=293206&r<wbr>2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p Thu Jan 26 14:40:47 2017<br>
@@ -3976,7 +3976,8 @@ static void captureVariablyModifiedType(<br>
T = cast<DecltypeType>(Ty)->desuga<wbr>r();<br>
break;<br>
case Type::Auto:<br>
- T = cast<AutoType>(Ty)->getDeduced<wbr>Type();<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ T = cast<DeducedType>(Ty)->getDedu<wbr>cedType();<br>
break;<br>
case Type::TypeOfExpr:<br>
T = cast<TypeOfExprType>(Ty)->getU<wbr>nderlyingExpr()->getType();<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaE<wbr>xprCXX.cpp?rev=293207&r1=29320<wbr>6&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1255,9 +1255,19 @@ Sema::BuildCXXTypeConstructExp<wbr>r(TypeSour<br>
RParenLoc);<br>
}<br>
<br>
+ // C++1z [expr.type.conv]p1:<br>
+ // If the type is a placeholder for a deduced class type, [...perform class<br>
+ // template argument deduction...]<br>
+ DeducedType *Deduced = Ty->getContainedDeducedType();<br>
+ if (Deduced && isa<DeducedTemplateSpecializat<wbr>ionType>(Deduced)) {<br>
+ Diag(TyBeginLoc, diag::err_deduced_class_templa<wbr>te_not_supported);<br>
+ return ExprError();<br>
+ }<br>
+<br>
bool ListInitialization = LParenLoc.isInvalid();<br>
- assert((!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0])))<br>
- && "List initialization must have initializer list as expression.");<br>
+ assert((!ListInitialization ||<br>
+ (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0]))) &&<br>
+ "List initialization must have initializer list as expression.");<br>
SourceRange FullRange = SourceRange(TyBeginLoc,<br>
ListInitialization ? Exprs[0]->getSourceRange().get<wbr>End() : RParenLoc);<br>
<br>
@@ -1646,6 +1656,11 @@ Sema::BuildCXXNew(SourceRange Range, boo<br>
<br>
// C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for.<br>
if (AllocType->isUndeducedType()) {<br>
+ if (isa<DeducedTemplateSpecializa<wbr>tionType>(<br>
+ AllocType->getContainedDeduced<wbr>Type()))<br>
+ return ExprError(Diag(TypeRange.getBe<wbr>gin(),<br>
+ diag::err_deduced_class_templa<wbr>te_not_supported));<br>
+<br>
if (initStyle == CXXNewExpr::NoInit || NumInits == 0)<br>
return ExprError(Diag(StartLoc, diag::err_auto_new_requires_ct<wbr>or_arg)<br>
<< AllocType << TypeRange);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaL<wbr>ookup.cpp?rev=293207&r1=293206<wbr>&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp Thu Jan 26 14:40:47 2017<br>
@@ -2694,6 +2694,7 @@ addAssociatedClassesAndNamespa<wbr>ces(Associ<br>
<br>
// Non-deduced auto types only get here for error cases.<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
break;<br>
<br>
// If T is an Objective-C object or interface type, or a pointer to an<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaT<wbr>emplate.cpp?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp Thu Jan 26 14:40:47 2017<br>
@@ -4439,6 +4439,11 @@ bool UnnamedLocalNoLinkageFinder::V<wbr>isitA<br>
return Visit(T->getDeducedType());<br>
}<br>
<br>
+bool UnnamedLocalNoLinkageFinder::V<wbr>isitDeducedTemplateSpecializat<wbr>ionType(<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T) {<br>
+ return Visit(T->getDeducedType());<br>
+}<br>
+<br>
bool UnnamedLocalNoLinkageFinder::V<wbr>isitRecordType(const RecordType* T) {<br>
return VisitTagDecl(T->getDecl());<br>
}<br>
@@ -8786,6 +8791,9 @@ Sema::CheckTypenameType(Elabor<wbr>atedTypeKe<br>
Context.getTypeDeclType(Type))<wbr>;<br>
}<br>
<br>
+ // FIXME: Form a deduced template specialization type if we get a template<br>
+ // declaration here.<br>
+<br>
DiagID = diag::err_typename_nested_not_<wbr>type;<br>
Referenced = Result.getFoundDecl();<br>
break;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplat<wbr>eDeduction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaT<wbr>emplateDeduction.cpp?rev=29320<wbr>7&r1=293206&r2=293207&view=dif<wbr>f</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaTemplat<wbr>eDeduction.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplat<wbr>eDeduction.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1723,6 +1723,7 @@ DeduceTemplateArgumentsByTypeM<wbr>atch(Sema<br>
case Type::Decltype:<br>
case Type::UnaryTransform:<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
case Type::DependentTemplateSpecial<wbr>ization:<br>
case Type::PackExpansion:<br>
case Type::Pipe:<br>
@@ -5152,8 +5153,9 @@ MarkUsedTemplateParameters(AST<wbr>Context &C<br>
break;<br>
<br>
case Type::Auto:<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
MarkUsedTemplateParameters(Ct<wbr>x,<br>
- cast<AutoType>(T)->getDeduced<wbr>Type(),<br>
+ cast<DeducedType>(T)->getDedu<wbr>cedType(),<br>
OnlyDeduced, Depth, Used);<br>
<br>
// None of these types have any template parameters in them.<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaType.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaT<wbr>ype.cpp?rev=293207&r1=293206&r<wbr>2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaType.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaType.cp<wbr>p Thu Jan 26 14:40:47 2017<br>
@@ -2778,12 +2778,20 @@ static QualType GetDeclSpecTypeForDeclar<br>
distributeTypeAttrsFromDeclar<wbr>ator(state, T);<br>
<br>
// C++11 [dcl.spec.auto]p5: reject 'auto' if it is not in an allowed context.<br>
- if (D.getDeclSpec().containsPlace<wbr>holderType()) {<br>
+ if (DeducedType *Deduced = T->getContainedDeducedType()) {<br>
+ AutoType *Auto = dyn_cast<AutoType>(Deduced);<br>
int Error = -1;<br>
<br>
+ // Is this a 'auto' or 'decltype(auto)' type (as opposed to __auto_type or<br>
+ // class template argument deduction)?<br>
+ bool IsCXXAutoType =<br>
+ (Auto && Auto->getKeyword() != AutoTypeKeyword::GNUAutoType);<br>
+<br>
switch (D.getContext()) {<br>
case Declarator::LambdaExprContext:<br>
- llvm_unreachable("Can't specify a type specifier in lambda grammar");<br>
+ // Declared return type of a lambda-declarator is implicit and is always<br>
+ // 'auto'.<br>
+ break;<br>
case Declarator::ObjCParameterConte<wbr>xt:<br>
case Declarator::ObjCResultContext:<br>
case Declarator::PrototypeContext:<br>
@@ -2791,8 +2799,8 @@ static QualType GetDeclSpecTypeForDeclar<br>
break;<br>
case Declarator::LambdaExprParamete<wbr>rContext:<br>
// In C++14, generic lambdas allow 'auto' in their parameters.<br>
- if (!(SemaRef.getLangOpts().CPlus<wbr>Plus14<br>
- && D.getDeclSpec().getTypeSpecTyp<wbr>e() == DeclSpec::TST_auto))<br>
+ if (!SemaRef.getLangOpts().CPlusP<wbr>lus14 ||<br>
+ !Auto || Auto->getKeyword() != AutoTypeKeyword::Auto)<br>
Error = 16;<br>
break;<br>
case Declarator::MemberContext: {<br>
@@ -2807,6 +2815,8 @@ static QualType GetDeclSpecTypeForDeclar<br>
case TTK_Class: Error = 5; /* Class member */ break;<br>
case TTK_Interface: Error = 6; /* Interface member */ break;<br>
}<br>
+ if (D.getDeclSpec().isFriendSpeci<wbr>fied())<br>
+ Error = 20; // Friend type<br>
break;<br>
}<br>
case Declarator::CXXCatchContext:<br>
@@ -2814,8 +2824,10 @@ static QualType GetDeclSpecTypeForDeclar<br>
Error = 7; // Exception declaration<br>
break;<br>
case Declarator::TemplateParamConte<wbr>xt:<br>
- if (!SemaRef.getLangOpts().CPlusP<wbr>lus1z)<br>
- Error = 8; // Template parameter<br>
+ if (isa<DeducedTemplateSpecializa<wbr>tionType>(Deduced))<br>
+ Error = 19; // Template parameter<br>
+ else if (!SemaRef.getLangOpts().CPlusP<wbr>lus1z)<br>
+ Error = 8; // Template parameter (until C++1z)<br>
break;<br>
case Declarator::BlockLiteralContex<wbr>t:<br>
Error = 9; // Block literal<br>
@@ -2828,15 +2840,17 @@ static QualType GetDeclSpecTypeForDeclar<br>
Error = 12; // Type alias<br>
break;<br>
case Declarator::TrailingReturnCont<wbr>ext:<br>
- if (!SemaRef.getLangOpts().CPlusP<wbr>lus14 ||<br>
- D.getDeclSpec().getTypeSpecTyp<wbr>e() == DeclSpec::TST_auto_type)<br>
+ if (!SemaRef.getLangOpts().CPlusP<wbr>lus14 || !IsCXXAutoType)<br>
Error = 13; // Function return type<br>
break;<br>
case Declarator::ConversionIdContex<wbr>t:<br>
- if (!SemaRef.getLangOpts().CPlusP<wbr>lus14 ||<br>
- D.getDeclSpec().getTypeSpecTyp<wbr>e() == DeclSpec::TST_auto_type)<br>
+ if (!SemaRef.getLangOpts().CPlusP<wbr>lus14 || !IsCXXAutoType)<br>
Error = 14; // conversion-type-id<br>
break;<br>
+ case Declarator::FunctionalCastCont<wbr>ext:<br>
+ if (isa<DeducedTemplateSpecializa<wbr>tionType>(Deduced))<br>
+ break;<br>
+ LLVM_FALLTHROUGH;<br>
case Declarator::TypeNameContext:<br>
Error = 15; // Generic<br>
break;<br>
@@ -2845,9 +2859,14 @@ static QualType GetDeclSpecTypeForDeclar<br>
case Declarator::ForContext:<br>
case Declarator::InitStmtContext:<br>
case Declarator::ConditionContext:<br>
+ // FIXME: P0091R3 (erroneously) does not permit class template argument<br>
+ // deduction in conditions, for-init-statements, and other declarations<br>
+ // that are not simple-declarations.<br>
break;<br>
case Declarator::CXXNewContext:<br>
- if (D.getDeclSpec().getTypeSpecTy<wbr>pe() == DeclSpec::TST_auto_type)<br>
+ // FIXME: P0091R3 does not permit class template argument deduction here,<br>
+ // but we follow GCC and allow it anyway.<br>
+ if (!IsCXXAutoType && !isa<DeducedTemplateSpecializa<wbr>tionType>(Deduced))<br>
Error = 17; // 'new' type<br>
break;<br>
case Declarator::KNRTypeListContext<wbr>:<br>
@@ -2861,8 +2880,7 @@ static QualType GetDeclSpecTypeForDeclar<br>
// In Objective-C it is an error to use 'auto' on a function declarator<br>
// (and everywhere for '__auto_type').<br>
if (D.isFunctionDeclarator() &&<br>
- (!SemaRef.getLangOpts().CPlusP<wbr>lus11 ||<br>
- D.getDeclSpec().getTypeSpecTy<wbr>pe() == DeclSpec::TST_auto_type))<br>
+ (!SemaRef.getLangOpts().CPlusP<wbr>lus11 || !IsCXXAutoType))<br>
Error = 13;<br>
<br>
bool HaveTrailing = false;<br>
@@ -2872,8 +2890,8 @@ static QualType GetDeclSpecTypeForDeclar<br>
// level. Check all declarator chunks (outermost first) anyway, to give<br>
// better diagnostics.<br>
// We don't support '__auto_type' with trailing return types.<br>
- if (SemaRef.getLangOpts().CPlusPl<wbr>us11 &&<br>
- D.getDeclSpec().getTypeSpecTyp<wbr>e() != DeclSpec::TST_auto_type) {<br>
+ // FIXME: Should we only do this for 'auto' and not 'decltype(auto)'?<br>
+ if (SemaRef.getLangOpts().CPlusPl<wbr>us11 && IsCXXAutoType) {<br>
for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {<br>
unsigned chunkIndex = e - i - 1;<br>
state.setCurrentChunkIndex(ch<wbr>unkIndex);<br>
@@ -2894,15 +2912,28 @@ static QualType GetDeclSpecTypeForDeclar<br>
AutoRange = D.getName().getSourceRange();<br>
<br>
if (Error != -1) {<br>
- unsigned Keyword;<br>
- switch (D.getDeclSpec().getTypeSpecTy<wbr>pe()) {<br>
- case DeclSpec::TST_auto: Keyword = 0; break;<br>
- case DeclSpec::TST_decltype_auto: Keyword = 1; break;<br>
- case DeclSpec::TST_auto_type: Keyword = 2; break;<br>
- default: llvm_unreachable("unknown auto TypeSpecType");<br>
+ unsigned Kind;<br>
+ if (Auto) {<br>
+ switch (Auto->getKeyword()) {<br>
+ case AutoTypeKeyword::Auto: Kind = 0; break;<br>
+ case AutoTypeKeyword::DecltypeAuto: Kind = 1; break;<br>
+ case AutoTypeKeyword::GNUAutoType: Kind = 2; break;<br>
+ }<br>
+ } else {<br>
+ assert(isa<DeducedTemplateSpec<wbr>ializationType>(Deduced) &&<br>
+ "unknown auto type");<br>
+ Kind = 3;<br>
}<br>
+<br>
+ auto *DTST = dyn_cast<DeducedTemplateSpecia<wbr>lizationType>(Deduced);<br>
+ TemplateName TN = DTST ? DTST->getTemplateName() : TemplateName();<br>
+<br>
SemaRef.Diag(AutoRange.getBeg<wbr>in(), diag::err_auto_not_allowed)<br>
- << Keyword << Error << AutoRange;<br>
+ << Kind << Error << (int)SemaRef.getTemplateNameKi<wbr>ndForDiagnostics(TN)<br>
+ << QualType(Deduced, 0) << AutoRange;<br>
+ if (auto *TD = TN.getAsTemplateDecl())<br>
+ SemaRef.Diag(TD->getLocation()<wbr>, diag::note_template_decl_here)<wbr>;<br>
+<br>
T = SemaRef.Context.IntTy;<br>
D.setInvalidType(true);<br>
} else if (!HaveTrailing) {<br>
@@ -2942,6 +2973,7 @@ static QualType GetDeclSpecTypeForDeclar<br>
DiagID = diag::err_type_defined_in_alia<wbr>s_template;<br>
break;<br>
case Declarator::TypeNameContext:<br>
+ case Declarator::FunctionalCastCont<wbr>ext:<br>
case Declarator::ConversionIdContex<wbr>t:<br>
case Declarator::TemplateParamConte<wbr>xt:<br>
case Declarator::CXXNewContext:<br>
@@ -3623,17 +3655,32 @@ static TypeSourceInfo *GetFullTypeForDec<br>
<br>
// If T is 'decltype(auto)', the only declarators we can have are parens<br>
// and at most one function declarator if this is a function declaration.<br>
- if (const AutoType *AT = T->getAs<AutoType>()) {<br>
- if (AT->isDecltypeAuto()) {<br>
+ // If T is a deduced class template specialization type, we can have no<br>
+ // declarator chunks at all.<br>
+ if (auto *DT = T->getAs<DeducedType>()) {<br>
+ const AutoType *AT = T->getAs<AutoType>();<br>
+ bool IsClassTemplateDeduction = isa<DeducedTemplateSpecializat<wbr>ionType>(DT);<br>
+ if ((AT && AT->isDecltypeAuto()) || IsClassTemplateDeduction) {<br>
for (unsigned I = 0, E = D.getNumTypeObjects(); I != E; ++I) {<br>
unsigned Index = E - I - 1;<br>
DeclaratorChunk &DeclChunk = D.getTypeObject(Index);<br>
- unsigned DiagId = diag::err_decltype_auto_compou<wbr>nd_type;<br>
+ unsigned DiagId = IsClassTemplateDeduction<br>
+ ? diag::err_deduced_class_templa<wbr>te_compound_type<br>
+ : diag::err_decltype_auto_compou<wbr>nd_type;<br>
unsigned DiagKind = 0;<br>
switch (DeclChunk.Kind) {<br>
case DeclaratorChunk::Paren:<br>
+ // FIXME: Rejecting this is a little silly.<br>
+ if (IsClassTemplateDeduction) {<br>
+ DiagKind = 4;<br>
+ break;<br>
+ }<br>
continue;<br>
case DeclaratorChunk::Function: {<br>
+ if (IsClassTemplateDeduction) {<br>
+ DiagKind = 3;<br>
+ break;<br>
+ }<br>
unsigned FnIndex;<br>
if (D.isFunctionDeclarationContex<wbr>t() &&<br>
D.isFunctionDeclarator(FnInde<wbr>x) && FnIndex == Index)<br>
@@ -3834,6 +3881,7 @@ static TypeSourceInfo *GetFullTypeForDec<br>
case Declarator::TemplateParamConte<wbr>xt:<br>
case Declarator::TemplateTypeArgCon<wbr>text:<br>
case Declarator::TypeNameContext:<br>
+ case Declarator::FunctionalCastCont<wbr>ext:<br>
// Don't infer in these contexts.<br>
break;<br>
}<br>
@@ -4713,6 +4761,7 @@ static TypeSourceInfo *GetFullTypeForDec<br>
case Declarator::ObjCParameterConte<wbr>xt: // FIXME: special diagnostic here?<br>
case Declarator::ObjCResultContext:<wbr> // FIXME: special diagnostic here?<br>
case Declarator::TypeNameContext:<br>
+ case Declarator::FunctionalCastCont<wbr>ext:<br>
case Declarator::CXXNewContext:<br>
case Declarator::AliasDeclContext:<br>
case Declarator::AliasTemplateConte<wbr>xt:<br>
<br>
Modified: cfe/trunk/lib/Sema/TreeTransfo<wbr>rm.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/TreeT<wbr>ransform.h?rev=293207&r1=29320<wbr>6&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/TreeTransfo<wbr>rm.h (original)<br>
+++ cfe/trunk/lib/Sema/TreeTransfo<wbr>rm.h Thu Jan 26 14:40:47 2017<br>
@@ -876,6 +876,14 @@ public:<br>
/*IsDependent*/ false);<br>
}<br>
<br>
+ /// By default, builds a new DeducedTemplateSpecializationT<wbr>ype with the given<br>
+ /// deduced type.<br>
+ QualType RebuildDeducedTemplateSpeciali<wbr>zationType(TemplateName Template,<br>
+ QualType Deduced) {<br>
+ return SemaRef.Context.getDeducedTemp<wbr>lateSpecializationType(<br>
+ Template, Deduced, /*IsDependent*/ false);<br>
+ }<br>
+<br>
/// \brief Build a new template specialization type.<br>
///<br>
/// By default, performs semantic analysis when building the template<br>
@@ -5344,6 +5352,37 @@ QualType TreeTransform<Derived>::Transf<wbr>o<br>
<br>
return Result;<br>
}<br>
+<br>
+template<typename Derived><br>
+QualType TreeTransform<Derived>::Transf<wbr>ormDeducedTemplateSpecializati<wbr>onType(<br>
+ TypeLocBuilder &TLB, DeducedTemplateSpecializationT<wbr>ypeLoc TL) {<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T = TL.getTypePtr();<br>
+<br>
+ CXXScopeSpec SS;<br>
+ TemplateName TemplateName = getDerived().TransformTemplate<wbr>Name(<br>
+ SS, T->getTemplateName(), TL.getTemplateNameLoc());<br>
+ if (TemplateName.isNull())<br>
+ return QualType();<br>
+<br>
+ QualType OldDeduced = T->getDeducedType();<br>
+ QualType NewDeduced;<br>
+ if (!OldDeduced.isNull()) {<br>
+ NewDeduced = getDerived().TransformType(Old<wbr>Deduced);<br>
+ if (NewDeduced.isNull())<br>
+ return QualType();<br>
+ }<br>
+<br>
+ QualType Result = getDerived().RebuildDeducedTem<wbr>plateSpecializationType(<br>
+ TemplateName, NewDeduced);<br>
+ if (Result.isNull())<br>
+ return QualType();<br>
+<br>
+ DeducedTemplateSpecializationT<wbr>ypeLoc NewTL =<br>
+ TLB.push<DeducedTemplateSpecia<wbr>lizationTypeLoc>(Result);<br>
+ NewTL.setTemplateNameLoc(TL.ge<wbr>tTemplateNameLoc());<br>
+<br>
+ return Result;<br>
+}<br>
<br>
template<typename Derived><br>
QualType TreeTransform<Derived>::Transf<wbr>ormRecordType(TypeLocBuilder &TLB,<br>
<br>
Modified: cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Serializat<wbr>ion/ASTReader.cpp?rev=293207&r<wbr>1=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp Thu Jan 26 14:40:47 2017<br>
@@ -5651,6 +5651,14 @@ QualType ASTReader::readTypeRecord(unsi<wbr>g<br>
return Context.getAutoType(Deduced, Keyword, IsDependent);<br>
}<br>
<br>
+ case TYPE_DEDUCED_TEMPLATE_SPECIALI<wbr>ZATION: {<br>
+ TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx);<br>
+ QualType Deduced = readType(*Loc.F, Record, Idx);<br>
+ bool IsDependent = Deduced.isNull() ? Record[Idx++] : false;<br>
+ return Context.getDeducedTemplateSpec<wbr>ializationType(Name, Deduced,<br>
+ IsDependent);<br>
+ }<br>
+<br>
case TYPE_RECORD: {<br>
if (Record.size() != 2) {<br>
Error("incorrect encoding of record type");<br>
@@ -6082,6 +6090,11 @@ void TypeLocReader::VisitAutoTypeLo<wbr>c(Aut<br>
TL.setNameLoc(ReadSourceLocat<wbr>ion());<br>
}<br>
<br>
+void TypeLocReader::VisitDeducedTem<wbr>plateSpecializationTypeLoc(<br>
+ DeducedTemplateSpecializationT<wbr>ypeLoc TL) {<br>
+ TL.setTemplateNameLoc(ReadSour<wbr>ceLocation());<br>
+}<br>
+<br>
void TypeLocReader::VisitRecordType<wbr>Loc(RecordTypeLoc TL) {<br>
TL.setNameLoc(ReadSourceLocat<wbr>ion());<br>
}<br>
<br>
Modified: cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Serializat<wbr>ion/ASTWriter.cpp?rev=293207&r<wbr>1=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp Thu Jan 26 14:40:47 2017<br>
@@ -349,6 +349,15 @@ void ASTTypeWriter::VisitAutoType(c<wbr>onst<br>
Code = TYPE_AUTO;<br>
}<br>
<br>
+void ASTTypeWriter::VisitDeducedTem<wbr>plateSpecializationType(<br>
+ const DeducedTemplateSpecializationT<wbr>ype *T) {<br>
+ Record.AddTemplateName(T->getT<wbr>emplateName());<br>
+ Record.AddTypeRef(T->getDeduce<wbr>dType());<br>
+ if (T->getDeducedType().isNull())<br>
+ Record.push_back(T->isDependen<wbr>tType());<br>
+ Code = TYPE_DEDUCED_TEMPLATE_SPECIALI<wbr>ZATION;<br>
+}<br>
+<br>
void ASTTypeWriter::VisitTagType(co<wbr>nst TagType *T) {<br>
Record.push_back(T->isDepende<wbr>ntType());<br>
Record.AddDeclRef(T->getDecl(<wbr>)->getCanonicalDecl());<br>
@@ -683,6 +692,11 @@ void TypeLocWriter::VisitAutoTypeLo<wbr>c(Aut<br>
Record.AddSourceLocation(TL.g<wbr>etNameLoc());<br>
}<br>
<br>
+void TypeLocWriter::VisitDeducedTem<wbr>plateSpecializationTypeLoc(<br>
+ DeducedTemplateSpecializationT<wbr>ypeLoc TL) {<br>
+ Record.AddSourceLocation(TL.ge<wbr>tTemplateNameLoc());<br>
+}<br>
+<br>
void TypeLocWriter::VisitRecordType<wbr>Loc(RecordTypeLoc TL) {<br>
Record.AddSourceLocation(TL.g<wbr>etNameLoc());<br>
}<br>
<br>
Modified: cfe/trunk/test/CXX/dcl.dcl/dcl<wbr>.spec/dcl.type/dcl.spec.auto/p<wbr>5.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/dcl.d<wbr>cl/dcl.spec/dcl.type/dcl.spec.<wbr>auto/p5.cpp?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CXX/dcl.dcl/dcl<wbr>.spec/dcl.type/dcl.spec.auto/p<wbr>5.cpp (original)<br>
+++ cfe/trunk/test/CXX/dcl.dcl/dcl<wbr>.spec/dcl.type/dcl.spec.auto/p<wbr>5.cpp Thu Jan 26 14:40:47 2017<br>
@@ -9,7 +9,7 @@ struct S {<br>
<br>
void f() throw (auto); // expected-error{{'auto' not allowed here}}<br>
<br>
- friend auto; // expected-error{{'auto' not allowed in non-static struct member}}<br>
+ friend auto; // expected-error{{'auto' not allowed in friend declaration}}<br>
<br>
operator auto(); // expected-error{{'auto' not allowed in conversion function type}}<br>
};<br>
<br>
Modified: cfe/trunk/test/CXX/drs/dr5xx.c<wbr>pp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/drs/d<wbr>r5xx.cpp?rev=293207&r1=293206&<wbr>r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CXX/drs/dr5xx.c<wbr>pp (original)<br>
+++ cfe/trunk/test/CXX/drs/dr5xx.c<wbr>pp Thu Jan 26 14:40:47 2017<br>
@@ -877,13 +877,25 @@ namespace dr583 { // dr583: 4<br>
namespace dr585 { // dr585: yes<br>
template<typename> struct T;<br>
struct A {<br>
- friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}<br>
+ friend T;<br>
+#if __cplusplus <= 201402L<br>
+ // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}}<br>
+#else<br>
+ // expected-error@-4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}<br>
+ // expected-note@-7 {{here}}<br>
+#endif<br>
// FIXME: It's not clear whether the standard allows this or what it means,<br>
// but the DR585 writeup suggests it as an alternative.<br>
template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}<br>
};<br>
template<template<typename> class T> struct B {<br>
- friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}<br>
+ friend T;<br>
+#if __cplusplus <= 201402L<br>
+ // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}}<br>
+#else<br>
+ // expected-error@-4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}<br>
+ // expected-note@-6 {{here}}<br>
+#endif<br>
template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}<br>
};<br>
}<br>
<br>
Modified: cfe/trunk/test/Parser/backtrac<wbr>k-off-by-one.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/backtrack-off-by-one.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/Parser/ba<wbr>cktrack-off-by-one.cpp?rev=293<wbr>207&r1=293206&r2=293207&view=d<wbr>iff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Parser/backtrac<wbr>k-off-by-one.cpp (original)<br>
+++ cfe/trunk/test/Parser/backtrac<wbr>k-off-by-one.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1,6 +1,7 @@<br>
// RUN: %clang_cc1 -verify %s<br>
// RUN: %clang_cc1 -verify %s -std=c++98<br>
// RUN: %clang_cc1 -verify %s -std=c++11<br>
+// RUN: %clang_cc1 -verify %s -std=c++1z<br>
<br>
// PR25946<br>
// We had an off-by-one error in an assertion when annotating A<int> below. Our<br>
@@ -13,9 +14,13 @@ template <typename T> class A {};<br>
// expected-error@+1 {{expected '{' after base class list}}<br>
template <typename T> class B : T // not ',' or '{'<br>
#if __cplusplus < 201103L<br>
-// expected-error@+4 {{expected ';' after top level declarator}}<br>
+// expected-error@+8 {{expected ';' after top level declarator}}<br>
+#endif<br>
+#if __cplusplus <= 201402L<br>
+// expected-error@+5 {{C++ requires a type specifier for all declarations}}<br>
+#else<br>
+// expected-error@+3 {{expected unqualified-id}}<br>
#endif<br>
-// expected-error@+2 {{C++ requires a type specifier for all declarations}}<br>
// expected-error@+1 {{expected ';' after class}}<br>
A<int> {<br>
};<br>
<br>
Added: cfe/trunk/test/Parser/cxx1z-cl<wbr>ass-template-argument-deductio<wbr>n.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp?rev=293207&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/Parser/cx<wbr>x1z-class-template-argument-de<wbr>duction.cpp?rev=293207&view=au<wbr>to</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Parser/cxx1z-cl<wbr>ass-template-argument-deductio<wbr>n.cpp (added)<br>
+++ cfe/trunk/test/Parser/cxx1z-cl<wbr>ass-template-argument-deductio<wbr>n.cpp Thu Jan 26 14:40:47 2017<br>
@@ -0,0 +1,131 @@<br>
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -verify %s<br>
+<br>
+template<typename T> struct A {}; // expected-note 31{{declared here}}<br>
+<br>
+// Make sure we still correctly parse cases where a template can appear without arguments.<br>
+namespace template_template_arg {<br>
+ template<template<typename> typename> struct X {};<br>
+ template<typename> struct Y {};<br>
+<br>
+ X<A> xa;<br>
+ Y<A> ya; // expected-error {{requires template arguments}}<br>
+ X<::A> xcca;<br>
+ Y<::A> ycca; // expected-error {{requires template arguments}}<br>
+<br>
+ template<template<typename> typename = A> struct XD {};<br>
+ template<typename = A> struct YD {}; // expected-error {{requires template arguments}}<br>
+ template<template<typename> typename = ::A> struct XCCD {};<br>
+ template<typename = ::A> struct YCCD {}; // expected-error {{requires template arguments}}<br>
+<br>
+ // FIXME: replacing the invalid type with 'int' here is horrible<br>
+ template <A a = A<int>()> class C { }; // expected-error {{requires template arguments}} expected-error {{not implicitly convertible to 'int'}}<br>
+ template<typename T = A> struct G { }; // expected-error {{requires template arguments}}<br>
+}<br>
+<br>
+namespace injected_class_name {<br>
+ template<typename T> struct A {<br>
+ A(T);<br>
+ void f(int) {<br>
+ A a = 1;<br>
+ injected_class_name::A b = 1; // expected-error {{not yet supported}}<br>
+ }<br>
+ void f(T);<br>
+ };<br>
+ A<short> ai = 1;<br>
+ A<double>::A b(1); // expected-error {{constructor name}}<br>
+}<br>
+<br>
+struct member {<br>
+ A a; // expected-error {{requires template arguments}}<br>
+ A *b; // expected-error {{requires template arguments}}<br>
+ const A c; // expected-error {{requires template arguments}}<br>
+<br>
+ void f() throw (A); // expected-error {{requires template arguments}}<br>
+<br>
+ friend A; // expected-error {{requires template arguments; argument deduction not allowed in friend declaration}}<br>
+<br>
+ operator A(); // expected-error {{requires template arguments; argument deduction not allowed in conversion function type}}<br>
+<br>
+ static A x; // expected-error {{requires an initializer}}<br>
+ static A y = 0; // expected-error {{not yet supported}}<br>
+};<br>
+<br>
+namespace in_typedef {<br>
+ typedef A *AutoPtr; // expected-error {{requires template arguments; argument deduction not allowed in typedef}}<br>
+ typedef A (*PFun)(int a); // expected-error{{requires template arguments; argument deduction not allowed in typedef}}<br>
+ typedef A Fun(int a) -> decltype(a + a); // expected-error{{requires template arguments; argument deduction not allowed in function return type}}<br>
+}<br>
+<br>
+namespace stmt {<br>
+ void g(A a) { // expected-error{{requires template arguments; argument deduction not allowed in function prototype}}<br>
+ try { }<br>
+ catch (A &a) { } // expected-error{{requires template arguments; argument deduction not allowed in exception declaration}}<br>
+ catch (const A a) { } // expected-error{{requires template arguments; argument deduction not allowed in exception declaration}}<br>
+ try { } catch (A a) { } // expected-error{{requires template arguments; argument deduction not allowed in exception declaration}}<br>
+<br>
+ // FIXME: The standard only permits class template argument deduction in a<br>
+ // simple-declaration or cast. We also permit it in conditions,<br>
+ // for-range-declarations, member-declarations for static data members, and<br>
+ // new-expressions, because not doing so would be bizarre.<br>
+ A local = 0; // expected-error {{not yet supported}}<br>
+ static A local_static = 0; // expected-error {{not yet supported}}<br>
+ static thread_local A thread_local_static = 0; // expected-error {{not yet supported}}<br>
+ if (A a = 0) {} // expected-error {{not yet supported}}<br>
+ if (A a = 0; a) {} // expected-error {{not yet supported}}<br>
+ switch (A a = 0) {} // expected-error {{not yet supported}}<br>
+ switch (A a = 0; a) {} // expected-error {{not yet supported}}<br>
+ for (A a = 0; a; /**/) {} // expected-error {{not yet supported}}<br>
+ for (/**/; A a = 0; /**/) {} // expected-error {{not yet supported}}<br>
+ while (A a = 0) {} // expected-error {{not yet supported}}<br>
+ int arr[3];<br>
+ for (A a : arr) {} // expected-error {{not yet supported}}<br>
+ }<br>
+<br>
+ namespace std {<br>
+ class type_info;<br>
+ }<br>
+}<br>
+<br>
+namespace expr {<br>
+ template<typename T> struct U {};<br>
+ void j() {<br>
+ (void)typeid(A); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)sizeof(A); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)__alignof(A); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+<br>
+ U<A> v; // expected-error {{requires template arguments}}<br>
+<br>
+ int n;<br>
+ (void)dynamic_cast<A&>(n); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)static_cast<A*>(&n); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)reinterpret_cast<A*>(&n)<wbr>; // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)const_cast<A>(n); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ (void)*(A*)(&n); // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+<br>
+ (void)A(n); // expected-error {{not yet supported}}<br>
+ (void)A{n}; // expected-error {{not yet supported}}<br>
+ (void)new A(n); // expected-error {{not yet supported}}<br>
+ (void)new A{n}; // expected-error {{not yet supported}}<br>
+ // FIXME: We should diagnose the lack of an initializer here.<br>
+ (void)new A; // expected-error {{not yet supported}}<br>
+ }<br>
+}<br>
+<br>
+namespace decl {<br>
+ enum E : A {}; // expected-error{{requires template arguments; argument deduction not allowed here}}<br>
+ struct F : A {}; // expected-error{{expected class name}}<br>
+<br>
+ using B = A; // expected-error{{requires template arguments}}<br>
+<br>
+ auto k() -> A; // expected-error{{requires template arguments}}<br>
+<br>
+ A a; // expected-error {{requires an initializer}}<br>
+ A b = 0; // expected-error {{not yet supported}}<br>
+ A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}<br>
+ A *p = 0; // expected-error {{cannot form pointer to deduced class template specialization type}}<br>
+ A &r = *p; // expected-error {{cannot form reference to deduced class template specialization type}}<br>
+ A arr[3] = 0; // expected-error {{cannot form array of deduced class template specialization type}}<br>
+ A F::*pm = 0; // expected-error {{cannot form pointer to deduced class template specialization type}}<br>
+ A (*fp)() = 0; // expected-error {{cannot form function returning deduced class template specialization type}}<br>
+ A [x, y] = 0; // expected-error {{cannot be declared with type 'A'}} expected-error {{not yet supported}}<br>
+}<br>
<br>
Modified: cfe/trunk/test/SemaTemplate/te<wbr>mp_arg.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaTempl<wbr>ate/temp_arg.cpp?rev=293207&r1<wbr>=293206&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaTemplate/te<wbr>mp_arg.cpp (original)<br>
+++ cfe/trunk/test/SemaTemplate/te<wbr>mp_arg.cpp Thu Jan 26 14:40:47 2017<br>
@@ -10,7 +10,7 @@ A<int, 0, X> * a1;<br>
<br>
A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}}<br>
A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}}<br>
-A a3; // expected-error{{use of class template 'A' requires template arguments}}<br>
+A a4; // expected-error{{use of class template 'A' requires template arguments}}<br>
<br>
namespace test0 {<br>
template <class t> class foo {};<br>
<br>
Modified: cfe/trunk/test/SemaTemplate/ty<wbr>pename-specifier-3.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaTempl<wbr>ate/typename-specifier-3.cpp?r<wbr>ev=293207&r1=293206&r2=293207&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaTemplate/ty<wbr>pename-specifier-3.cpp (original)<br>
+++ cfe/trunk/test/SemaTemplate/ty<wbr>pename-specifier-3.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1,7 +1,7 @@<br>
// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
<br>
// PR4364<br>
-template<class T> struct a {<br>
+template<class T> struct a { // expected-note {{here}}<br>
T b() {<br>
return typename T::x();<br>
}<br>
@@ -17,3 +17,4 @@ B c() {<br>
// Some extra tests for invalid cases<br>
template<class T> struct test2 { T b() { return typename T::a; } }; // expected-error{{expected '(' for function-style cast or type construction}}<br>
template<class T> struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}}<br>
+template<class T> struct test4 { T b() { return typename ::a; } }; // expected-error{{refers to non-type member}} expected-error{{expected '(' for function-style cast or type construction}}<br>
<br>
Modified: cfe/trunk/tools/libclang/CInde<wbr>x.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/tools/libclang<wbr>/CIndex.cpp?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/libclang/CInde<wbr>x.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CInde<wbr>x.cpp Thu Jan 26 14:40:47 2017<br>
@@ -1640,6 +1640,15 @@ bool CursorVisitor::VisitAdjustedTy<wbr>peLoc<br>
return Visit(TL.getOriginalLoc());<br>
}<br>
<br>
+bool CursorVisitor::VisitDeducedTem<wbr>plateSpecializationTypeLoc(<br>
+ DeducedTemplateSpecializationT<wbr>ypeLoc TL) {<br>
+ if (VisitTemplateName(TL.getTypeP<wbr>tr()->getTemplateName(),<br>
+ TL.getTemplateNameLoc()))<br>
+ return true;<br>
+<br>
+ return false;<br>
+}<br>
+<br>
bool CursorVisitor::VisitTemplateSp<wbr>ecializationTypeLoc(<br>
TemplateSpecializationTypeLoc TL) {<br>
// Visit the template name.<br>
<br>
Modified: cfe/trunk/tools/libclang/CXTyp<wbr>e.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=293207&r1=293206&r2=293207&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/tools/libclang<wbr>/CXType.cpp?rev=293207&r1=2932<wbr>06&r2=293207&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/libclang/CXTyp<wbr>e.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CXTyp<wbr>e.cpp Thu Jan 26 14:40:47 2017<br>
@@ -452,7 +452,8 @@ try_again:<br>
break;<br>
<br>
case Type::Auto:<br>
- TP = cast<AutoType>(TP)->getDeduced<wbr>Type().getTypePtrOrNull();<br>
+ case Type::DeducedTemplateSpecializ<wbr>ation:<br>
+ TP = cast<DeducedType>(TP)->getDedu<wbr>cedType().getTypePtrOrNull();<br>
if (TP)<br>
goto try_again;<br>
break;<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>