Skip to content

Commit bd2a6ef

Browse files
authored
[clang]not lookup name containing a dependent type (#77587)
Fixes: #77583 bcd51aa fixed part of template instantiation dependent name issues but still missing some cases This patch want to enhance the dependent name check
1 parent dc97457 commit bd2a6ef

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,9 @@ Bug Fixes in This Version
719719
- Clang now emits correct source location for code-coverage regions in `if constexpr`
720720
and `if consteval` branches.
721721
Fixes (`#54419 <https://github.com/llvm/llvm-project/issues/54419>`_)
722-
722+
- Fix an issue where clang cannot find conversion function with template
723+
parameter when instantiation of template class.
724+
Fixes (`#77583 <https://github.com/llvm/llvm-project/issues/77583>`_)
723725

724726
Bug Fixes to Compiler Builtins
725727
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,8 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType,
782782
const Scope *S,
783783
ActOnMemberAccessExtraArgs *ExtraArgs) {
784784
if (BaseType->isDependentType() ||
785-
(SS.isSet() && isDependentScopeSpecifier(SS)))
785+
(SS.isSet() && isDependentScopeSpecifier(SS)) ||
786+
NameInfo.getName().isDependentName())
786787
return ActOnDependentMemberExpr(Base, BaseType,
787788
IsArrow, OpLoc,
788789
SS, TemplateKWLoc, FirstQualifierInScope,

clang/test/SemaCXX/conversion-function.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,22 @@ struct S {
475475

476476
#if __cplusplus >= 201103L
477477
namespace dependent_conversion_function_id_lookup {
478-
template<typename T> struct A {
479-
operator T();
480-
};
481-
template<typename T> struct B : A<T> {
482-
template<typename U> using Lookup = decltype(&B::operator U);
483-
};
484-
using Result = B<int>::Lookup<int>;
485-
using Result = int (A<int>::*)();
478+
namespace gh77583 {
479+
struct A1 {
480+
operator int();
481+
};
482+
template<class T> struct C {
483+
template <typename U> using Lookup = decltype(T{}.operator U());
484+
};
485+
C<A1> v{};
486+
}
487+
template<typename T> struct A2 {
488+
operator T();
489+
};
490+
template<typename T> struct B : A2<T> {
491+
template<typename U> using Lookup = decltype(&B::operator U);
492+
};
493+
using Result = B<int>::Lookup<int>;
494+
using Result = int (A2<int>::*)();
486495
}
487496
#endif

0 commit comments

Comments
 (0)