Bug 84026 - invalid 'unnamed scoped enum is not allowed' when scoped enum has a full qualified-id
Summary: invalid 'unnamed scoped enum is not allowed' when scoped enum has a full qual...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: c++-lookup, c++-name-lookup
  Show dependency treegraph
 
Reported: 2018-01-24 15:11 UTC by Stephen M. Webb
Modified: 2020-08-26 09:58 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-08-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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