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.

Reply via email to