public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109222] New: Confusing error for declaring an enum class with unknown type
@ 2023-03-21  1:48 barry.revzin at gmail dot com
  2023-03-21  2:07 ` [Bug c++/109222] " pinskia at gcc dot gnu.org
  2023-03-21  2:10 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: barry.revzin at gmail dot com @ 2023-03-21  1:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109222
           Summary: Confusing error for declaring an enum class with
                    unknown type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

This program fails to compile (as it should, since the first line is commented
out):

// using i32 = int;
enum class E : i32 { red, green, blue };

But the error is... 

<source>:2:6: warning: elaborated-type-specifier for a scoped enum must not use
the 'class' keyword
    2 | enum class E : i32 { red, green, blue };
      | ~~~~ ^~~~~
      |      -----
<source>:2:14: error: found ':' in nested-name-specifier, expected '::'
    2 | enum class E : i32 { red, green, blue };
      |              ^
      |              ::
<source>:2:12: error: 'E' has not been declared
    2 | enum class E : i32 { red, green, blue };
      |            ^
<source>:2:20: error: expected unqualified-id before '{' token
    2 | enum class E : i32 { red, green, blue };
      |                    ^

In this case I was missing an include for the typedef, but boy did that take me
a while to figure out.

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

* [Bug c++/109222] Confusing error for declaring an enum class with unknown type
  2023-03-21  1:48 [Bug c++/109222] New: Confusing error for declaring an enum class with unknown type barry.revzin at gmail dot com
@ 2023-03-21  2:07 ` pinskia at gcc dot gnu.org
  2023-03-21  2:10 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-21  2:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-03-21
           Keywords|                            |diagnostic

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

clang does a decent job here:
<source>:1:16: error: unknown type name 'i32'
enum class E : i32 { red, green, blue };
               ^

Though clang error messages for:
```
struct E
{
  enum i32 : int;
};
enum E : i32 { red, green, blue };
```
Seems off ...

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

* [Bug c++/109222] Confusing error for declaring an enum class with unknown type
  2023-03-21  1:48 [Bug c++/109222] New: Confusing error for declaring an enum class with unknown type barry.revzin at gmail dot com
  2023-03-21  2:07 ` [Bug c++/109222] " pinskia at gcc dot gnu.org
@ 2023-03-21  2:10 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-21  2:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Duplicate of bug 64758 in the end.

*** This bug has been marked as a duplicate of bug 64758 ***

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

end of thread, other threads:[~2023-03-21  2:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21  1:48 [Bug c++/109222] New: Confusing error for declaring an enum class with unknown type barry.revzin at gmail dot com
2023-03-21  2:07 ` [Bug c++/109222] " pinskia at gcc dot gnu.org
2023-03-21  2:10 ` pinskia 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).