diff options
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 14 | ||||
-rw-r--r-- | clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp | 17 |
2 files changed, 10 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 3d182f4c69b..47b18dc39ea 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -102,15 +102,15 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, bool hasNonInstance = false; bool isField = false; BaseSet Classes; - for (const NamedDecl *const D : R) { + for (NamedDecl *D : R) { + // Look through any using decls. + D = D->getUnderlyingDecl(); + if (D->isCXXInstanceMember()) { - // Look through any using decls. - const NamedDecl *const UnderlyingDecl = D->getUnderlyingDecl(); - isField |= isa<FieldDecl>(UnderlyingDecl) || - isa<MSPropertyDecl>(UnderlyingDecl) || - isa<IndirectFieldDecl>(UnderlyingDecl); + isField |= isa<FieldDecl>(D) || isa<MSPropertyDecl>(D) || + isa<IndirectFieldDecl>(D); - const CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext()); + CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext()); Classes.insert(R->getCanonicalDecl()); } else hasNonInstance = true; diff --git a/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp index a6092f5b90d..9116e7146f8 100644 --- a/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp +++ b/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp @@ -64,26 +64,17 @@ namespace test2 { template <class T> struct A { void foo(); - void foo2(); - static void static_foo(); - static void static_foo2(); - + void test0() { Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}} } void test1() { B<T>::foo(); - B<T>::foo2(); // expected-error {{call to non-static member function without an object argument}} - B<T>::static_foo(); - B<T>::static_foo2(); } static void test2() { B<T>::foo(); // expected-error {{call to non-static member function without an object argument}} - B<T>::foo2(); // expected-error {{call to non-static member function without an object argument}} - B<T>::static_foo(); - B<T>::static_foo2(); } void test3() { @@ -92,17 +83,15 @@ namespace test2 { }; template <class T> struct B : A<T> { - using A<T>::foo2; - using A<T>::static_foo2; }; - + template <class T> struct C { }; int test() { A<int> a; a.test0(); // no instantiation note here, decl is ill-formed - a.test1(); // expected-note {{in instantiation}} + a.test1(); a.test2(); // expected-note {{in instantiation}} a.test3(); // expected-note {{in instantiation}} } |