Fix undeduced type assert

If the instantiation of a member variable makes it possible to
compute a previously undeduced type, we should use that piece of
information.

Fix bug#50590

Differential Revision: https://reviews.llvm.org/D103849
This commit is contained in:
serge-sans-paille 2021-06-07 17:14:43 +02:00
parent d9cdcfb069
commit 4b219051a3
2 changed files with 24 additions and 2 deletions

View File

@ -490,6 +490,8 @@ DeclRefExpr *DeclRefExpr::CreateEmpty(const ASTContext &Context,
void DeclRefExpr::setDecl(ValueDecl *NewD) {
D = NewD;
if (getType()->isUndeducedType())
setType(NewD->getType());
setDependence(computeDependence(this, NewD->getASTContext()));
}
@ -1722,8 +1724,10 @@ MemberExpr *MemberExpr::CreateEmpty(const ASTContext &Context,
return new (Mem) MemberExpr(EmptyShell());
}
void MemberExpr::setMemberDecl(ValueDecl *D) {
MemberDecl = D;
void MemberExpr::setMemberDecl(ValueDecl *NewD) {
MemberDecl = NewD;
if (getType()->isUndeducedType())
setType(NewD->getType());
setDependence(computeDependence(this));
}

View File

@ -12,3 +12,21 @@ int main() { vtemplate<int>(); }
// CHECK: define{{.*}} i32 @main()
// CHECK: call void @_ZNK1fclEv(%struct.f* {{[^,]*}} @_Z9vtemplateIiE)
template <typename>
struct pack {
template <typename T>
constexpr static auto some_boolean_cx_value = true;
};
auto usage() {
return pack<char>::some_boolean_cx_value<int>;
}
// CHECK: define{{.*}} i1 @_Z5usagev()
auto otherusage() {
return pack<char>{}.some_boolean_cx_value<int>;
}
// CHECK: define{{.*}} i1 @_Z10otherusagev()