2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-01-18 09:47:54 +08:00
|
|
|
|
|
|
|
typedef __attribute__(( ext_vector_type(2) )) float float2;
|
|
|
|
typedef __attribute__(( ext_vector_type(3) )) float float3;
|
|
|
|
typedef __attribute__(( ext_vector_type(4) )) float float4;
|
2009-06-26 05:06:09 +08:00
|
|
|
typedef __attribute__(( ext_vector_type(16) )) float float16;
|
2009-01-18 09:47:54 +08:00
|
|
|
|
2009-06-27 02:22:18 +08:00
|
|
|
static float4 vec4_0 = (float4)0.5f;
|
|
|
|
|
2009-01-18 09:47:54 +08:00
|
|
|
static void test() {
|
|
|
|
float2 vec2, vec2_2;
|
|
|
|
float3 vec3;
|
2009-02-17 05:11:58 +08:00
|
|
|
float4 vec4, vec4_2, *vec4p;
|
2009-06-26 05:06:09 +08:00
|
|
|
float16 vec16;
|
2009-01-18 09:47:54 +08:00
|
|
|
float f;
|
|
|
|
|
|
|
|
vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
|
|
|
|
vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
|
|
|
|
vec4.xyzw; // expected-warning {{expression result unused}}
|
|
|
|
vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
|
|
|
|
vec4.s01z; // expected-error {{illegal vector component name 'z'}}
|
|
|
|
vec2 = vec4.s01; // legal, shorten
|
2009-06-26 05:06:09 +08:00
|
|
|
vec2 = vec4.S01; // legal, shorten
|
2009-01-18 09:47:54 +08:00
|
|
|
|
|
|
|
vec3 = vec4.xyz; // legal, shorten
|
|
|
|
f = vec2.x; // legal, shorten
|
|
|
|
f = vec4.xy.x; // legal, shorten
|
|
|
|
|
|
|
|
vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec2.x = f;
|
|
|
|
vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec2.yx = vec2_2.xy;
|
|
|
|
vec4 = (float4){ 1,2,3,4 };
|
|
|
|
vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
|
|
|
|
vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
|
2009-06-26 05:06:09 +08:00
|
|
|
vec4.x = vec16.sf;
|
|
|
|
vec4.x = vec16.sF;
|
2009-02-17 05:11:58 +08:00
|
|
|
|
|
|
|
vec4p->yz = vec4p->xy;
|
2009-01-18 09:47:54 +08:00
|
|
|
}
|
2009-12-16 02:13:04 +08:00
|
|
|
|
|
|
|
float2 lo(float3 x) { return x.lo; }
|
|
|
|
float2 hi(float3 x) { return x.hi; }
|
|
|
|
float2 ev(float3 x) { return x.even; }
|
|
|
|
float2 od(float3 x) { return x.odd; }
|