Anonymous records with typedef names for linkage

John McCall rjmccall at
Wed Jan 29 15:05:20 PST 2014

On Jan 29, 2014, at 8:45 AM, Richard Smith <richard at> wrote:
> When we see the class definition, we already have to cache the tokens in member functions until we hit the close brace. It doesn't seem too hard or expensive to look ahead and see if we have a typedef name for linkage purposes if the class is anonymous and is preceded or followed by typedef.

I don’t think we can actually tentatively parse declarators.  Remember that we might have something like

  typedef struct { … } (*FnType)(), (*ArrayType)[sizeof(decltype(declval<FnType>()()))], StructType;

because C++ is dumb.

But obviously we could recognize some simple cases and limit the damage of my proposed diagnostic.

> 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.


More information about the cfe-commits mailing list