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.
This rings a bell, I think it's a dup.
Ah maybe I was thinking of PR 71664 but that's different.
PR 83132 is related.
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