]> granicus.if.org Git - clang/commitdiff
In Microsoft Mode, disable the C++11 strict integral conversion rules for enumerator...
authorFrancois Pichet <pichet2000@gmail.com>
Sat, 21 Jan 2012 23:26:50 +0000 (23:26 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sat, 21 Jan 2012 23:26:50 +0000 (23:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/MicrosoftCompatibility.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 7fd10735b7a4d3099a61e19d160860da104598cb..696e84234cd2f66f0c7f39fbfb045da5ebca55c3 100644 (file)
@@ -9559,7 +9559,8 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
       EltTy = Context.DependentTy;
     else {
       SourceLocation ExpLoc;
-      if (getLangOptions().CPlusPlus0x && Enum->isFixed()) {
+      if (getLangOptions().CPlusPlus0x && Enum->isFixed() &&
+          !getLangOptions().MicrosoftMode) {
         // C++11 [dcl.enum]p5: If the underlying type is fixed, [...] the
         // constant-expression in the enumerator-definition shall be a converted
         // constant expression of the underlying type.
index 4db543720527e27344f6bd956567570bfdeffa0b..ad11b16cce067da825fd751ff6edb88fd99786b1 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
 
 
@@ -135,5 +135,10 @@ template void function_missing_typename<D>(const D::Type param);
 \r
 }\r
 \r
+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'}}
+};
 \r
 \r
index 62f4f61471807c279e1e705d063a1892c1f9a4ea..93da08f1f206e421d47d288403ffc0c05204f48c 100644 (file)
@@ -99,11 +99,6 @@ ENUM var2 = (ENUM)3;
 enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
 
 
-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'}}
-};
 
 
 void f(long long);