r325321 - [Sema] Take into account the current context when checking the

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 16 04:08:53 PST 2018


Reverted in r325335 as this broke the Chromium build.

See https://bugs.chromium.org/p/chromium/issues/detail?id=813017 for
stack trace and reproducer.

(I think Ben said it might have also broken a Clang bootstrap build,
but I didn't see that anywhere?)

On Fri, Feb 16, 2018 at 9:47 AM, Akira Hatanaka via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: ahatanak
> Date: Fri Feb 16 00:47:37 2018
> New Revision: 325321
>
> URL: http://llvm.org/viewvc/llvm-project?rev=325321&view=rev
> Log:
> [Sema] Take into account the current context when checking the
> accessibility of a class member.
>
> This fixes PR32898.
>
> rdar://problem/33737747
>
> Differential revision: https://reviews.llvm.org/D36918
>
> Modified:
>     cfe/trunk/lib/Sema/SemaAccess.cpp
>     cfe/trunk/test/SemaCXX/access.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=325321&r1=325320&r2=325321&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaAccess.cpp Fri Feb 16 00:47:37 2018
> @@ -1793,6 +1793,11 @@ Sema::AccessResult Sema::CheckAddressOfM
>
>    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();
>
>
> Modified: cfe/trunk/test/SemaCXX/access.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access.cpp?rev=325321&r1=325320&r2=325321&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/access.cpp (original)
> +++ cfe/trunk/test/SemaCXX/access.cpp Fri Feb 16 00:47:37 2018
> @@ -169,3 +169,38 @@ namespace ThisLambdaIsNotMyFriend {
>    }
>    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 at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list