Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -6456,8 +6456,15 @@ } inline bool Type::isUndeducedType() const { - auto *DT = getContainedDeducedType(); - return DT && !DT->isDeduced(); + QualType Ty(this, 0); + while (auto *DT = Ty->getContainedDeducedType()) { + if (!DT->isDeduced()) + return true; + Ty = DT->getDeducedType(); + if (Ty.isNull()) + return false; + } + return false; } /// Determines whether this is a type for which one can define Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp =================================================================== --- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp +++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp @@ -335,3 +335,13 @@ void g(int, int); using Int = A::B<&g>::param2; } + +namespace rdar41852459 { +template struct G {}; + +template struct S { + template void f() { + G x; + } +}; +}