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

Serge Pavlov via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 28 12:08:15 PDT 2016


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.

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


More information about the cfe-commits mailing list