This is the mail archive of the gcc-prs@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: c/8420: volatile after the type specifier for an unnamed structure is rejected


The following reply was made to PR c/8420; it has been noted by GNATS.

From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: Richard Henderson <rth@redhat.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/8420: volatile after the type specifier for an unnamed structure is rejected
Date: Thu, 12 Dec 2002 01:34:25 +0100

 On Wed, Dec 11, 2002 at 03:40:19PM -0800, Richard Henderson wrote:
 > On Fri, Nov 01, 2002 at 10:14:09AM -0000, ehrhardt@mathematik.uni-ulm.de wrote:
 > > struct c {
 > > 	struct  { int x; } volatile;
 > > };  /* ERROR */
 > > 
 > > theseus$ gcc -Wall -c t.c
 > > t.c:10: unnamed fields of type other than struct or union are not allowed
 > [...]
 > > Given the other two examples (struct a and struct b) which are accepted
 > > this code should probably be legal.
 > 
 > I don't agree.  I think this is very confusing syntax.
 
 I agree that it is confusing, but normally the order in which type
 specifiers and type qualifiers appear is irrelevant. This is shown
 by the fact that
 struct {
 	struct { int a; } volatile name;
 } X;
 is accepted and legal. If we continue to allow this we should also
 allow it for anon structs. Having said that I don't particularly care
 about this, as already said in the orignal report this is to point out
 what looks like an oversight in c-decl.c: The declspecs passed to 
 grokfield may contain qualifiers and it is not safe to assume that
 the type specifier is the last thing in a declspec and hence the first
 thing in the declspec list as returned from the parser.
 
 > > Even if it is illegal the error message is wrong.
 > 
 > Granted.
 
 3.3. meanwhile gives a somewhat better message. The proper solution
 is IMHO to move the whole check for unnamed types from grokfield to
 grokdeclarator and do the check when we know which element on the
 declspec list is the type specifier.
 
     regards  Christian
 
 -- 
 THAT'S ALL FOLKS!


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