public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct
       [not found] <bug-44854-4@http.gcc.gnu.org/bugzilla/>
@ 2011-10-03 10:25 ` manu at gcc dot gnu.org
  2024-02-18 11:54 ` peter0x44 at disroot dot org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-03 10:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44854

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-03 10:23:57 UTC ---
(In reply to comment #1)
> identifier is the same as  member name.  In fact I say GCC's diagnostic is more
> correct as ( can be there also.

I am sorry Andrew, but this way of reasoning is counter-intuitive. Can you
write?

struct foo { int (};

No, so talking about '(' doesn't make sense. And: "specifier-qualifier-list at
end of input" is equally bogus.

BTW, clang++ is neither perfect, and it makes a mess of error-recovery here.

/tmp/webcompile/_12636_0.cc:1:18: error: expected member name or ';' after
declaration specifiers
struct foo { int };
             ~~~ ^
/tmp/webcompile/_12636_0.cc:1:20: error: expected '}'
struct foo { int };
                   ^
/tmp/webcompile/_12636_0.cc:1:12: note: to match this '{'
struct foo { int };
           ^
/tmp/webcompile/_12636_0.cc:1:20: error: expected ';' after struct
struct foo { int };
                   ^
                   ;
3 errors generated.

I guess it skips the '}' as the (invalid) member name, and consumes the ";" as
the end of the member declaration. Then, it notices that it needs a '}' and a
';'.

On the other hand, g++ is almost perfect:

test.cc:1:18: error: expected unqualified-id before ‘}’ token

except for the legalese-speak "unqualified-id".


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

* [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct
       [not found] <bug-44854-4@http.gcc.gnu.org/bugzilla/>
  2011-10-03 10:25 ` [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct manu at gcc dot gnu.org
@ 2024-02-18 11:54 ` peter0x44 at disroot dot org
  1 sibling, 0 replies; 3+ messages in thread
From: peter0x44 at disroot dot org @ 2024-02-18 11:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44854

peter0x44 at disroot dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter0x44 at disroot dot org

--- Comment #4 from peter0x44 at disroot dot org ---
GCC trunk currently emits:
<source>:1:18: error: expected unqualified-id before '}' token
    1 | struct foo { int };
      |                  ^
Which seems pretty okay to me.

I still think there is room for improvement and I prefer clang's wording on
this issue:

<source>:1:18: error: expected member name or ';' after declaration specifiers
    1 | struct foo { int };
      |              ~~~ ^

I think more people are likely to understand what a "member name" is, rather
than "unqualified-id"

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

* [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct
  2010-07-07  7:15 [Bug c/44854] New: " pzhao at gcc dot gnu dot org
@ 2010-07-24 18:28 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-07-24 18:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-07-24 18:28 -------
identifier is the same as  member name.  In fact I say GCC's diagnostic is more
correct as ( can be there also.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44854


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

end of thread, other threads:[~2024-02-18 11:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-44854-4@http.gcc.gnu.org/bugzilla/>
2011-10-03 10:25 ` [Bug c/44854] Improve diagnostic for missing member name or ';' in a struct manu at gcc dot gnu.org
2024-02-18 11:54 ` peter0x44 at disroot dot org
2010-07-07  7:15 [Bug c/44854] New: " pzhao at gcc dot gnu dot org
2010-07-24 18:28 ` [Bug c/44854] " pinskia at gcc dot gnu dot org

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).