Implicit underlying enum type with MSVC compatibility (/Zc:enumTypes flag)

Greetings! MSVC used to have a bug where enums always had the implicit underlying type of int , independently of the enum’s items. This bug is accomodated for within clang’s MSVC compatibility mode, while the fix for it (the /Zc:enumTypes flag) is not.

The issue with this is that this results in information being lost for the enum’s items (as they are trimmed to fit the underlying type), so fixing this on the application side would likely require reparsing the items.

I’m not at all familiar with the clang infrastructure, but after some digging I believe this might potentially be a good fit for an option in LangOptions.def? I’d be glad to look into contributing the changes that would allow for support for this so any pointers would be appreciated! :slight_smile:

2 Likes

This seems like a reasonable request, it feels sufficiently useful and does not sound particularly difficult to implement.

Can you file a issue here: GitHub · Where software is built

and label it as a feature request.

Done! [Clang] Add support for `/Zc:enumTypes` compiler flag in MSVC mode · Issue #120759 · llvm/llvm-project · GitHub :slight_smile: