blob: a89c8397e0a04d173d8272d9888e34135beed19a [file] [log] [blame]
Chandler Carruthaec7caa2010-01-26 06:39:24 +00001// RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \
2// RUN: -verify %s
3// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
4// RUN: -verify %s
Eli Friedman3c0eb162008-05-27 03:33:27 +00005
6typedef int i16_1 __attribute((mode(HI)));
7int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
8typedef int i16_2 __attribute((__mode__(__HI__)));
9int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
10
11typedef float f64 __attribute((mode(DF)));
12int f64_test[sizeof(f64) == 8 ? 1 : -1];
13
14typedef int invalid_1 __attribute((mode)); // expected-error{{attribute requires unquoted parameter}}
15typedef int invalid_2 __attribute((mode())); // expected-error{{attribute requires unquoted parameter}}
16typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
17typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
18typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
Chris Lattnere5c5ee12008-06-29 00:16:31 +000019
Rafael Espindola8e721b72013-01-07 19:58:54 +000020typedef unsigned unwind_word __attribute((mode(unwind_word)));
21
Chris Lattnere5c5ee12008-06-29 00:16:31 +000022int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
Eli Friedman73397492009-03-03 06:41:03 +000023
24typedef _Complex double c32 __attribute((mode(SC)));
25int c32_test[sizeof(c32) == 8 ? 1 : -1];
26typedef _Complex float c64 __attribute((mode(DC)));
27typedef _Complex float c80 __attribute((mode(XC)));
Chandler Carruthaec7caa2010-01-26 06:39:24 +000028
29// PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
30// modes. Also test other mode-based conversions.
31typedef int i8_mode_t __attribute__ ((__mode__ (__QI__)));
32typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__)));
33typedef int i16_mode_t __attribute__ ((__mode__ (__HI__)));
34typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__)));
35typedef int i32_mode_t __attribute__ ((__mode__ (__SI__)));
36typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__)));
37typedef int i64_mode_t __attribute__ ((__mode__ (__DI__)));
38typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__)));
39void f_i8_arg(i8_mode_t* x) { (void)x; }
40void f_ui8_arg(ui8_mode_t* x) { (void)x; }
41void f_i16_arg(i16_mode_t* x) { (void)x; }
42void f_ui16_arg(ui16_mode_t* x) { (void)x; }
43void f_i32_arg(i32_mode_t* x) { (void)x; }
44void f_ui32_arg(ui32_mode_t* x) { (void)x; }
45void f_i64_arg(i64_mode_t* x) { (void)x; }
46void f_ui64_arg(ui64_mode_t* x) { (void)x; }
47void test_char_to_i8(signed char* y) { f_i8_arg(y); }
48void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); }
49void test_short_to_i16(short* y) { f_i16_arg(y); }
50void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); }
51void test_int_to_i32(int* y) { f_i32_arg(y); }
52void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); }
53#if TEST_32BIT_X86
54void test_long_to_i64(long long* y) { f_i64_arg(y); }
55void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
56#elif TEST_64BIT_X86
57void test_long_to_i64(long* y) { f_i64_arg(y); }
58void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
59#else
60#error Unknown test architecture.
61#endif