https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64758
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- For this code: enum class foo : bar { baz }; auto x = foo::baz; We give: e.C:1:6: warning: elaborated-type-specifier for a scoped enum must not use the ‘class’ keyword 1 | enum class foo : bar { baz }; | ~~~~ ^~~~~ | ----- e.C:1:16: error: found ‘:’ in nested-name-specifier, expected ‘::’ 1 | enum class foo : bar { baz }; | ^ | :: e.C:1:12: error: ‘foo’ has not been declared 1 | enum class foo : bar { baz }; | ^~~ e.C:1:22: error: expected unqualified-id before ‘{’ token 1 | enum class foo : bar { baz }; | ^ e.C:2:10: error: ‘foo’ has not been declared 2 | auto x = foo::baz; | ^~~ Every one of these diagnostics is the result of bad error recovery from the initial problem. The warning is just nonsense. The first error is a bad recovery, we should not assume it's a bested-name-specifier, we should assume it's an enum-base with an undeclared type in the type-specifier-seq. The remaining errors are because we failed to do anything useful with the bad enum definition. I suggest that we should notice that ": bar" is bad, give an error about "bar" being undeclared, and then act as though no enum-base was present for the rest of the compilation. All the other diagnostics should vanish at that point. We won't complain about a bogus elaborared-type-specifier that isn't present. We won't say 'foo' is undeclared. We won't complain about expecting an unqualified-id (when one is actually present, just not one we recognize), and we won't complain about foo::baz being undeclared.