From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31823 invoked by alias); 12 Dec 2002 00:36:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31736 invoked by uid 71); 12 Dec 2002 00:36:02 -0000 Date: Wed, 11 Dec 2002 16:36:00 -0000 Message-ID: <20021212003602.31735.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Christian Ehrhardt" Subject: Re: c/8420: volatile after the type specifier for an unnamed structure is rejected Reply-To: "Christian Ehrhardt" X-SW-Source: 2002-12/txt/msg00687.txt.bz2 List-Id: The following reply was made to PR c/8420; it has been noted by GNATS. From: "Christian Ehrhardt" To: Richard Henderson 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!