Files
swift-mirror/test/Interop/Cxx/class/Inputs/nested-enums.h
John Hui 02ba254130 [cxx-interop] Support nested unscoped enum constants as C++ record members
That is, when we have:

    struct Foo {
      enum Bar { B1, B2 };
    };

We should be able to access Foo.B1 and Foo.B2 in Swift just as we would
access Foo::B1 and Foo::B2 in C++.

The previous commit makes this lookup possible, but doesn't load those
members when dumping the module interface. This patch fixes the member
loading path.

Furthermore, it *broke* ObjC interop, whereby those enum members were
available at the top-level scope, to be consistent with C scoping rules.
This patch fixes that by changing the effective Clang context for such
enums to be the enclosing struct, rather than the translation unit.

Closes #54905
Closes #62127

rdar://175283372
2026-06-03 14:17:37 -07:00

30 lines
313 B
C++

#pragma once
struct Struct {
enum class Scoped {
S1, S2, S3
};
enum Unscoped {
U1, U2, U3
};
enum /* anonymous */ {
A1, A2, A3
};
};
namespace Namespace {
enum class Scoped {
S1, S2, S3
};
enum Unscoped {
U1, U2, U3
};
enum /* anonymous */ {
A1, A2, A3
};
};