]> granicus.if.org Git - clang/commit
[Sema] Don't mark plain MS enums as fixed
authorReid Kleckner <rnk@google.com>
Mon, 12 Feb 2018 17:37:06 +0000 (17:37 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 12 Feb 2018 17:37:06 +0000 (17:37 +0000)
commitc537122805731f3c43676e7f0f7ba5543aecdfa2
tree22a67a5a2db6e9f0e85171d12ed970c7cd18149c
parent66b9f8607f9757e7782d0320ee4ec5a513052e80
[Sema] Don't mark plain MS enums as fixed

Summary:
This fixes a flaw in our AST: PR27098

MSVC always gives plain enums the underlying type 'int'. Clang does this
as well, but we claim the enum is "fixed", as if the user actually wrote
': int'. It means we end up emitting spurious -Wsign-compare warnings on
code like this:

  enum Vals { E1, E2, E3 };
  bool f(unsigned v1, Vals v2) {
    return v1 == v2;
  }

We think 'v2' can take on negative values because we think 'Vals' is
fixed. This fixes that.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324913 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Decl.h
include/clang/Sema/Sema.h
lib/AST/Type.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/Sema/sign-compare-enum.c