From: Fariborz Jahanian Date: Fri, 4 Nov 2011 18:51:24 +0000 (+0000) Subject: objc: fixed enum type is supported in objc mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b25216a47681e7957c0e9ec37a3cf445ab24743;p=clang objc: fixed enum type is supported in objc mode. 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 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 806608cf43..05f48707aa 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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 index 0000000000..a057dc0d37 --- /dev/null +++ b/test/SemaObjC/fixed-enum.m @@ -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];