Anonymous records with typedef names for linkage

John McCall rjmccall at apple.com
Wed Jan 29 16:55:14 PST 2014


On Jan 29, 2014, at 3:46 PM, Richard Smith <metafoo at gmail.com> wrote:
> On Wed Jan 29 2014 at 3:36:53 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
> >> Can this go wrong in any non-delay-parsed context?
> >
> > ‘this’ is legal in some non-delay-parsed contexts, namely trailing result types.
> >
> > Do you have any objection to adopting my proposed diagnostic as a semi-temporary fix?  All the code it would affect currently triggers an assertion, and frankly it feels like a “real” fix here would require a pretty disproportionate amount of effort for the expected benefit.
> 
> BTW, I tried
> 
> template <typename T>
> void f(T* x) {
> }
> template <typename T>
> void g(T* x) {
> }
> typedef struct {
>   void foo() {
>     f(this);
>   }
> } A;
> void bar(A *x) {
>   f(x);
>   g(x);
> }
> 
> with with gcc trunk. With c++03 it still produces an error and with
> c++11 it produces an internal f and an external g.
> 
> For what it is worth, clang would probably be the most standard
> complaint even with just the error.
> 
> EDG gets this (and similar cases) right. I'm not sure what it's doing, but I've not been able to trip it up yet. Maybe it just doesn't compute linkage until it gets to code generation?

Probably.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140129/a8981041/attachment.html>


More information about the cfe-commits mailing list