xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/attr-mode.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \
2*f4a2713aSLionel Sambuc // RUN:   -verify %s
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
4*f4a2713aSLionel Sambuc // RUN:   -verify %s
5*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
6*f4a2713aSLionel Sambuc // RUN:   -verify %s
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc typedef int i16_1 __attribute((mode(HI)));
9*f4a2713aSLionel Sambuc int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
10*f4a2713aSLionel Sambuc typedef int i16_2 __attribute((__mode__(__HI__)));
11*f4a2713aSLionel Sambuc int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc typedef float f64 __attribute((mode(DF)));
14*f4a2713aSLionel Sambuc int f64_test[sizeof(f64) == 8 ? 1 : -1];
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc typedef int invalid_1 __attribute((mode)); // expected-error{{'mode' attribute takes one argument}}
17*f4a2713aSLionel Sambuc typedef int invalid_2 __attribute((mode())); // expected-error{{'mode' attribute takes one argument}}
18*f4a2713aSLionel Sambuc typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
19*f4a2713aSLionel Sambuc typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
20*f4a2713aSLionel Sambuc typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
21*f4a2713aSLionel Sambuc typedef int invalid_6 __attribute__((mode(12)));  // expected-error{{'mode' attribute requires an identifier}}
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc typedef unsigned unwind_word __attribute((mode(unwind_word)));
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc typedef _Complex double c32 __attribute((mode(SC)));
28*f4a2713aSLionel Sambuc int c32_test[sizeof(c32) == 8 ? 1 : -1];
29*f4a2713aSLionel Sambuc typedef _Complex float c64 __attribute((mode(DC)));
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc #ifndef TEST_64BIT_PPC64 // Note, 'XC' mode is illegal for PPC64 machines.
32*f4a2713aSLionel Sambuc typedef _Complex float c80 __attribute((mode(XC)));
33*f4a2713aSLionel Sambuc #endif
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
36*f4a2713aSLionel Sambuc // modes. Also test other mode-based conversions.
37*f4a2713aSLionel Sambuc typedef int i8_mode_t __attribute__ ((__mode__ (__QI__)));
38*f4a2713aSLionel Sambuc typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__)));
39*f4a2713aSLionel Sambuc typedef int i16_mode_t __attribute__ ((__mode__ (__HI__)));
40*f4a2713aSLionel Sambuc typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__)));
41*f4a2713aSLionel Sambuc typedef int i32_mode_t __attribute__ ((__mode__ (__SI__)));
42*f4a2713aSLionel Sambuc typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__)));
43*f4a2713aSLionel Sambuc typedef int i64_mode_t __attribute__ ((__mode__ (__DI__)));
44*f4a2713aSLionel Sambuc typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__)));
f_i8_arg(i8_mode_t * x)45*f4a2713aSLionel Sambuc void f_i8_arg(i8_mode_t* x) { (void)x; }
f_ui8_arg(ui8_mode_t * x)46*f4a2713aSLionel Sambuc void f_ui8_arg(ui8_mode_t* x) { (void)x; }
f_i16_arg(i16_mode_t * x)47*f4a2713aSLionel Sambuc void f_i16_arg(i16_mode_t* x) { (void)x; }
f_ui16_arg(ui16_mode_t * x)48*f4a2713aSLionel Sambuc void f_ui16_arg(ui16_mode_t* x) { (void)x; }
f_i32_arg(i32_mode_t * x)49*f4a2713aSLionel Sambuc void f_i32_arg(i32_mode_t* x) { (void)x; }
f_ui32_arg(ui32_mode_t * x)50*f4a2713aSLionel Sambuc void f_ui32_arg(ui32_mode_t* x) { (void)x; }
f_i64_arg(i64_mode_t * x)51*f4a2713aSLionel Sambuc void f_i64_arg(i64_mode_t* x) { (void)x; }
f_ui64_arg(ui64_mode_t * x)52*f4a2713aSLionel Sambuc void f_ui64_arg(ui64_mode_t* x) { (void)x; }
test_char_to_i8(signed char * y)53*f4a2713aSLionel Sambuc void test_char_to_i8(signed char* y) { f_i8_arg(y); }
test_char_to_ui8(unsigned char * y)54*f4a2713aSLionel Sambuc void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); }
test_short_to_i16(short * y)55*f4a2713aSLionel Sambuc void test_short_to_i16(short* y) { f_i16_arg(y); }
test_short_to_ui16(unsigned short * y)56*f4a2713aSLionel Sambuc void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); }
test_int_to_i32(int * y)57*f4a2713aSLionel Sambuc void test_int_to_i32(int* y) { f_i32_arg(y); }
test_int_to_ui32(unsigned int * y)58*f4a2713aSLionel Sambuc void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); }
59*f4a2713aSLionel Sambuc #if TEST_32BIT_X86
test_long_to_i64(long long * y)60*f4a2713aSLionel Sambuc void test_long_to_i64(long long* y) { f_i64_arg(y); }
test_long_to_ui64(unsigned long long * y)61*f4a2713aSLionel Sambuc void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
62*f4a2713aSLionel Sambuc #elif TEST_64BIT_X86
test_long_to_i64(long * y)63*f4a2713aSLionel Sambuc void test_long_to_i64(long* y) { f_i64_arg(y); }
test_long_to_ui64(unsigned long * y)64*f4a2713aSLionel Sambuc void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
65*f4a2713aSLionel Sambuc typedef          float f128ibm __attribute__ ((mode (TF)));     // expected-error{{unsupported machine mode 'TF'}}
66*f4a2713aSLionel Sambuc #elif TEST_64BIT_PPC64
67*f4a2713aSLionel Sambuc typedef          float f128ibm __attribute__ ((mode (TF)));
68*f4a2713aSLionel Sambuc typedef _Complex float c128ibm __attribute__ ((mode (TC)));
69*f4a2713aSLionel Sambuc void f_ft128_arg(long double *x);
70*f4a2713aSLionel Sambuc void f_ft128_complex_arg(_Complex long double *x);
test_TFtype(f128ibm * a)71*f4a2713aSLionel Sambuc void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
test_TCtype(c128ibm * a)72*f4a2713aSLionel Sambuc void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
73*f4a2713aSLionel Sambuc #else
74*f4a2713aSLionel Sambuc #error Unknown test architecture.
75*f4a2713aSLionel Sambuc #endif
76