]> granicus.if.org Git - clang/commitdiff
[Sema] Tweak incomplete enum types on MSVC ABI targets
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 8 Oct 2015 07:45:35 +0000 (07:45 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 8 Oct 2015 07:45:35 +0000 (07:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249667 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 23d4491d04ccbdfc181df4807800b1c261bfb3d5..fcc40955836eb97db41b4226000dc7de82c4d655 100644 (file)
@@ -11769,8 +11769,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
         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();
+      }
     }
   }
 
index 6912da3d9323ef6867e03a27758753a7b53c8a4e..f63274b37f61be73e07c035c301759811b4bae23 100644 (file)
@@ -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;
index d803812efd37d3bd4cfdafb7b98e61d79f4163eb..7eec5761ea055d492e8bfa41442740ca1c406dba 100644 (file)
@@ -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 {
index ce20dfbf8bb84732b54835301453e03f94c1d6ce..dd10e00d444ad5b7016f0f508766362bb7250030 100644 (file)
@@ -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}}
index 8cdbdf2fcdf2bd87bd345c60b6a1c23897ad4f4c..e185d19b544e3f254408c0d63dba49546d980bfe 100644 (file)
@@ -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;