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