public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95288] New: Poor error message with function-scope enum definition
@ 2020-05-23 13:33 nathan at gcc dot gnu.org
  2020-05-26 21:04 ` [Bug c++/95288] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-05-23 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95288
           Summary: Poor error message with function-scope enum definition
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 48587
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48587&action=edit
testcase

A malformed enum definition in function-scope gives a very poor diagnostic.  In
this example I typoed a '.' (DOT) for a ',' (COMMA).  the compiler complains at
the 'enum' token, not at the dot.  

Contrast the error for X and (namespace-scope) Y.  Class-scope enums behave
like namespace-scope ones.

(1)bester:139>g++ -c f.cc
f.cc: In function ‘void f()’:
f.cc:4:3: error: expected primary-expression before ‘enum’
    4 |   enum X
      |   ^~~~
f.cc: At global scope:
f.cc:13:4: error: expected ‘}’ before ‘.’ token
   13 |   c. // DOT
      |    ^
f.cc:12:1: note: to match this ‘{’
   12 | {
      | ^
f.cc:13:4: error: expected unqualified-id before ‘.’ token
   13 |   c. // DOT
      |    ^
f.cc:15:1: error: expected declaration before ‘}’ token
   15 | };

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

end of thread, other threads:[~2020-07-13 17:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 13:33 [Bug c++/95288] New: Poor error message with function-scope enum definition nathan at gcc dot gnu.org
2020-05-26 21:04 ` [Bug c++/95288] " mpolacek at gcc dot gnu.org
2020-07-13 16:55 ` mpolacek at gcc dot gnu.org
2020-07-13 17:07 ` cvs-commit at gcc dot gnu.org
2020-07-13 17:08 ` mpolacek at gcc dot gnu.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).