public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Joseph S. Myers" <jsm28@cam.ac.uk> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c/4784: Anonymous structs issues Date: Fri, 07 Mar 2003 09:56:00 -0000 [thread overview] Message-ID: <20030307095600.12036.qmail@sources.redhat.com> (raw) The following reply was made to PR c/4784; it has been noted by GNATS. From: "Joseph S. Myers" <jsm28@cam.ac.uk> To: <bangerth@dealii.org>, <gcc-bugs@gcc.gnu.org>, Joseph Myers <jsm28@cam.ac.uk>, <gcc-gnats@gcc.gnu.org> Cc: Subject: Re: c/4784: Anonymous structs issues Date: Fri, 7 Mar 2003 09:51:25 +0000 (GMT) On 7 Mar 2003 bangerth@dealii.org wrote: > Hm, with 3.3 and present mainline, we get on this code > ----------------------- > struct s { > int x; > struct { int x; }; > }; > ------------------ > the following message: > g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -W -Wall -std=c99 -c x.c > x.c:3: warning: declaration does not declare anything What's relevant is -std=gnu99 and -std=gnu89, as this is a GNU extension. That warning hardly diagnoses what the problem is; the point of the extension is that certain declarations that don't declare anything do, in fact, declare nested anonymous struct elements. The PR asks for a hard error (with a more sensible error message). What about more complicated cases, such as: struct s { struct { int a; struct { int b; }; }; struct { int b; int c; }; }; (where the duplicate "b" elements should be diagnosed)? > gcc3.2 is quiet. If compiled in C++ mode, we get this: > g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -W -Wall -c x.cc > x.cc:3: error: declaration of `int s::<anonymous struct>::x' > x.cc:2: error: conflicts with previous declaration `int s::x' > x.cc:3: error: duplicate member `s::<anonymous struct>::x' > > Joseph, is this approximately what you wanted gcc to > tell us? What the C++ compiler does isn't part of the PR (C++ has its own rules; this is a C extension), but those error messages are the sort of error I think the C front end ought to be giving: they accurately diagnose what the problem in the example code is. -- Joseph S. Myers jsm28@cam.ac.uk
next reply other threads:[~2003-03-07 9:56 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-03-07 9:56 Joseph S. Myers [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-03-07 15:16 Wolfgang Bangerth 2003-03-07 2:24 bangerth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030307095600.12036.qmail@sources.redhat.com \ --to=jsm28@cam.ac.uk \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).