2013-10-10 10:12:25 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions %s
|
2009-06-26 08:50:28 +08:00
|
|
|
|
|
|
|
typedef __attribute__(( ext_vector_type(2) )) float float2;
|
2014-01-04 11:31:22 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(3) )) float float3;
|
2009-06-26 08:50:28 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(4) )) int int4;
|
2009-06-28 10:36:38 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(8) )) short short8;
|
2009-06-26 08:50:28 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(4) )) float float4;
|
|
|
|
typedef float t3 __attribute__ ((vector_size (16)));
|
2013-10-10 08:54:01 +08:00
|
|
|
typedef __typeof__(sizeof(int)) size_t;
|
|
|
|
typedef unsigned long ulong2 __attribute__ ((ext_vector_type(2)));
|
|
|
|
typedef size_t stride4 __attribute__((ext_vector_type(4)));
|
2009-06-26 08:50:28 +08:00
|
|
|
|
|
|
|
static void test() {
|
|
|
|
float2 vec2;
|
2014-01-04 11:31:22 +08:00
|
|
|
float3 vec3;
|
2009-06-26 08:50:28 +08:00
|
|
|
float4 vec4, vec4_2;
|
|
|
|
int4 ivec4;
|
2009-06-28 10:36:38 +08:00
|
|
|
short8 ish8;
|
2009-06-26 08:50:28 +08:00
|
|
|
t3 vec4_3;
|
2009-06-28 10:36:38 +08:00
|
|
|
int *ptr;
|
|
|
|
int i;
|
2014-01-04 11:31:22 +08:00
|
|
|
|
|
|
|
vec3 += vec2; // expected-error {{can't convert between vector values of different size}}
|
2014-01-04 14:27:45 +08:00
|
|
|
vec4 += vec3; // expected-error {{can't convert between vector values of different size}}
|
2009-06-26 08:50:28 +08:00
|
|
|
|
2009-06-28 10:36:38 +08:00
|
|
|
vec4 = 5.0f;
|
2009-06-26 08:50:28 +08:00
|
|
|
vec4 = (float4)5.0f;
|
|
|
|
vec4 = (float4)5;
|
|
|
|
vec4 = (float4)vec4_3;
|
|
|
|
|
|
|
|
ivec4 = (int4)5.0f;
|
|
|
|
ivec4 = (int4)5;
|
|
|
|
ivec4 = (int4)vec4_3;
|
|
|
|
|
2009-06-28 10:36:38 +08:00
|
|
|
i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
|
2010-04-09 08:35:39 +08:00
|
|
|
i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
|
2009-06-28 10:36:38 +08:00
|
|
|
|
|
|
|
ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
|
|
|
|
|
2009-06-26 08:50:28 +08:00
|
|
|
vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
|
2009-06-28 10:36:38 +08:00
|
|
|
|
|
|
|
ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
|
|
|
|
ish8 += (short)5;
|
|
|
|
ivec4 *= 5;
|
|
|
|
vec4 /= 5.2f;
|
|
|
|
vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
|
|
|
|
ivec4 %= 4;
|
2011-06-24 02:10:35 +08:00
|
|
|
ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' and 'float4')}}
|
2009-06-28 10:36:38 +08:00
|
|
|
ivec4 += (int4)vec4;
|
|
|
|
ivec4 -= ivec4;
|
|
|
|
ivec4 |= ivec4;
|
2014-02-05 07:58:19 +08:00
|
|
|
ivec4 += ptr; // expected-error {{can't convert between vector and non-scalar values ('int4' and 'int *')}}
|
2009-06-26 08:50:28 +08:00
|
|
|
}
|
2010-06-23 07:07:26 +08:00
|
|
|
|
2010-07-01 01:30:41 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
|
2010-06-23 07:13:52 +08:00
|
|
|
|
|
|
|
void inc(float2 f2) {
|
|
|
|
f2++; // expected-error{{cannot increment value of type 'float2'}}
|
2010-06-23 07:41:02 +08:00
|
|
|
__real f2; // expected-error{{invalid type 'float2' to __real operator}}
|
2010-06-23 07:13:52 +08:00
|
|
|
}
|
2013-10-10 08:54:01 +08:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
uchar_stride = 1,
|
|
|
|
uchar4_stride = 4,
|
|
|
|
ushort4_stride = 8,
|
|
|
|
short4_stride = 8,
|
|
|
|
uint4_stride = 16,
|
|
|
|
int4_stride = 16,
|
|
|
|
float4_stride = 16,
|
|
|
|
} PixelByteStride;
|
|
|
|
|
|
|
|
stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride);
|
|
|
|
stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride)
|
|
|
|
{
|
|
|
|
stride4 stride;
|
|
|
|
// This previously caused an assertion failure.
|
|
|
|
stride.lo = ((ulong2) x) * pixelByteStride; // no-warning
|
|
|
|
return stride;
|
|
|
|
}
|
|
|
|
|
2014-03-07 06:47:09 +08:00
|
|
|
// 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' and 'C3DVector3'}}
|
|
|
|
}
|