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

            Bug ID: 122568
           Summary: -Welaborated-enum-base not applied to
                    elaborated-type-specifiers in alias-declarations
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gulackeg at gmail dot com
  Target Milestone: ---

Test code:

    // https://godbolt.org/z/7bTn4P7hM

    // ✔ - GCC (>=14.1): warning: declaration of enumeration with fixed
    //     underlying type and no enumerator list is only permitted as a
    //     standalone declaration [-Welaborated-enum-base]
    // ✔ - GCC (<=13.4): error: expected ';' or '{' before 'E1'
    typedef enum E : int E1; // #1
    // ✗ - GCC: OK
    using E2 = enum E : int; // #2

The commit "c++: Accept elaborated-enum-base with pedwarn" (g:b106f11) made #1
accepted by GCC with a warning. However, #2 has been accepted since early
versions of GCC. The treatment of #1 and #2 should be consistent - #2 should
emit the same warning as #1.

Extra test code:

    // https://godbolt.org/z/hbKdnGdK5

    enum E : int;
    // ✔ - GCC: error: expected unqualified-id before ':' token
    typedef enum ::E : int E3;
    // ✔ - GCC: error: expected ';' before ':' token
    using E4 = enum ::E : int;

    namespace N {
    enum E : int;
    }
    // ✔ - GCC (>=14.1): warning: declaration of enumeration with fixed
    //     underlying type and no enumerator list is only permitted as a
    //     standalone declaration [-Welaborated-enum-base]
    // ✔ - GCC (<=13.4): error: expected ';' or '{' before 'E5'
    typedef enum N::E : int E5;
    // ✔ - GCC: error: opaque-enum-specifier must use a simple identifier
    using E6 = enum N::E : int;

Reply via email to