This revision was automatically updated to reflect the committed changes.
Closed by commit rC325321: [Sema] Take into account the current context when 
checking the (authored by ahatanak, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D36918

Files:
  lib/Sema/SemaAccess.cpp
  test/SemaCXX/access.cpp


Index: lib/Sema/SemaAccess.cpp
===================================================================
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
                       /*no instance context*/ QualType());
+
+  if (IsAccessible(*this, EffectiveContext(CurScope->getEntity()), Entity) ==
+      ::AR_accessible)
+    return AR_accessible;
+
   Entity.setDiag(diag::err_access)
     << Ovl->getSourceRange();
 
Index: test/SemaCXX/access.cpp
===================================================================
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,38 @@
   }
   void bar() { foo<void>(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template<class T, void(T::*pMethod)()>
+  void func0() {}
+
+  template<class T, void(T::*pMethod)(int)>
+  void func1() {}
+
+  template<class T>
+  void func2(void(*fn)()) {} // expected-note 2 {{candidate function not 
viable: no overload of 'func}}
+
+  class C {
+  private:
+    friend void friendFunc();
+    void overloadedMethod();
+  protected:
+    void overloadedMethod(int);
+  public:
+    void overloadedMethod(int, int);
+    void method() {
+      func2<int>(&func0<C, &C::overloadedMethod>);
+      func2<int>(&func1<C, &C::overloadedMethod>);
+    }
+  };
+
+  void friendFunc() {
+    func2<int>(&func0<C, &C::overloadedMethod>);
+    func2<int>(&func1<C, &C::overloadedMethod>);
+  }
+
+  void nonFriendFunc() {
+    func2<int>(&func0<C, &C::overloadedMethod>); // expected-error {{no 
matching function for call to 'func2'}}
+    func2<int>(&func1<C, &C::overloadedMethod>); // expected-error {{no 
matching function for call to 'func2'}}
+  }
+}


Index: lib/Sema/SemaAccess.cpp
===================================================================
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
                       /*no instance context*/ QualType());
+
+  if (IsAccessible(*this, EffectiveContext(CurScope->getEntity()), Entity) ==
+      ::AR_accessible)
+    return AR_accessible;
+
   Entity.setDiag(diag::err_access)
     << Ovl->getSourceRange();
 
Index: test/SemaCXX/access.cpp
===================================================================
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,38 @@
   }
   void bar() { foo<void>(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template<class T, void(T::*pMethod)()>
+  void func0() {}
+
+  template<class T, void(T::*pMethod)(int)>
+  void func1() {}
+
+  template<class T>
+  void func2(void(*fn)()) {} // expected-note 2 {{candidate function not viable: no overload of 'func}}
+
+  class C {
+  private:
+    friend void friendFunc();
+    void overloadedMethod();
+  protected:
+    void overloadedMethod(int);
+  public:
+    void overloadedMethod(int, int);
+    void method() {
+      func2<int>(&func0<C, &C::overloadedMethod>);
+      func2<int>(&func1<C, &C::overloadedMethod>);
+    }
+  };
+
+  void friendFunc() {
+    func2<int>(&func0<C, &C::overloadedMethod>);
+    func2<int>(&func1<C, &C::overloadedMethod>);
+  }
+
+  void nonFriendFunc() {
+    func2<int>(&func0<C, &C::overloadedMethod>); // expected-error {{no matching function for call to 'func2'}}
+    func2<int>(&func1<C, &C::overloadedMethod>); // expected-error {{no matching function for call to 'func2'}}
+  }
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to