]> granicus.if.org Git - clang/commit
Emit -Wmicrosoft-enum-value warning instead of error in MS ABI
authorReid Kleckner <rnk@google.com>
Wed, 11 Sep 2019 01:01:06 +0000 (01:01 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 11 Sep 2019 01:01:06 +0000 (01:01 +0000)
commit20c2e19346d420611e0f67037a827c5d83ce4c0c
tree711c6cab3847bbee2f8c648557b3378d604458e9
parent9e36d0177be5c87b7280ce4abae1775056c83e6c
Emit -Wmicrosoft-enum-value warning instead of error in MS ABI

Summary:
The first NFC change is to replace a getCXXABI().isMicrosoft() check
with getTriple().isWindowsMSVCEnvironment(). This code takes effect in
non-C++ compilations, so it doesn't make sense to check the C++ ABI. In
the MS ABI, enums are always considered to be "complete" because the
underlying type of an unfixed enum will always be 'int'. This behavior
was moved from -fms-compatibility to MS ABI back in r249656.

The second change is functional, and it downgrades an error to a warning
when the MS ABI is used rather than only under -fms-compatibility. The
reasoning is that it's unreasonable for the following code to reject the
following code for all MS ABI targets with -fno-ms-compatibility:
  enum Foo { Foo_Val = 0xDEADBEEF };
This is valid code for any other target, but in the MS ABI, Foo_Val just
happens to be negative. With this change, clang emits a
-Wmicrosoft-enum-value warning on this code, but compiles it without
error.

Fixes PR38478

Reviewers: hans, rsmith, STL_MSFT

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67304

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371581 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDecl.cpp
test/Sema/MicrosoftCompatibility.c