]> granicus.if.org Git - clang/commitdiff
Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, so -fms...
authorEli Friedman <eli.friedman@gmail.com>
Thu, 16 Feb 2012 05:20:44 +0000 (05:20 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 16 Feb 2012 05:20:44 +0000 (05:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150663 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/MicrosoftCompatibility.c [new file with mode: 0644]
test/Sema/MicrosoftExtensions.c
test/SemaCXX/MicrosoftCompatibility-cxx98.cpp [new file with mode: 0644]
test/SemaCXX/MicrosoftExtensions.cpp
test/SemaTemplate/enum-forward.cpp

index 304304b776c64f8bbbc7b7286c1f4f036af6b403..9fa0349723530873af88e3bbdd7562766a3fad7b 100644 (file)
@@ -7820,7 +7820,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
                                           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 @@ CreateNewDecl:
         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 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
           // 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
diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c
new file mode 100644 (file)
index 0000000..c26c303
--- /dev/null
@@ -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'}}
+};
index a08aeab99b881e4ec4795f049e2daa51692504d5..a4a8acd78e8d98d278b6f9795b94163275410702 100644 (file)
@@ -21,16 +21,6 @@ struct D {
 };
 
 
-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'}}
-};
 
 
 
diff --git a/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp b/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
new file mode 100644 (file)
index 0000000..0c7d354
--- /dev/null
@@ -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}}
index 93da08f1f206e421d47d288403ffc0c05204f48c..0b72cd3e1fc0db73d90adcdd8b4eb3b18940f0c5 100644 (file)
@@ -92,11 +92,6 @@ void m1() {
   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}}
 
 
 
index 3a4f05c0baa418c718306d9571517753b6dcd70a..b25c21fc46359e4f0cf928ab2121f65c02f91943 100644 (file)
@@ -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 {