2007-10-11 08:18:28 +08:00
|
|
|
// RUN: clang -fsyntax-only -verify %s
|
2007-07-28 06:15:19 +08:00
|
|
|
|
2008-04-19 07:10:10 +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;
|
2007-07-28 06:15:19 +08:00
|
|
|
|
|
|
|
static void test() {
|
2007-07-30 11:29:09 +08:00
|
|
|
float2 vec2, vec2_2;
|
2007-07-28 06:15:19 +08:00
|
|
|
float3 vec3;
|
2007-07-30 11:29:09 +08:00
|
|
|
float4 vec4, vec4_2;
|
2007-07-28 06:15:19 +08:00
|
|
|
float f;
|
|
|
|
|
2007-07-30 11:29:09 +08:00
|
|
|
vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
|
|
|
|
vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
|
|
|
|
vec4.rgba; // expected-warning {{expression result unused}}
|
|
|
|
vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
|
2007-07-28 06:15:19 +08:00
|
|
|
vec3 = vec4.rgb; // legal, shorten
|
|
|
|
f = vec2.x; // legal, shorten
|
2007-07-30 11:29:09 +08:00
|
|
|
|
|
|
|
vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
|
|
|
|
vec4_2.rgga = vec4.rgba; // 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;
|
2007-07-28 06:15:19 +08:00
|
|
|
vec4 = (float4){ 1,2,3,4 };
|
2008-05-09 14:41:27 +08:00
|
|
|
vec4.rg.a; // expected-error {{vector component access exceeds type 'float2'}}
|
2007-07-28 06:15:19 +08:00
|
|
|
}
|