Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -490,6 +490,8 @@ void DeclRefExpr::setDecl(ValueDecl *NewD) { D = NewD; + if (getType()->isUndeducedType()) + setType(NewD->getType()); setDependence(computeDependence(this, NewD->getASTContext())); } @@ -1722,8 +1724,10 @@ 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)); } Index: clang/test/CodeGenCXX/auto-variable-template.cpp =================================================================== --- clang/test/CodeGenCXX/auto-variable-template.cpp +++ clang/test/CodeGenCXX/auto-variable-template.cpp @@ -12,3 +12,21 @@ // CHECK: define{{.*}} i32 @main() // CHECK: call void @_ZNK1fclEv(%struct.f* {{[^,]*}} @_Z9vtemplateIiE) + +template +struct pack { + template + constexpr static auto some_boolean_cx_value = true; +}; + +auto usage() { + return pack::some_boolean_cx_value; +} + +// CHECK: define{{.*}} i1 @_Z5usagev() + +auto otherusage() { + return pack{}.some_boolean_cx_value; +} + +// CHECK: define{{.*}} i1 @_Z10otherusagev()