diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Sema/attr-mode.c | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Sema/attr-mode.c')
-rw-r--r-- | clang/test/Sema/attr-mode.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/clang/test/Sema/attr-mode.c b/clang/test/Sema/attr-mode.c new file mode 100644 index 0000000..0c53362 --- /dev/null +++ b/clang/test/Sema/attr-mode.c @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \ +// RUN: -verify %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \ +// RUN: -verify %s + +typedef int i16_1 __attribute((mode(HI))); +int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1]; +typedef int i16_2 __attribute((__mode__(__HI__))); +int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1]; + +typedef float f64 __attribute((mode(DF))); +int f64_test[sizeof(f64) == 8 ? 1 : -1]; + +typedef int invalid_1 __attribute((mode)); // expected-error{{attribute requires unquoted parameter}} +typedef int invalid_2 __attribute((mode())); // expected-error{{attribute requires unquoted parameter}} +typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}} +typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}} +typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}} + +int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}} + +typedef _Complex double c32 __attribute((mode(SC))); +int c32_test[sizeof(c32) == 8 ? 1 : -1]; +typedef _Complex float c64 __attribute((mode(DC))); +typedef _Complex float c80 __attribute((mode(XC))); + +// PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit +// modes. Also test other mode-based conversions. +typedef int i8_mode_t __attribute__ ((__mode__ (__QI__))); +typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__))); +typedef int i16_mode_t __attribute__ ((__mode__ (__HI__))); +typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__))); +typedef int i32_mode_t __attribute__ ((__mode__ (__SI__))); +typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__))); +typedef int i64_mode_t __attribute__ ((__mode__ (__DI__))); +typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__))); +void f_i8_arg(i8_mode_t* x) { (void)x; } +void f_ui8_arg(ui8_mode_t* x) { (void)x; } +void f_i16_arg(i16_mode_t* x) { (void)x; } +void f_ui16_arg(ui16_mode_t* x) { (void)x; } +void f_i32_arg(i32_mode_t* x) { (void)x; } +void f_ui32_arg(ui32_mode_t* x) { (void)x; } +void f_i64_arg(i64_mode_t* x) { (void)x; } +void f_ui64_arg(ui64_mode_t* x) { (void)x; } +void test_char_to_i8(signed char* y) { f_i8_arg(y); } +void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); } +void test_short_to_i16(short* y) { f_i16_arg(y); } +void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); } +void test_int_to_i32(int* y) { f_i32_arg(y); } +void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); } +#if TEST_32BIT_X86 +void test_long_to_i64(long long* y) { f_i64_arg(y); } +void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); } +#elif TEST_64BIT_X86 +void test_long_to_i64(long* y) { f_i64_arg(y); } +void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); } +#else +#error Unknown test architecture. +#endif |