Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -2693,19 +2693,35 @@ // spuriously dependent expression if we're inside a dependent // instance method. if (!R.empty() && (*R.begin())->isCXXClassMember()) { - bool MightBeImplicitMember; - if (!IsAddressOfOperand) - MightBeImplicitMember = true; - else if (!SS.isEmpty()) - MightBeImplicitMember = false; - else if (R.isOverloadedResult()) - MightBeImplicitMember = false; - else if (R.isUnresolvableResult()) - MightBeImplicitMember = true; - else - MightBeImplicitMember = isa(R.getFoundDecl()) || - isa(R.getFoundDecl()) || - isa(R.getFoundDecl()); + bool MightBeImplicitMember = true, CheckField = true; + if (IsAddressOfOperand) { + if (!SS.isEmpty()) + MightBeImplicitMember = false; + else if (R.isOverloadedResult()) + MightBeImplicitMember = false; + else if (R.isUnresolvableResult()) { + MightBeImplicitMember = true; + CheckField = false; + } + } + if (MightBeImplicitMember && CheckField) { + if (R.isSingleResult() && (isa(R.getFoundDecl()) || + isa(R.getFoundDecl()) || + isa(R.getFoundDecl()))) { + if (auto Class = dyn_cast_or_null( + (*R.begin())->getDeclContext())) { + for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext(); + Curr = Curr->getParent()) { + if (auto ThisClass = dyn_cast_or_null(Curr)) { + if ((MightBeImplicitMember = ThisClass->Equals(Class) || + ThisClass->isDerivedFrom(Class))) + break; + } + } + } + } else if (IsAddressOfOperand) + MightBeImplicitMember = false; + } if (MightBeImplicitMember) return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, Index: clang/test/CXX/drs/dr6xx.cpp =================================================================== --- clang/test/CXX/drs/dr6xx.cpp +++ clang/test/CXX/drs/dr6xx.cpp @@ -789,7 +789,7 @@ struct E : D {}; static_assert(!__is_trivially_constructible(E, const E&), ""); - struct F { F &operator=(F&&) = delete; }; + struct F { F &operator=(F&&) = delete; }; // expected-note 0-1 {{declared here}} struct G : F {}; static_assert(!__is_trivially_assignable(G, G&&), ""); } @@ -839,7 +839,7 @@ template struct X { static const int n = 0; }; class A { - friend class B *f(); + friend class B *f(); // expected-note 0-1 {{previous definition is here}} class C *f(); void f(class D *); enum { e = X::n }; @@ -850,6 +850,7 @@ D *d; E *e; F *f; // expected-error {{unknown type name}} + // expected-error@-1 0-1 {{redefinition of 'f' as different kind of symbol}} } namespace dr674 { // dr674: 8 Index: clang/test/SemaCXX/attr-cpuspecific.cpp =================================================================== --- clang/test/SemaCXX/attr-cpuspecific.cpp +++ clang/test/SemaCXX/attr-cpuspecific.cpp @@ -16,8 +16,10 @@ // OK, will fail in the linker, unless another TU provides the cpu_dispatch. no_default(); + // expected-error@+2 0-1 {{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}} // expected-error@+1 {{call to non-static member function without an object argument}} +MVReference::bar; + // expected-error@+2 0-1 {{reference to multiversioned function could not be resolved; did you mean to call it with no arguments?}} // expected-error@+1 {{call to non-static member function without an object argument}} +MVReference::foo; // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}} Index: clang/test/SemaCXX/decltype.cpp =================================================================== --- clang/test/SemaCXX/decltype.cpp +++ clang/test/SemaCXX/decltype.cpp @@ -101,6 +101,27 @@ template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {} } +namespace GH58674 { + struct Foo { + float value_; + }; + + template + struct Animal{}; + + template + class Cat : Animal { + public: + void meow() { + using okay = decltype(Foo::value_); + } + }; + + void bar() { + Cat{}.meow(); + } +} + template class conditional { };