[cfe-commits] r150663 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/MicrosoftCompatibility.c test/Sema/MicrosoftExtensions.c test/SemaCXX/MicrosoftCompatibility-cxx98.cpp test/SemaCXX/MicrosoftExtensions.cpp test/SemaTemplate/enum-forward.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Feb 15 21:20:45 PST 2012
Author: efriedma
Date: Wed Feb 15 23:20:44 2012
New Revision: 150663
URL: http://llvm.org/viewvc/llvm-project?rev=150663&view=rev
Log:
Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>.
Added:
cfe/trunk/test/Sema/MicrosoftCompatibility.c
cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
cfe/trunk/test/SemaTemplate/enum-forward.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=150663&r1=150662&r2=150663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 15 23:20:44 2012
@@ -7820,7 +7820,7 @@
UPPC_FixedUnderlyingType))
EnumUnderlying = Context.IntTy.getTypePtr();
- } else if (getLangOptions().MicrosoftExt)
+ } else if (getLangOptions().MicrosoftMode)
// Microsoft enums are always of int type.
EnumUnderlying = Context.IntTy.getTypePtr();
}
@@ -8281,7 +8281,7 @@
Diag(Def->getLocation(), diag::note_previous_definition);
} else {
unsigned DiagID = diag::ext_forward_ref_enum;
- if (getLangOptions().MicrosoftExt)
+ if (getLangOptions().MicrosoftMode)
DiagID = diag::ext_ms_forward_ref_enum;
else if (getLangOptions().CPlusPlus)
DiagID = diag::err_forward_ref_enum;
@@ -9682,7 +9682,7 @@
// we perform a non-narrowing conversion as part of converted constant
// expression checking.
if (!isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
- if (getLangOptions().MicrosoftExt) {
+ if (getLangOptions().MicrosoftMode) {
Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).take();
} else
Added: cfe/trunk/test/Sema/MicrosoftCompatibility.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftCompatibility.c?rev=150663&view=auto
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftCompatibility.c (added)
+++ cfe/trunk/test/Sema/MicrosoftCompatibility.c Wed Feb 15 23:20:44 2012
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+
+enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+enum ENUM1 var1 = 3;
+enum ENUM1* var2 = 0;
+
+
+enum ENUM2 {
+ ENUM2_a = (enum ENUM2) 4,
+ ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+ ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+};
Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=150663&r1=150662&r2=150663&view=diff
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Wed Feb 15 23:20:44 2012
@@ -21,16 +21,6 @@
};
-enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-enum ENUM1 var1 = 3;
-enum ENUM1* var2 = 0;
-
-
-enum ENUM2 {
- ENUM2_a = (enum ENUM2) 4,
- ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
- ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
-};
Added: cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=150663&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (added)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp Wed Feb 15 23:20:44 2012
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++98 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
+
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+ENUM *var = 0;
+ENUM var2 = (ENUM)3;
+enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=150663&r1=150662&r2=150663&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Wed Feb 15 23:20:44 2012
@@ -92,11 +92,6 @@
h1(&M::subtractP);
}
-//MSVC allows forward enum declaration
-enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-ENUM *var = 0;
-ENUM var2 = (ENUM)3;
-enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
Modified: cfe/trunk/test/SemaTemplate/enum-forward.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/enum-forward.cpp?rev=150663&r1=150662&r2=150663&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/enum-forward.cpp (original)
+++ cfe/trunk/test/SemaTemplate/enum-forward.cpp Wed Feb 15 23:20:44 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s
template<typename T>
struct X {
More information about the cfe-commits
mailing list