annotate clang/test/Sema/attr-mode.c @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \
anatofuz
parents:
diff changeset
2 // RUN: -verify %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
anatofuz
parents:
diff changeset
4 // RUN: -verify %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
anatofuz
parents:
diff changeset
6 // RUN: -verify %s
anatofuz
parents:
diff changeset
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
anatofuz
parents:
diff changeset
8 // RUN: -verify %s
anatofuz
parents:
diff changeset
9 // RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
anatofuz
parents:
diff changeset
10 // RUN: -verify %s
anatofuz
parents:
diff changeset
11 // RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -DTEST_MIPS_N32 -fsyntax-only \
anatofuz
parents:
diff changeset
12 // RUN: -verify %s
anatofuz
parents:
diff changeset
13 // RUN: %clang_cc1 -triple mips64-linux-gnu -DTEST_MIPS_64 -fsyntax-only \
anatofuz
parents:
diff changeset
14 // RUN: -verify %s
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 typedef int i16_1 __attribute((mode(HI)));
anatofuz
parents:
diff changeset
17 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
anatofuz
parents:
diff changeset
18 typedef int i16_2 __attribute((__mode__(__HI__)));
anatofuz
parents:
diff changeset
19 int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 typedef float f64 __attribute((mode(DF)));
anatofuz
parents:
diff changeset
22 int f64_test[sizeof(f64) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 typedef int invalid_1 __attribute((mode)); // expected-error{{'mode' attribute takes one argument}}
anatofuz
parents:
diff changeset
25 typedef int invalid_2 __attribute((mode())); // expected-error{{'mode' attribute takes one argument}}
anatofuz
parents:
diff changeset
26 typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
anatofuz
parents:
diff changeset
27 typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
anatofuz
parents:
diff changeset
28 typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
anatofuz
parents:
diff changeset
29 typedef int invalid_6 __attribute__((mode(12))); // expected-error{{'mode' attribute requires an identifier}}
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 typedef unsigned unwind_word __attribute((mode(unwind_word)));
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 __attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables, enums, typedefs, and non-static data members}}
anatofuz
parents:
diff changeset
36 enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to}}
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 typedef _Complex double c32 __attribute((mode(SC)));
anatofuz
parents:
diff changeset
39 int c32_test[sizeof(c32) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
40 typedef _Complex float c64 __attribute((mode(DC)));
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 #if !defined(__ppc__) && !defined(__mips__) // Note, 'XC' mode is illegal for PPC64 and MIPS machines.
anatofuz
parents:
diff changeset
43 typedef _Complex float c80 __attribute((mode(XC)));
anatofuz
parents:
diff changeset
44 #endif
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 // PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
anatofuz
parents:
diff changeset
47 // modes. Also test other mode-based conversions.
anatofuz
parents:
diff changeset
48 typedef int i8_mode_t __attribute__ ((__mode__ (__QI__)));
anatofuz
parents:
diff changeset
49 typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__)));
anatofuz
parents:
diff changeset
50 typedef int i16_mode_t __attribute__ ((__mode__ (__HI__)));
anatofuz
parents:
diff changeset
51 typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__)));
anatofuz
parents:
diff changeset
52 typedef int i32_mode_t __attribute__ ((__mode__ (__SI__)));
anatofuz
parents:
diff changeset
53 typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__)));
anatofuz
parents:
diff changeset
54 typedef int i64_mode_t __attribute__ ((__mode__ (__DI__)));
anatofuz
parents:
diff changeset
55 typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__)));
anatofuz
parents:
diff changeset
56 void f_i8_arg(i8_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
57 void f_ui8_arg(ui8_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
58 void f_i16_arg(i16_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
59 void f_ui16_arg(ui16_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
60 void f_i32_arg(i32_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
61 void f_ui32_arg(ui32_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
62 void f_i64_arg(i64_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
63 void f_ui64_arg(ui64_mode_t* x) { (void)x; }
anatofuz
parents:
diff changeset
64 void test_char_to_i8(signed char* y) { f_i8_arg(y); }
anatofuz
parents:
diff changeset
65 void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); }
anatofuz
parents:
diff changeset
66 void test_short_to_i16(short* y) { f_i16_arg(y); }
anatofuz
parents:
diff changeset
67 void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); }
anatofuz
parents:
diff changeset
68 void test_int_to_i32(int* y) { f_i32_arg(y); }
anatofuz
parents:
diff changeset
69 void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); }
anatofuz
parents:
diff changeset
70 #if TEST_32BIT_X86
anatofuz
parents:
diff changeset
71 void test_long_to_i64(long long* y) { f_i64_arg(y); }
anatofuz
parents:
diff changeset
72 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
anatofuz
parents:
diff changeset
73 #elif TEST_64BIT_X86
anatofuz
parents:
diff changeset
74 #ifdef __ILP32__
anatofuz
parents:
diff changeset
75 typedef unsigned int gcc_word __attribute__((mode(word)));
anatofuz
parents:
diff changeset
76 int foo[sizeof(gcc_word) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
77 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
anatofuz
parents:
diff changeset
78 int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
79 void test_long_to_i64(long long* y) { f_i64_arg(y); }
anatofuz
parents:
diff changeset
80 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
anatofuz
parents:
diff changeset
81 #else
anatofuz
parents:
diff changeset
82 void test_long_to_i64(long* y) { f_i64_arg(y); }
anatofuz
parents:
diff changeset
83 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
anatofuz
parents:
diff changeset
84 #endif
anatofuz
parents:
diff changeset
85 typedef float f128ibm __attribute__ ((mode (TF)));
anatofuz
parents:
diff changeset
86 #elif TEST_64BIT_PPC64
anatofuz
parents:
diff changeset
87 typedef float f128ibm __attribute__ ((mode (TF)));
anatofuz
parents:
diff changeset
88 typedef _Complex float c128ibm __attribute__ ((mode (TC)));
anatofuz
parents:
diff changeset
89 void f_ft128_arg(long double *x);
anatofuz
parents:
diff changeset
90 void f_ft128_complex_arg(_Complex long double *x);
anatofuz
parents:
diff changeset
91 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
anatofuz
parents:
diff changeset
92 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
anatofuz
parents:
diff changeset
93 #elif TEST_MIPS_32
anatofuz
parents:
diff changeset
94 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
anatofuz
parents:
diff changeset
95 int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
anatofuz
parents:
diff changeset
96 #elif TEST_MIPS_N32
anatofuz
parents:
diff changeset
97 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
anatofuz
parents:
diff changeset
98 int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
99 #elif TEST_MIPS_64
anatofuz
parents:
diff changeset
100 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
anatofuz
parents:
diff changeset
101 int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
anatofuz
parents:
diff changeset
102 #else
anatofuz
parents:
diff changeset
103 #error Unknown test architecture.
anatofuz
parents:
diff changeset
104 #endif
anatofuz
parents:
diff changeset
105
anatofuz
parents:
diff changeset
106 struct S {
anatofuz
parents:
diff changeset
107 int n __attribute((mode(HI)));
anatofuz
parents:
diff changeset
108 };