This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFA: Support Plan 9 extensions in gcc


On Thu, Apr 9, 2009 at 11:08 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, Apr 9, 2009 at 9:35 PM, Ian Lance Taylor <iant@google.com> wrote:
>> gcc currently supports an option -fms-extensions which permits some uses
>> of unnamed fields in structs and unions. ?The Plan 9 C compiler has two
>> extensions which are not included in -fms-extensions.
>>
>> The first extension is if a structure has an anonymous field, a pointer
>> to that structure can be automatically converted to apointer to the
>> anonymous field in an assignment or a function call. ?For example:
>>
>> struct s1 { int a; };
>> struct s2 { int b; struct s1; };
>> extern void f1 (struct s1 *);
>> void f2 (struct s2 *p) { f1 (p); }
>>
>> Here struct s2 has an anonymous field of type struct s1. ?When calling
>> f1 from f2, the pointer to s2 is converted into a pointer to s1. ?Note
>> that the anonymous field is not the first field in s2, so this actually
>> adjusts the pointer in order to make the call.

Some more constructive concerns.  What happens with

struct s2 { int b; struct s1; struct { struct s1; int c; }; };
void f2 (struct s2 *p) { f1 (p); }
?

The extension is not properly specified IMHO, and I do not think
we should add non ISO-C extensions to GCC without a very good reason.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]