[cfe-commits] pr12328 PATCH: Friend method declaration doesn't require method to be visible

Stepan Dyatkovskiy stpworld at narod.ru
Sun Apr 22 05:17:42 PDT 2012


Hi John. Ok, I propose two versions then.

1. Add "bool SuppressDelayedDiagnostics" param to the CheckLookupAccess 
method, that will "false" by default. IMHO looks like a workaround.
2. Extend DelayedDiagnostics with enable() feature.

#1 is attached as pr12328.patch
#2 is attached as pr12328-2.patch

Also I attached new + fixed tests in pr12328-testcases.patch.

-Stepan.

John McCall wrote:
> On Apr 19, 2012, at 3:45 AM, Stepan Dyatkovskiy wrote:
>> ping.
>> Stepan Dyatkovskiy wrote:
>>> ping.
>>> Stepan Dyatkovskiy wrote:
>>>> ping.
>>>> Stepan Dyatkovskiy wrote:
>>>>> Hi all.
>>>>> Please find patch in attachment for review.
>>>>> I suppose that this check was not implemented yet, since I couldn't
>>>>> found it anywhere. The friend method availability check was inserted in
>>>>> Sema::ActOnFriendFunctionDecl.
>>>>> I also added "DeclContext *FromContext" to the AccessedEntity class. It
>>>>> allows to ask DelayedDiagnostic to use context that was "current" when
>>>>> this diagnostics was requested. It is usefull in our case, since we
>>>>> requested diagnostics when we're parsing class with "friend"
>>>>> declaration, but diagnostics is invoked for class with definition of
>>>>> friend member itself.
>
> Sorry for the delay.
>
> Please include test cases when you submit patches.  Also, I'm afraid your
> patch is out-of-date.
>
> +  if (Previous.getResultKind() == LookupResult::Found&&
> +      Previous.getFoundDecl()->isCXXClassMember())
> +    CheckLookupAccess(Previous);
>
> This is a bit silly, because we know exactly what we're checking access to,
> and we're getting nothing out of delaying the diagnostic.  It would be better
> to provide a different CheckFriendAccess entrypoint that happens to
> suppress diagnostic delay.
>
> Also, you'll need to do this same access check in SemaTemplateInstantiateDecl
> so that it happens in template instantiations.
>
> John.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr12328.patch
Type: text/x-patch
Size: 3231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/9b910868/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr12328-2.patch
Type: text/x-patch
Size: 2079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/9b910868/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr12328-testcases.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/9b910868/attachment-0002.bin>


More information about the cfe-commits mailing list