1 // RUN: %clang_cc1 -std=c99 %s -pedantic -verify -triple=x86_64-apple-darwin9 2 3 typedef float float4 __attribute__((ext_vector_type(4))); 4 typedef int int3 __attribute__((ext_vector_type(3))); 5 typedef unsigned unsigned4 __attribute__((ext_vector_type(4))); 6 7 struct Foo { 8 char *p; 9 }; 10 11 __attribute__((address_space(1))) int int_as_one; 12 typedef int bar; 13 bar b; 14 15 void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 16 struct Foo s = __builtin_elementwise_abs(i); 17 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 18 19 i = __builtin_elementwise_abs(); 20 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 21 22 i = __builtin_elementwise_abs(i, i); 23 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 24 25 i = __builtin_elementwise_abs(v); 26 // expected-error@-1 {{assigning to 'int' from incompatible type 'float4' (vector of 4 'float' values)}} 27 28 u = __builtin_elementwise_abs(u); 29 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned int')}} 30 31 uv = __builtin_elementwise_abs(uv); 32 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 33 } 34 35 void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, int *p) { 36 i = __builtin_elementwise_max(p, d); 37 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 38 39 struct Foo foo = __builtin_elementwise_max(i, i); 40 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 41 42 i = __builtin_elementwise_max(i); 43 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 44 45 i = __builtin_elementwise_max(); 46 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 47 48 i = __builtin_elementwise_max(i, i, i); 49 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 50 51 i = __builtin_elementwise_max(v, iv); 52 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 53 54 s = __builtin_elementwise_max(i, s); 55 56 enum e { one, 57 two }; 58 i = __builtin_elementwise_max(one, two); 59 60 enum f { three }; 61 enum f x = __builtin_elementwise_max(one, three); 62 63 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 64 ext = __builtin_elementwise_max(ext, ext); 65 66 const int ci; 67 i = __builtin_elementwise_max(ci, i); 68 i = __builtin_elementwise_max(i, ci); 69 i = __builtin_elementwise_max(ci, ci); 70 71 i = __builtin_elementwise_max(i, int_as_one); // ok (attributes don't match)? 72 i = __builtin_elementwise_max(i, b); // ok (sugar doesn't match)? 73 74 int A[10]; 75 A = __builtin_elementwise_max(A, A); 76 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 77 78 int(ii); 79 int j; 80 j = __builtin_elementwise_max(i, j); 81 82 _Complex float c1, c2; 83 c1 = __builtin_elementwise_max(c1, c2); 84 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 85 } 86 87 void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, int *p) { 88 i = __builtin_elementwise_min(p, d); 89 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 90 91 struct Foo foo = __builtin_elementwise_min(i, i); 92 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 93 94 i = __builtin_elementwise_min(i); 95 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 96 97 i = __builtin_elementwise_min(); 98 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 99 100 i = __builtin_elementwise_min(i, i, i); 101 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 102 103 i = __builtin_elementwise_min(v, iv); 104 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 105 106 s = __builtin_elementwise_min(i, s); 107 108 enum e { one, 109 two }; 110 i = __builtin_elementwise_min(one, two); 111 112 enum f { three }; 113 enum f x = __builtin_elementwise_min(one, three); 114 115 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 116 ext = __builtin_elementwise_min(ext, ext); 117 118 const int ci; 119 i = __builtin_elementwise_min(ci, i); 120 i = __builtin_elementwise_min(i, ci); 121 i = __builtin_elementwise_min(ci, ci); 122 123 i = __builtin_elementwise_min(i, int_as_one); // ok (attributes don't match)? 124 i = __builtin_elementwise_min(i, b); // ok (sugar doesn't match)? 125 126 int A[10]; 127 A = __builtin_elementwise_min(A, A); 128 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 129 130 int(ii); 131 int j; 132 j = __builtin_elementwise_min(i, j); 133 134 _Complex float c1, c2; 135 c1 = __builtin_elementwise_min(c1, c2); 136 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 137 } 138 139 void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 140 141 struct Foo s = __builtin_elementwise_ceil(f); 142 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 143 144 i = __builtin_elementwise_ceil(); 145 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 146 147 i = __builtin_elementwise_ceil(i); 148 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 149 150 i = __builtin_elementwise_ceil(f, f); 151 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 152 153 u = __builtin_elementwise_ceil(u); 154 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 155 156 uv = __builtin_elementwise_ceil(uv); 157 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 158 } 159 160 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 161 162 struct Foo s = __builtin_elementwise_floor(f); 163 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 164 165 i = __builtin_elementwise_floor(); 166 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 167 168 i = __builtin_elementwise_floor(i); 169 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 170 171 i = __builtin_elementwise_floor(f, f); 172 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 173 174 u = __builtin_elementwise_floor(u); 175 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 176 177 uv = __builtin_elementwise_floor(uv); 178 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 179 } 180 181 void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 182 183 struct Foo s = __builtin_elementwise_roundeven(f); 184 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 185 186 i = __builtin_elementwise_roundeven(); 187 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 188 189 i = __builtin_elementwise_roundeven(i); 190 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 191 192 i = __builtin_elementwise_roundeven(f, f); 193 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 194 195 u = __builtin_elementwise_roundeven(u); 196 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 197 198 uv = __builtin_elementwise_roundeven(uv); 199 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 200 } 201 202 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 203 204 struct Foo s = __builtin_elementwise_trunc(f); 205 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 206 207 i = __builtin_elementwise_trunc(); 208 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 209 210 i = __builtin_elementwise_trunc(i); 211 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 212 213 i = __builtin_elementwise_trunc(f, f); 214 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 215 216 u = __builtin_elementwise_trunc(u); 217 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 218 219 uv = __builtin_elementwise_trunc(uv); 220 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 221 } 222