Files
swift-mirror/test/SILOptimizer/Inputs/switch_enum_objc.h
Allan Shortlidge 455f3dcaee AST: Clang enum elements can't be unavailable during lowering.
There aren't sufficiently strong compiler checks that would prevent unavailable
elements of clang enums from being instantiated at runtime, so don't consider
any clang enum elements as unavailable during lowering. Since there aren't any
symbols associated with clang enum elements, we don't have to worry about
linker failures that might result from leaving references to them in SIL.
2023-08-15 17:13:10 -07:00

30 lines
992 B
C

// Even though these are marked "closed", Swift shouldn't trust it.
enum Alpha {
AlphaA __attribute__((swift_name("a"))),
AlphaB __attribute__((swift_name("b"))),
AlphaC __attribute__((swift_name("c"))),
AlphaD __attribute__((swift_name("d"))),
AlphaE __attribute__((swift_name("e")))
} __attribute__((enum_extensibility(closed)));
enum Coin {
CoinHeads,
CoinTails
} __attribute__((enum_extensibility(closed)));
// Swift should preserve branches matching the unavailable elements in clang
// enums since there are not strong compiler protections preventing these values
// from being instantiated at runtime.
enum Dimension {
DimensionX __attribute__((swift_name("x"))),
DimensionY __attribute__((swift_name("y"))),
DimensionZ __attribute__((swift_name("z"))) __attribute__((unavailable)),
} __attribute__((enum_extensibility(open)));
enum UnfairCoin {
UnfairCoinHeads,
UnfairCoinTails __attribute__((unavailable)),
} __attribute__((enum_extensibility(closed)));