This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix PR c/6660
Jim Wilson wrote:
> For extra points, I looked up the Plan9 reference.
> This is about 2/3 of the way down, in a section called "extensions".
> There is a little more detail here, but still not as much as I'd like to see.
> This one explicitly allows anonymous typedefs within a structure. It also
> goes a little farther and allows one to use the super-struct in contexts
> where the base-struct is required, kind of like C++ (though I probably have
> the terminology wrong).
There's one other aspect of the Plan 9 extension, in addition to these two.
Anonymous structures and unions may be accessed by type name if (and only
if) they are declared using a typedef name. For example, assuming a
typedef'd struct Point, one may declare
and refer to p.Point.
I assume the restriction to typedef names is so the parser doesn't have to
try to figure out how to parse something like 'p.struct Point'.
Now, the interesting question arises as to whether these extensions are
easily applicable to C++. The first and third extensions (including
anonymous structures by name, and allowing explicit references to them by
typedef name) are pretty obviously extensible to C++; however, the second
(implicit type promotion) would be a mess with the C++ type system, as far
as I can tell.