[PATCH] D67304: Unify checking enumerator values in ObjC, C, and MSVC modes

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 15:33:17 PDT 2019


rnk created this revision.
rnk added reviewers: hans, rsmith, STL_MSFT.
Herald added a project: clang.

These three modes need to range check enumerator values differently than
C++ does. Before this change, we had two codepaths doing the same thing
in two cases:

1. enum complete (ObjC fixed & Microsoft unfixed)
2. enum incomplete (C99 unfixed)

Now we share the code, but have separate diagnostic paths.

The main functional change is that -fno-ms-compatibility now no longer
sends us down the hard error diagnostic code path for ObjC fixed enums.
Instead, complete-but-not-fixed MS enums go down the C99 codepath which
issues a -Wmicrosoft-enum-value warning about the enum value not being
representable as an 'int'. This was highlighted as the single largest
blocker to compiling windows.h with -fno-ms-compatibility, so this
should make that feasible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67304

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/MicrosoftCompatibility.c
  clang/test/SemaCXX/MicrosoftCompatibility.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67304.219189.patch
Type: text/x-patch
Size: 8008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190906/acc43d01/attachment.bin>


More information about the cfe-commits mailing list