Skip to content

Incorrect diagnostic wording for out-of-line enum declarations #134955

Open
@Endilll

Description

@Endilll

Consider the following (https://godbolt.org/z/cj1hMqbof):

struct A {
  enum E : int;
};

namespace N {
enum A::E : int { e1 };
}

Clang rejects this with error: cannot define or redeclare 'E' here because namespace 'N' does not enclose namespace 'A', but A is a struct and not a namespace.

Edit: more importantly, it seems that this code is well-formed per https://eel.is/c++draft/enum#dcl.enum-4:

If an enum-head-name contains a nested-name-specifier, the enclosing enum-specifier or opaque-enum-declaration D shall not inhabit a class scope and shall correspond to one or more declarations nominable in the class, class template, or namespace to which the nested-name-specifier refers ([basic.scope.scope]).
All those declarations shall have the same target scope; the target scope of D is that scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions