Preserve type source information when substituting into FieldDecls.

Just r84734 now that some fundamental work has been completed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84914 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2009-10-22 23:33:21 +00:00
Родитель eb692e07c7
Коммит 07fb6bef62
1 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -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(),