1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 // Test checks that 'mode' attribute is handled correctly with enums, i. e. code 4 // 1. "typedef enum { A } __attribute__((mode(HI))) T;" is accepted, 5 // 2. "enum X __attribute__((mode(QI))) var;" forms a complete integer type. 6 // 3. "enum { A } __attribute__((mode(V4SI))) var;" is not accepted (vector mode). 7 8 typedef enum { E4 } EnumType; 9 main()10int main() { 11 // Vector mode are not allowed with enums. 12 typedef enum { E1 } __attribute__((mode(V4QI))) RejectedType1; // expected-error{{mode 'V4QI' is not supported for enumeration types}} 13 // expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated}} 14 typedef enum __attribute__((mode(V8HI))) { E2 } RejectedType2; // expected-error{{mode 'V8HI' is not supported for enumeration types}} 15 // expected-warning@-1{{deprecated}} 16 typedef enum E3 __attribute__((mode(V2SI))) RejectedType3; // expected-error{{mode 'V2SI' is not supported for enumeration types}} 17 // expected-warning@-1{{deprecated}} 18 typedef EnumType __attribute__((mode(V4DI))) RejectedType4; // expected-error{{mode 'V4DI' is not supported for enumeration types}} 19 // expected-warning@-1{{deprecated}} 20 EnumType v1 __attribute__((mode(V4QI))); // expected-error{{mode 'V4QI' is not supported for enumeration types}} 21 // expected-warning@-1{{deprecated}} 22 enum __attribute__((mode(V8HI))) { E5 } v2; // expected-error{{mode 'V8HI' is not supported for enumeration types}} 23 // expected-warning@-1{{deprecated}} 24 25 // Incomplete enums without mode attribute are not allowed. 26 typedef enum Y IncompleteYType; // expected-note{{forward declaration of 'enum Y'}} 27 28 enum X a1; // expected-error{{variable has incomplete type 'enum X'}} 29 // expected-note@-1{{forward declaration of 'enum X'}} 30 IncompleteYType a2; // expected-error{{variable has incomplete type 'IncompleteYType' (aka 'enum Y')}} 31 32 // OK with 'mode' attribute. 33 typedef enum Y __attribute__((mode(QI))) CompleteYType1; 34 typedef enum Y CompleteYType2 __attribute__((mode(HI))); 35 typedef enum { A1, B1 } __attribute__((mode(QI))) CompleteType3; 36 typedef enum { A2, B2 } CompleteType4 __attribute__((mode(QI))); 37 typedef enum __attribute__((mode(QI))) { A3, B3 } CompleteType5; 38 39 enum X __attribute__((mode(QI))) a3; 40 enum X a4 __attribute__((mode(HI))); 41 IncompleteYType __attribute__((mode(QI))) a5; 42 IncompleteYType a6 __attribute__((mode(HI))); 43 CompleteYType1 a7; 44 CompleteYType2 a8; 45 CompleteType3 a9; 46 CompleteType4 a10; 47 CompleteType5 a11; 48 enum __attribute__((mode(QI))) { A4, B4 } a12; 49 50 return 0; 51 } 52