attr-mode.c revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3typedef int i16_1 __attribute((mode(HI)));
4int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
5typedef int i16_2 __attribute((__mode__(__HI__)));
6int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
7
8typedef float f64 __attribute((mode(DF)));
9int f64_test[sizeof(f64) == 8 ? 1 : -1];
10
11typedef int invalid_1 __attribute((mode)); // expected-error{{attribute requires unquoted parameter}}
12typedef int invalid_2 __attribute((mode())); // expected-error{{attribute requires unquoted parameter}}
13typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
14typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
15typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
16
17int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
18
19typedef _Complex double c32 __attribute((mode(SC)));
20int c32_test[sizeof(c32) == 8 ? 1 : -1];
21typedef _Complex float c64 __attribute((mode(DC)));
22typedef _Complex float c80 __attribute((mode(XC)));
23