diff options
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 69cd884300..96d17be931 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -14,6 +14,7 @@ #include "Sema.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/Parse/DeclSpec.h" using namespace clang; @@ -473,7 +474,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, /// This routine checks the function type according to C++ rules and /// under the assumption that the result type and parameter types have /// just been instantiated from a template. It therefore duplicates -/// some of the behavior of GetTypeForDeclaration, but in a much +/// some of the behavior of GetTypeForDeclarator, but in a much /// simpler form that is only suitable for this narrow use case. /// /// \param T The return type of the function. @@ -1033,6 +1034,21 @@ bool Sema::DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag, if (!T->isIncompleteType()) return false; + // If we have a class template specialization, try to instantiate + // it. + if (const RecordType *Record = T->getAsRecordType()) + if (ClassTemplateSpecializationDecl *ClassTemplateSpec + = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) + if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) { + // Update the class template specialization's location to + // refer to the point of instantiation. + if (Loc.isValid()) + ClassTemplateSpec->setLocation(Loc); + return InstantiateClassTemplateSpecialization(ClassTemplateSpec, + /*ExplicitInstantiation=*/false); + } + + if (PrintType.isNull()) PrintType = T; |