1// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2
3#if !__has_feature(objc_fixed_enum)
4#  error Enumerations with a fixed underlying type are not supported
5#endif
6
7typedef long Integer;
8
9typedef enum : Integer { Enumerator1, Enumerator2 } Enumeration;
10
11int array[sizeof(Enumeration) == sizeof(long)? 1 : -1];
12
13
14enum Color { Red, Green, Blue };
15
16struct 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
24void test() {
25  long value = 2;
26  Enumeration e = value;
27}
28
29// <rdar://10381507>
30typedef enum : long { Foo } IntegerEnum;
31int arr[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(IntegerEnum)))? 1 : -1];
32int arr1[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(long)))? 1 : -1];
33int arr2[(sizeof(__typeof__(IntegerEnum)) == sizeof(__typeof__(long)))? 1 : -1];
34
35// <rdar://problem/10760113>
36typedef enum : long long { Bar = -1 } LongLongEnum;
37int arr3[(long long)Bar == (long long)-1 ? 1 : -1];
38
39typedef enum : Integer { BaseElem } BaseEnum;
40typedef enum : BaseEnum { DerivedElem } DerivedEnum; // expected-error {{non-integral type 'BaseEnum' is an invalid underlying type}}
41