Bug 84026

Summary: invalid 'unnamed scoped enum is not allowed' when scoped enum has a full qualified-id
Product: gcc Reporter: Stephen M. Webb <smw>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: daniel.kruegler, webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 7.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83132
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2020-08-26 00:00:00
Bug Depends on:    
Bug Blocks: 12944    

Description Stephen M. Webb 2018-01-24 15:11:55 UTC
On GCC (all versions tested, up to and including 8.0.1 20180117 with -std=c++14 -pedantic) but not o nMSVC, ICC, or clang, the following code

    struct S1 {
      enum class E1;
    };
    enum class S1::E1 {}; // OK

    struct S2 {
      enum class E2;
    };
    enum class ::S1::E1 {}; // Not OK

spits out the following error.

9 : <source>:9:16: error: unnamed scoped enum is not allowed
     enum class ::S1::E1 {}; // Not OK
                ^~
9 : <source>:9:10: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
     enum class ::S1::E1 {}; // Not OK
     ~~~~ ^~~~~
          -----
9 : <source>:9:25: error: expected unqualified-id before '{' token
     enum class ::S1::E1 {}; // Not OK
                         ^
Looks like it's not quite parsing correctly.
Comment 1 Jonathan Wakely 2018-01-25 14:05:45 UTC
This rings a bell, I think it's a dup.
Comment 2 Jonathan Wakely 2018-01-25 14:09:20 UTC
Ah maybe I was thinking of PR 71664 but that's different.
Comment 3 Jonathan Wakely 2020-08-26 09:58:02 UTC
PR 83132 is related.
Comment 4 Jonathan Wakely 2020-08-26 09:58:26 UTC
Fixed testcase (so it doesn't define S1::E1 twice):

    struct S1 {
      enum class E1;
    };
    enum class S1::E1 {}; // OK

    struct S2 {
      enum class E2;
    };
    enum class ::S2::E2 {}; // Not OK