Anonymous records with typedef names for linkage

Richard Smith metafoo at gmail.com
Wed Jan 29 15:46:23 PST 2014


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140129/21c51979/attachment.html>


More information about the cfe-commits mailing list