r249667 - [Sema] Tweak incomplete enum types on MSVC ABI targets

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 00:45:35 PDT 2015


Author: majnemer
Date: Thu Oct  8 02:45:35 2015
New Revision: 249667

URL: http://llvm.org/viewvc/llvm-project?rev=249667&view=rev
Log:
[Sema] Tweak incomplete enum types on MSVC ABI targets

Enums without an explicit, fixed, underlying type are implicitly given a
fixed 'int' type for ABI compatibility with MSVC.  However, we can
enforce the standard-mandated rules on these types as-if we didn't know
this fact if the tag is not part of a definition.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/CodeGen/volatile-1.c
    cfe/trunk/test/Parser/cxx0x-attributes.cpp
    cfe/trunk/test/Sema/cast-incomplete.c
    cfe/trunk/test/Sema/decl-in-prototype.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=249667&r1=249666&r2=249667&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct  8 02:45:35 2015
@@ -11769,8 +11769,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
         EnumUnderlying = Context.IntTy.getTypePtr();
 
     } else if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-      // Microsoft enums are always of int type.
-      EnumUnderlying = Context.IntTy.getTypePtr();
+      if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
+        // Microsoft enums are always of int type.
+        EnumUnderlying = Context.IntTy.getTypePtr();
+      }
     }
   }
 

Modified: cfe/trunk/test/CodeGen/volatile-1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/volatile-1.c?rev=249667&r1=249666&r2=249667&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/volatile-1.c (original)
+++ cfe/trunk/test/CodeGen/volatile-1.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -Wno-return-type -Wno-unused-value -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -o - | FileCheck %s
 
 // CHECK: @i = common global [[INT:i[0-9]+]] 0
 volatile int i, j, k;

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=249667&r1=249666&r2=249667&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat %s
 
 // Need std::initializer_list
 namespace std {

Modified: cfe/trunk/test/Sema/cast-incomplete.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cast-incomplete.c?rev=249667&r1=249666&r2=249667&view=diff
==============================================================================
--- cfe/trunk/test/Sema/cast-incomplete.c (original)
+++ cfe/trunk/test/Sema/cast-incomplete.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -verify
 // PR5692
 
 enum x;            // expected-note   {{forward declaration}}

Modified: cfe/trunk/test/Sema/decl-in-prototype.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-in-prototype.c?rev=249667&r1=249666&r2=249667&view=diff
==============================================================================
--- cfe/trunk/test/Sema/decl-in-prototype.c (original)
+++ cfe/trunk/test/Sema/decl-in-prototype.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -fsyntax-only -verify %s
 
 const int AA = 5;
 




More information about the cfe-commits mailing list