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