Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 #if !__has_feature(objc_fixed_enum)
      4 #  error Enumerations with a fixed underlying type are not supported
      5 #endif
      6 
      7 typedef long Integer;
      8 
      9 typedef enum : Integer { Enumerator1, Enumerator2 } Enumeration;
     10 
     11 int array[sizeof(Enumeration) == sizeof(long)? 1 : -1];
     12 
     13 
     14 enum Color { Red, Green, Blue };
     15 
     16 struct X { 
     17   enum Color : 4;
     18   enum Color field1: 4;
     19   enum Other : Integer field2;
     20   enum Other : Integer field3 : 4;
     21   enum  : Integer { Blah, Blarg } field4 : 4;
     22 };
     23 
     24 void test() {
     25   long value = 2;
     26   Enumeration e = value;
     27 }
     28 
     29 // <rdar://10381507>
     30 typedef enum : long { Foo } IntegerEnum;
     31 int arr[(sizeof(typeof(Foo)) == sizeof(typeof(IntegerEnum))) - 1];
     32 int arr1[(sizeof(typeof(Foo)) == sizeof(typeof(long))) - 1];
     33 int arr2[(sizeof(typeof(IntegerEnum)) == sizeof(typeof(long))) - 1];
     34 
     35 // <rdar://problem/10760113>
     36 typedef enum : long long { Bar = -1 } LongLongEnum;
     37 int arr3[(long long)Bar == (long long)-1 ? 1 : -1];
     38