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

* [Bug c++/95288] Poor error message with function-scope enum definition
  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 ` mpolacek at gcc dot gnu.org
  2020-07-13 16:55 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-26 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-05-26
     Ever confirmed|0                           |1
           Keywords|                            |diagnostic

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/95288] Poor error message with function-scope enum definition
  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
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-13 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Somewhat improved by r11-2064, though we still generate junk that seem
redundant.  But at least it says
error: expected ‘}’ before ‘.’ token

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

* [Bug c++/95288] Poor error message with function-scope enum definition
  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
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-13 17:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:6a9a3434c7396ea14c8f9c291694faea382c36dc

commit r11-2067-g6a9a3434c7396ea14c8f9c291694faea382c36dc
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jul 13 13:05:06 2020 -0400

    c++: Add test [PR95288]

    Somewhat improved by r11-2064, though we still generate junk that seems
    redundant.  But at least it says
    error: expected â}â before â.â token

            PR c++/95288
            * g++.dg/diagnostic/enum2.C: New test.

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

* [Bug c++/95288] Poor error message with function-scope enum definition
  2020-05-23 13:33 [Bug c++/95288] New: Poor error message with function-scope enum definition nathan at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-07-13 17:07 ` cvs-commit at gcc dot gnu.org
@ 2020-07-13 17:08 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-13 17:08 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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