[PATCH] D67304: Emit -Wmicrosoft-enum-value warning instead of error in MS ABI

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 16:34:23 PDT 2019


rnk added a comment.

In D67304#1664696 <https://reviews.llvm.org/D67304#1664696>, @thakis wrote:

> We have the old TODO of changing this warning to be emitted at enum use time (e.g. when Foo_Val is compared to 0) instead of declaration time. Maybe that's a better fix. Or is implementing that very involved?


I guess it would depend on the logic of the point-of-use warning. We could make it very simple. We could:

- mark all enum types with coerced enumerators (maybe we already know this)
- warn on all ordering comparisons that use that enum type

If the user explicitly casts to any other integer type to do the comparison, we can expect them to know the rules.

I think it can't allow false negatives, though. -Wmicrosoft is kind of like our -pedantic mode for standard C. It basically says, if your code is -Wmicrosoft clean, we promise that it is not relying on Microsoft-specific behavior. The simplest way to do that is to soften the existing error to a warning, which is what this does.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67304/new/

https://reviews.llvm.org/D67304





More information about the cfe-commits mailing list