From: David Majnemer Date: Thu, 8 Oct 2015 07:45:35 +0000 (+0000) Subject: [Sema] Tweak incomplete enum types on MSVC ABI targets X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d63a6b8d6599722c2fc7747d72094a3eacb49ab;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249667 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 23d4491d04..fcc4095583 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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(); + } } } diff --git a/test/CodeGen/volatile-1.c b/test/CodeGen/volatile-1.c index 6912da3d93..f63274b37f 100644 --- a/test/CodeGen/volatile-1.c +++ b/test/CodeGen/volatile-1.c @@ -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; diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index d803812efd..7eec5761ea 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -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 { diff --git a/test/Sema/cast-incomplete.c b/test/Sema/cast-incomplete.c index ce20dfbf8b..dd10e00d44 100644 --- a/test/Sema/cast-incomplete.c +++ b/test/Sema/cast-incomplete.c @@ -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}} diff --git a/test/Sema/decl-in-prototype.c b/test/Sema/decl-in-prototype.c index 8cdbdf2fcd..e185d19b54 100644 --- a/test/Sema/decl-in-prototype.c +++ b/test/Sema/decl-in-prototype.c @@ -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;