aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/ext_vector_casts.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/ext_vector_casts.c')
-rw-r--r--test/Sema/ext_vector_casts.c76
1 files changed, 62 insertions, 14 deletions
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index 66004b03ff8c..949d67311b36 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions -Wconversion %s
typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(3) )) float float3;
typedef __attribute__(( ext_vector_type(4) )) int int4;
typedef __attribute__(( ext_vector_type(8) )) short short8;
typedef __attribute__(( ext_vector_type(4) )) float float4;
@@ -11,12 +12,16 @@ typedef size_t stride4 __attribute__((ext_vector_type(4)));
static void test() {
float2 vec2;
+ float3 vec3;
float4 vec4, vec4_2;
int4 ivec4;
short8 ish8;
t3 vec4_3;
int *ptr;
int i;
+
+ vec3 += vec2; // expected-error {{can't convert between vector values of different size}}
+ vec4 += vec3; // expected-error {{can't convert between vector values of different size}}
vec4 = 5.0f;
vec4 = (float4)5.0f;
@@ -27,31 +32,30 @@ static void test() {
ivec4 = (int4)5;
ivec4 = (int4)vec4_3;
- i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
- i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
-
- ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
+ i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' (vector of 4 'int' values) and integer type 'int' of different size}}
+ i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4' (vector of 4 'int' values)}}
- vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
+ ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' (vector of 4 'int' values) and scalar type 'int *'}}
- ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
- ish8 += (short)5;
+ vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' (vector of 4 'float' values) and 'float2' (vector of 2 'float' values)}}
+
+ ish8 += 5;
ivec4 *= 5;
vec4 /= 5.2f;
- vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
+ vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' (vector of 4 'float' values) and 'int')}}
ivec4 %= 4;
- ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' and 'float4')}}
+ ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' (vector of 4 'int' values) and 'float4' (vector of 4 'float' values))}}
ivec4 += (int4)vec4;
ivec4 -= ivec4;
ivec4 |= ivec4;
- ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
+ ivec4 += ptr; // expected-error {{can't convert between vector and non-scalar values ('int4' (vector of 4 'int' values) and 'int *')}}
}
-typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
+typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2' (vector of 2 'float' values)}}
void inc(float2 f2) {
- f2++; // expected-error{{cannot increment value of type 'float2'}}
- __real f2; // expected-error{{invalid type 'float2' to __real operator}}
+ f2++; // expected-error{{cannot increment value of type 'float2' (vector of 2 'float' values)}}
+ __real f2; // expected-error{{invalid type 'float2' (vector of 2 'float' values) to __real operator}}
}
typedef enum
@@ -74,3 +78,47 @@ stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride)
return stride;
}
+// rdar://16196902
+typedef __attribute__((ext_vector_type(4))) float float32x4_t;
+
+typedef float C3DVector3 __attribute__((ext_vector_type(3)));
+
+extern float32x4_t vabsq_f32(float32x4_t __a);
+
+C3DVector3 Func(const C3DVector3 a) {
+ return (C3DVector3)vabsq_f32((float32x4_t)a); // expected-error {{invalid conversion between ext-vector type 'float32x4_t' (vector of 4 'float' values) and 'C3DVector3' (vector of 3 'float' values)}}
+}
+
+// rdar://16350802
+typedef double double2 __attribute__ ((ext_vector_type(2)));
+
+static void splats(int i, long l, __uint128_t t, float f, double d) {
+ short8 vs = 0;
+ int4 vi = i;
+ ulong2 vl = (unsigned long)l;
+ float2 vf = f;
+ double2 vd = d;
+
+ vs = 65536 + vs; // expected-warning {{implicit conversion from 'int' to 'short8' (vector of 8 'short' values) changes value from 65536 to 0}}
+ vs = vs + i; // expected-warning {{implicit conversion loses integer precision}}
+ vs = vs + 1;
+ vs = vs + 1.f; // expected-error {{can't convert between vector values of different size}}
+
+ vi = l + vi; // expected-warning {{implicit conversion loses integer precision}}
+ vi = 1 + vi;
+ vi = vi + 2.0; // expected-error {{can't convert between vector values of different size}}
+ vi = vi + 0xffffffff; // expected-warning {{implicit conversion changes signedness}}
+
+ vl = l + vl; // expected-warning {{implicit conversion changes signedness}}
+ vl = vl + t; // expected-warning {{implicit conversion loses integer precision}}
+
+ vf = 1 + vf;
+ vf = l + vf;
+ vf = 2.0 + vf;
+ vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
+ vf = vf + 0xffffffff;
+ vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
+
+ vd = l + vd;
+ vd = vd + t;
+}