diff options
author | John McCall <rjmccall@apple.com> | 2009-10-22 23:33:21 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-10-22 23:33:21 +0000 |
commit | 90459c50d7e75a34b137bfb68ddf5f006e0be34e (patch) | |
tree | 88520471687d1ed8ca6cd5cc1ca050a7e90215b8 | |
parent | fa2d692b7dc682e75e3aa7c251550a0ffaa20e8c (diff) | |
download | bcm5719-llvm-90459c50d7e75a34b137bfb68ddf5f006e0be34e.tar.gz bcm5719-llvm-90459c50d7e75a34b137bfb68ddf5f006e0be34e.zip |
Preserve type source information when substituting into FieldDecls.
Just r84734 now that some fundamental work has been completed.
llvm-svn: 84914
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0a753838425..be4adbc93d1 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -204,11 +204,14 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { bool Invalid = false; - QualType T = D->getType(); - if (T->isDependentType()) { - T = SemaRef.SubstType(T, TemplateArgs, - D->getLocation(), D->getDeclName()); - if (!T.isNull() && T->isFunctionType()) { + DeclaratorInfo *DI = D->getDeclaratorInfo(); + if (DI->getType()->isDependentType()) { + DI = SemaRef.SubstType(DI, TemplateArgs, + D->getLocation(), D->getDeclName()); + if (!DI) { + DI = D->getDeclaratorInfo(); + Invalid = true; + } else if (DI->getType()->isFunctionType()) { // C++ [temp.arg.type]p3: // If a declaration acquires a function type through a type // dependent on a template-parameter and this causes a @@ -216,8 +219,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { // function declarator to have function type, the program is // ill-formed. SemaRef.Diag(D->getLocation(), diag::err_field_instantiates_to_function) - << T; - T = QualType(); + << DI->getType(); Invalid = true; } } @@ -238,8 +240,8 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { BitWidth = InstantiatedBitWidth.takeAs<Expr>(); } - FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), T, - D->getDeclaratorInfo(), + FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), + DI->getType(), DI, cast<RecordDecl>(Owner), D->getLocation(), D->isMutable(), |