[PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

Serge Pavlov via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 01:19:39 PDT 2016


2016-03-29 1:08 GMT+06:00 Serge Pavlov <sepavloff at gmail.com>:

> 2016-03-18 20:50 GMT+06:00 Richard Smith <richard at metafoo.co.uk>:
>
>> rsmith added a comment.
>>
>> Can we instead not add the function to the redeclaration chain until it's
>> instantiated (like we do if it's dependent)?
>>
>>
> I prepared implementation that uses this approach. In this variant
> information about potential definitions is lost, in some cases it makes
> difficult to make analysis. For instance we can diagnose misfit of
> declarations in the code:
> ```
> void func9(int);  // expected-note{{previous declaration is here}}
> template<typename T> struct C9a {
>   friend int func9(int);  // expected-error{{functions that differ only in
> their return type cannot be overloaded}}
> };
> ```
> but not in the case:
> ```
> template<typename T> struct C9a {
>   friend int func9(int);
> };
> void func9(int);
> ```
> Otherwise both approaches seem almost equivalent.
>

It looks like this is not an issue. In http://reviews.llvm.org/D16579
dependent friend are stored in a set for subsequent analysis. Nothing
prevents from using the same approach for all friend functions.

Thanks,
--Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160420/909b10a5/attachment.html>


More information about the cfe-commits mailing list