public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
@ 2015-07-29  3:15 anders.granlund.0 at gmail dot com
  2015-07-29  9:24 ` [Bug c++/67048] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2015-07-29  3:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67048
           Summary: GCC rejects well-formed program using empty anonymous
                    enum specifier in a variable declaration
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anders.granlund.0 at gmail dot com
  Target Milestone: ---

Consider the following well-formed program (prog.cc):

enum {} x;
int main() {}

Compile it with the following command line:

g++ prog.cc -std=c++14 -pedantic-errors

The following error message is given. I expected to get no error messages since
the program is well-formed.

prog.cc:1:6: error: ISO C++ forbids empty anonymous enum [-Wpedantic]
 enum {} x;
      ^

I have tried this with gcc HEAD 6.0.0 20150728 here:

http://melpon.org/wandbox/permlink/BXXfLL4WOU5lBOfk


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

* [Bug c++/67048] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
@ 2015-07-29  9:24 ` redi at gcc dot gnu.org
  2021-08-04 22:07 ` [Bug c++/67048] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-29  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-29
     Ever confirmed|0                           |1


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

* [Bug c++/67048] [9/10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
  2015-07-29  9:24 ` [Bug c++/67048] " redi at gcc dot gnu.org
@ 2021-08-04 22:07 ` pinskia at gcc dot gnu.org
  2022-01-17 15:18 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.5
   Target Milestone|---                         |9.5
      Known to fail|                            |10.1.0, 11.1.0, 4.9.0,
                   |                            |9.4.0
            Summary|GCC rejects well-formed     |[9/10/11/12 Regression] GCC
                   |program using empty         |rejects well-formed program
                   |anonymous enum specifier in |using empty anonymous enum
                   |a variable declaration      |specifier in a variable
                   |                            |declaration

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This was almost definitely caused by PR 54216 .

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

* [Bug c++/67048] [9/10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
  2015-07-29  9:24 ` [Bug c++/67048] " redi at gcc dot gnu.org
  2021-08-04 22:07 ` [Bug c++/67048] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-17 15:18 ` rguenth at gcc dot gnu.org
  2022-01-31 15:27 ` marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
           Priority|P3                          |P2
            Version|unknown                     |11.1.0

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

* [Bug c++/67048] [9/10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-01-17 15:18 ` rguenth at gcc dot gnu.org
@ 2022-01-31 15:27 ` marxin at gcc dot gnu.org
  2022-04-28 20:14 ` [Bug c++/67048] [9/10/11/12/13 " mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-31 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

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

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
All releases I have (4.9.0) report the error.

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

* [Bug c++/67048] [9/10/11/12/13 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-01-31 15:27 ` marxin at gcc dot gnu.org
@ 2022-04-28 20:14 ` mpolacek at gcc dot gnu.org
  2022-04-29 19:08 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-28 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r197742.  I'll take a look.

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

* [Bug c++/67048] [9/10/11/12/13 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-28 20:14 ` [Bug c++/67048] [9/10/11/12/13 " mpolacek at gcc dot gnu.org
@ 2022-04-29 19:08 ` cvs-commit at gcc dot gnu.org
  2022-04-29 19:09 ` [Bug c++/67048] [9/10/11/12 " mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-29 19:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:fd0d3e9121c5aa65150d242676be6bbdc8d4a92a

commit r13-51-gfd0d3e9121c5aa65150d242676be6bbdc8d4a92a
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Apr 28 16:50:06 2022 -0400

    c++: pedwarn for empty unnamed enum in decl [PR67048]

    [dcl.dcl]/5 says that

      enum { };

    is ill-formed, and since r197742 we issue a pedwarn.  However, the
    pedwarn also fires for

       enum { } x;

    which is well-formed.  So only warn when {} is followed by a ;.  This
    should be correct since you can't have "enum {}, <whatever>" -- that
    produces "expected unqualified-id before ',' token".

            PR c++/67048

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_enum_specifier): Warn about empty unnamed
enum
            only when it's followed by a semicolon.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/enum42.C: New test.

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

* [Bug c++/67048] [9/10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-04-29 19:08 ` cvs-commit at gcc dot gnu.org
@ 2022-04-29 19:09 ` mpolacek at gcc dot gnu.org
  2022-05-27  9:35 ` [Bug c++/67048] [10/11/12 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-29 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12/13 Regression]  |[9/10/11/12 Regression] GCC
                   |GCC rejects well-formed     |rejects well-formed program
                   |program using empty         |using empty anonymous enum
                   |anonymous enum specifier in |specifier in a variable
                   |a variable declaration      |declaration

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 13 so far.

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

* [Bug c++/67048] [10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-04-29 19:09 ` [Bug c++/67048] [9/10/11/12 " mpolacek at gcc dot gnu.org
@ 2022-05-27  9:35 ` rguenth at gcc dot gnu.org
  2022-06-28 10:31 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug c++/67048] [10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-05-27  9:35 ` [Bug c++/67048] [10/11/12 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:31 ` jakub at gcc dot gnu.org
  2022-08-12  8:11 ` cvs-commit at gcc dot gnu.org
  2023-03-07 17:42 ` [Bug c++/67048] [10/11 " mpolacek at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug c++/67048] [10/11/12 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (8 preceding siblings ...)
  2022-06-28 10:31 ` jakub at gcc dot gnu.org
@ 2022-08-12  8:11 ` cvs-commit at gcc dot gnu.org
  2023-03-07 17:42 ` [Bug c++/67048] [10/11 " mpolacek at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-12  8:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:60fed79c1e9a968eaedf292b298d19c9475ad37a

commit r12-8683-g60fed79c1e9a968eaedf292b298d19c9475ad37a
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Apr 28 16:50:06 2022 -0400

    c++: pedwarn for empty unnamed enum in decl [PR67048]

    [dcl.dcl]/5 says that

      enum { };

    is ill-formed, and since r197742 we issue a pedwarn.  However, the
    pedwarn also fires for

       enum { } x;

    which is well-formed.  So only warn when {} is followed by a ;.  This
    should be correct since you can't have "enum {}, <whatever>" -- that
    produces "expected unqualified-id before ',' token".

            PR c++/67048

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_enum_specifier): Warn about empty unnamed
enum
            only when it's followed by a semicolon.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/enum42.C: New test.

    (cherry picked from commit fd0d3e9121c5aa65150d242676be6bbdc8d4a92a)

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

* [Bug c++/67048] [10/11 Regression] GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration
  2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
                   ` (9 preceding siblings ...)
  2022-08-12  8:11 ` cvs-commit at gcc dot gnu.org
@ 2023-03-07 17:42 ` mpolacek at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-07 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-03-07 17:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-29  3:15 [Bug c++/67048] New: GCC rejects well-formed program using empty anonymous enum specifier in a variable declaration anders.granlund.0 at gmail dot com
2015-07-29  9:24 ` [Bug c++/67048] " redi at gcc dot gnu.org
2021-08-04 22:07 ` [Bug c++/67048] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-17 15:18 ` rguenth at gcc dot gnu.org
2022-01-31 15:27 ` marxin at gcc dot gnu.org
2022-04-28 20:14 ` [Bug c++/67048] [9/10/11/12/13 " mpolacek at gcc dot gnu.org
2022-04-29 19:08 ` cvs-commit at gcc dot gnu.org
2022-04-29 19:09 ` [Bug c++/67048] [9/10/11/12 " mpolacek at gcc dot gnu.org
2022-05-27  9:35 ` [Bug c++/67048] [10/11/12 " rguenth at gcc dot gnu.org
2022-06-28 10:31 ` jakub at gcc dot gnu.org
2022-08-12  8:11 ` cvs-commit at gcc dot gnu.org
2023-03-07 17:42 ` [Bug c++/67048] [10/11 " 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).