Sema::CheckAddressOfMemberAccess was disregarding the context in which the member pointer was referenced.
This patch fixes PR32898.
rdar://problem/33737747
Differential D36918
[Sema] Take into account the current context when checking the accessibility of a member function pointer ahatanak on Aug 18 2017, 10:27 PM. Authored by
Details
Sema::CheckAddressOfMemberAccess was disregarding the context in which the member pointer was referenced. This patch fixes PR32898. rdar://problem/33737747
Diff Detail Event Timeline
Comment Actions Address review comments.
Comment Actions The patch got reverted in r325335 as it broke the Chromium build. I'm reopening this review. Comment Actions The new patch passes the calling context to CheckNonDependent so that Sema::CheckAddressOfMemberAccess uses the correct context to check accessibility of explicit template arguments. I initially tried moving the declaration of SavedContext in Sema::FinishTemplateArgumentDeduction to after the call to CheckNonDependent, but that caused test/SemaCXX/cxx1z-class-template-argument-deduction.cpp to fail. It seems like it changes the way lookup of default template arguments is done when the context (which is a CXXDeductionGuideDecl in the failing test case) is not set before ConvertDeducedTemplateArguments is called. Comment Actions I don't see a new test case for the issue reduced out of Chromium. I'd recommend adding that. I have to resign because I don't know enough about deduction to stamp this... Comment Actions Add a test case for the Chromium failure. Also, simplify a bit by capturing the calling context in Sema::DeduceTemplateArguments. Comment Actions I don't particularly like that between setting the DeclContext (SemaTemplateDeduction.cpp:3814) and actually using it (CheckAccess() in SemaAccess.cpp:1459) are some 20 stack frames but it looks like you already tried fixing this "locally" in your initial approach. I assume we can't get the appropriate DeclContext from Expr *OvlExpr in CheckAddressOfMemberAccess(), right? Comment Actions It doesn't look like it's possible to get the context needed to do accessibility check (CXXMethodDecl 'method' for 'C::overloadedMethod' in the test case) from 'Expr *OvlExpr' in CheckAddressOfMemberAccess. It's possible to get the class in which the member is defined (class ''C' for C::overloadedMethod'), but we want the context in which the member is used (that is 'method'). |