public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Should typedef'd unnamed structs be supported?
@ 2003-03-27  8:02 Robert Dewar
  2003-03-27 10:26 ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Dewar @ 2003-03-27  8:02 UTC (permalink / raw)
  To: gcc, pthomas, rth

> Though you should note that none of this abomination is active
> unless -fms-extensions.  Nor is it documented, though I suppose
> that's a mistake.


if it isn't documented, then you could consider it a bug that it "works" :-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-27  8:02 Should typedef'd unnamed structs be supported? Robert Dewar
@ 2003-03-27 10:26 ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2003-03-27 10:26 UTC (permalink / raw)
  To: Robert Dewar; +Cc: gcc, pthomas

On Wed, Mar 26, 2003 at 10:32:48PM -0500, Robert Dewar wrote:
> if it isn't documented, then you could consider it a bug that it "works" :-)

Alternately, it's an undocumented feature that mingwin32 can
compile it's standard ms headers.



r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-27 10:04     ` Richard Henderson
  2003-03-27 10:33       ` Philipp Thomas
@ 2003-03-27 19:37       ` Philipp Thomas
  1 sibling, 0 replies; 8+ messages in thread
From: Philipp Thomas @ 2003-03-27 19:37 UTC (permalink / raw)
  To: Richard Henderson, gcc

* Richard Henderson (rth@redhat.com) [20030327 10:18]:

> Please smack the ntfs folk for me please.  This is gross.

I tried to, but alas, instead of accepting a patch that fixes the code the
maintainer chose instead to add -fms-extensions to ntfs/Makefile :(

Philipp

-- 
Philipp Thomas <pthomas@suse.de>
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-27 10:04     ` Richard Henderson
@ 2003-03-27 10:33       ` Philipp Thomas
  2003-03-27 19:37       ` Philipp Thomas
  1 sibling, 0 replies; 8+ messages in thread
From: Philipp Thomas @ 2003-03-27 10:33 UTC (permalink / raw)
  To: Richard Henderson, gcc

* Richard Henderson (rth@redhat.com) [20030327 10:18]:

> On Thu, Mar 27, 2003 at 09:57:11AM +0100, Philipp Thomas wrote:
> > And here's the catch: in 3.3 and mainline this only gives a warning when
> > it's a declaration.
> 
> Yes.  Not sure about the history of this off the top of my head.
> While the comment says error, the code says warning.

And I'd say it would be far better if the code said error because a) code
that tries to access that member *will* get an error and b) the layout of
the structure changes, which is fatal when used in a driver like nfts to
map on-disk structures.
 
> Please smack the ntfs folk for me please.  This is gross.

This I'll do with pleasure :) Seems they've dealt with MS code far too long.
 
BTW, as it's now clear that this isn't a 3.2/3.3 regression, could you close
c/10225?

Philipp

-- 
Philipp Thomas <pthomas@suse.de>
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-27  9:41   ` Philipp Thomas
@ 2003-03-27 10:04     ` Richard Henderson
  2003-03-27 10:33       ` Philipp Thomas
  2003-03-27 19:37       ` Philipp Thomas
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Henderson @ 2003-03-27 10:04 UTC (permalink / raw)
  To: Philipp Thomas, gcc

On Thu, Mar 27, 2003 at 09:57:11AM +0100, Philipp Thomas wrote:
> And here's the catch: in 3.3 and mainline this only gives a warning when
> it's a declaration.

Yes.  Not sure about the history of this off the top of my head.
While the comment says error, the code says warning.

> Sadly that's only true for 3.3 and up :( 3.2 accepts it without that switch 
> and that's why the ntfs driver developers seemingly decided to use it.

I recall this being wrong in the past and fixing it.  I didn't
recall specifically that 3.2 allowed it.

Please smack the ntfs folk for me please.  This is gross.

> Yes, I also think that this is mistake. I'll see if I can come up with
> something. BTW, from which file does the comment come from?

gcc/c-decl.c.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-27  2:11 ` Richard Henderson
@ 2003-03-27  9:41   ` Philipp Thomas
  2003-03-27 10:04     ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Thomas @ 2003-03-27  9:41 UTC (permalink / raw)
  To: Richard Henderson, gcc

* Richard Henderson (rth@redhat.com) [20030327 02:53]:

>          If this is something of the form "foo;" and foo is a TYPE_DECL, then
>            If MS extensions are enabled and foo names a structure, then
>              again this is an anonymous struct.
>            Otherwise this is an error.

And here's the catch: in 3.3 and mainline this only gives a warning when
it's a declaration. You only get an error if you try to access such a
member. If the comment is correct, gcc actually should flag this as error
and not only a warning.

> Though you should note that none of this abomination is active
> unless -fms-extensions.

Sadly that's only true for 3.3 and up :( 3.2 accepts it without that switch 
and that's why the ntfs driver developers seemingly decided to use it.

See c/10225 for the gory details.

> Nor is it documented, though I suppose that's a mistake.

Yes, I also think that this is mistake. I'll see if I can come up with
something. BTW, from which file does the comment come from?

Philipp

-- 
Philipp Thomas <pthomas@suse.de>
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Should typedef'd unnamed structs be supported?
  2003-03-25 18:18 Philipp Thomas
@ 2003-03-27  2:11 ` Richard Henderson
  2003-03-27  9:41   ` Philipp Thomas
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2003-03-27  2:11 UTC (permalink / raw)
  To: Philipp Thomas, gcc

On Tue, Mar 25, 2003 at 06:38:14PM +0100, Philipp Thomas wrote:
> One of the GCC extensions is to allow unnamed structs and unions as
> fields of a structure. Question now is, if that should also apply
> to typedefs, i.e:

Yes.  Indeed, this is implemented.

      /* This is an unnamed decl.

         If we have something of the form "union { list } ;" then this
         is the anonymous union extension.  Similarly for struct.

         If this is something of the form "struct foo;", then
           If MS extensions are enabled, this is handled as an
             anonymous struct.
           Otherwise this is a forward declaration of a structure tag.

         If this is something of the form "foo;" and foo is a TYPE_DECL, then
           If MS extensions are enabled and foo names a structure, then
             again this is an anonymous struct.
           Otherwise this is an error.

         Oh what a horrid tangled web we weave.  I wonder if MS consciously
         took this from Plan 9 or if it was an accident of implementation
         that took root before someone noticed the bug...  */

Though you should note that none of this abomination is active
unless -fms-extensions.  Nor is it documented, though I suppose
that's a mistake.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Should typedef'd unnamed structs be supported?
@ 2003-03-25 18:18 Philipp Thomas
  2003-03-27  2:11 ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Thomas @ 2003-03-25 18:18 UTC (permalink / raw)
  To: gcc


One of the GCC extensions is to allow unnamed structs and unions as
fields of a structure. Question now is, if that should also apply
to typedefs, i.e:

typedef struct {
  int z;
} type_z;

struct B {
  int i;
  type_z;
};

Is supposed to work. 

Philipp

-- 
Philipp Thomas <pthomas@suse.de>
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-03-27 18:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-27  8:02 Should typedef'd unnamed structs be supported? Robert Dewar
2003-03-27 10:26 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2003-03-25 18:18 Philipp Thomas
2003-03-27  2:11 ` Richard Henderson
2003-03-27  9:41   ` Philipp Thomas
2003-03-27 10:04     ` Richard Henderson
2003-03-27 10:33       ` Philipp Thomas
2003-03-27 19:37       ` Philipp Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).