brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 13dc677 Raw
50 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify=expected,c -xc %s3 4#ifdef __OBJC__5#if !__has_feature(objc_fixed_enum)6#  error Enumerations with a fixed underlying type are not supported7#endif8#endif9 10#if !__has_extension(cxx_fixed_enum)11#  error Enumerations with a fixed underlying type are not supported12#endif13 14typedef long Integer;15 16typedef enum : Integer { Enumerator1, Enumerator2 } Enumeration;17 18int array[sizeof(Enumeration) == sizeof(long)? 1 : -1];19 20 21enum Color { Red, Green, Blue };22 23struct X { 24  enum Color : 4;25  enum Color field1: 4;26  enum Other : Integer field2; // c-error {{only permitted as a standalone}}27  enum Other : Integer field3 : 4; // c-error {{only permitted as a standalone}}28  enum  : Integer { Blah, Blarg } field4 : 4;29};30 31void test(void) {32  long value = 2;33  Enumeration e = value;34}35 36typedef enum : long { Foo } IntegerEnum;37int arr[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(IntegerEnum)))? 1 : -1];38int arr1[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(long)))? 1 : -1];39int arr2[(sizeof(__typeof__(IntegerEnum)) == sizeof(__typeof__(long)))? 1 : -1];40 41typedef enum : long long { Bar = -1 } LongLongEnum;42int arr3[(long long)Bar == (long long)-1 ? 1 : -1];43 44typedef enum : Integer { BaseElem } BaseEnum;45typedef enum : BaseEnum { DerivedElem } DerivedEnum; // expected-error {{non-integral type 'BaseEnum' is an invalid underlying type}}46 47enum MyEnum : _Bool {48  MyThing = 049};50