erik.pilkington created this revision. erik.pilkington added a reviewer: rsmith. Herald added a subscriber: dexonsmith.
Clang used to error out on the attached test case because we deduced an auto type to an undeduced auto type in the template-id G<V>. This caused Sema::CheckNonTypeTemplateParameterType to error out because isUndeducedType() returned false. It seems like we want to retain this type sugar, so this patch teaches isUndeducedType to dig through any deduced-to-undeduced types. rdar://41852459 Thanks for taking a look! Erik Repository: rC Clang https://reviews.llvm.org/D50088 Files: clang/include/clang/AST/Type.h clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp 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<int>::B<&g>::param2; } + +namespace rdar41852459 { +template <auto V> struct G {}; + +template <class T> struct S { + template <auto V> void f() { + G<V> x; + } +}; +} 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<int>::B<&g>::param2; } + +namespace rdar41852459 { +template <auto V> struct G {}; + +template <class T> struct S { + template <auto V> void f() { + G<V> x; + } +}; +} 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits