]> granicus.if.org Git - clang/commitdiff
objc: fixed enum type is supported in objc mode.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 4 Nov 2011 18:51:24 +0000 (18:51 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 4 Nov 2011 18:51:24 +0000 (18:51 +0000)
Fixes a bug where enumerator type is not this
fixed type. // rdar://10381507

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

lib/Sema/SemaDecl.cpp
test/SemaObjC/fixed-enum.m [new file with mode: 0644]

index 806608cf439c88c447886f0f6cac990e007a8681..05f48707aa2c98ef4cf2941e4d4cee8fc315f9c7 100644 (file)
@@ -9812,6 +9812,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
     unsigned NewWidth;
     bool NewSign;
     if (!getLangOptions().CPlusPlus &&
+        !Enum->isFixed() &&
         isRepresentableIntegerValue(Context, InitVal, Context.IntTy)) {
       NewTy = Context.IntTy;
       NewWidth = IntWidth;
diff --git a/test/SemaObjC/fixed-enum.m b/test/SemaObjC/fixed-enum.m
new file mode 100644 (file)
index 0000000..a057dc0
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10381507
+
+typedef enum : long { Foo } IntegerEnum;
+int arr[(sizeof(typeof(Foo)) == sizeof(typeof(IntegerEnum))) - 1];
+int arr1[(sizeof(typeof(Foo)) == sizeof(typeof(long))) - 1];
+int arr2[(sizeof(typeof(IntegerEnum)) == sizeof(typeof(long))) - 1];