| Issue |
169601
|
| Summary |
[Clang] Support `/Zc:enumTypes` in Clang-cl mode
|
| Labels |
clang:frontend,
clang-cl,
diverges-from:msvc
|
| Assignees |
|
| Reporter |
frederick-vs-ja
|
MSVC has recently added a new option `/Zc:enumTypes` ([documentation](https://learn.microsoft.com/en-us/cpp/build/reference/zc-enumtypes?view=msvc-170)), under which the underlying type is selected conformingly (per [[dcl.enum]/7](https://eel.is/c++draft/dcl.enum#7)) for a enumeration type without a fixed underlying type.
Example ([Godbolt link](https://godbolt.org/z/99a5nooqW)):
```C++
template<class, class>
constexpr bool is_same_v = false;
template<class T>
constexpr bool is_same_v<T, T> = true;
enum E1 {
m1 = 0x8000'0000ULL,
};
static_assert(is_same_v<__underlying_type(E1), unsigned int>);
enum E2 {
ix = is_same_v<__underlying_type(E2), int>,
m2 = 0x1'0000'0000ULL,
iy = is_same_v<__underlying_type(E2), int>,
};
static_assert(ix); // accepted by MSVC, but weird
static_assert(iy); // accepted by MSVC, but weird
static_assert(is_same_v<__underlying_type(E2), long long>);
enum E3 {
m3 = 0xFFFF'FFFF'FFFF'FFFFULL,
};
static_assert(is_same_v<__underlying_type(E3), unsigned long long>);
```
Note that MSVC still thinks the underlying type is `int` when the enum is incomplete. It's questionable whether Clang-cl mode should still be bug-compatible with MSVC on this, see also #169472.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs