blob: 7d3d52aa954683a3d8f71067f581e3362545976d [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Nate Begeman353417a2009-01-18 01:47:54 +00002
3typedef __attribute__(( ext_vector_type(2) )) float float2;
4typedef __attribute__(( ext_vector_type(3) )) float float3;
5typedef __attribute__(( ext_vector_type(4) )) float float4;
Nate Begeman131f4652009-06-25 21:06:09 +00006typedef __attribute__(( ext_vector_type(16) )) float float16;
Nate Begeman353417a2009-01-18 01:47:54 +00007
Nate Begemane8c9e922009-06-26 18:22:18 +00008static float4 vec4_0 = (float4)0.5f;
9
Nate Begeman353417a2009-01-18 01:47:54 +000010static void test() {
11 float2 vec2, vec2_2;
12 float3 vec3;
Chris Lattner73525de2009-02-16 21:11:58 +000013 float4 vec4, vec4_2, *vec4p;
Nate Begeman131f4652009-06-25 21:06:09 +000014 float16 vec16;
Nate Begeman353417a2009-01-18 01:47:54 +000015 float f;
16
17 vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
18 vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000019 vec4.xyzw; // expected-warning {{expression result unused}}
Nate Begeman353417a2009-01-18 01:47:54 +000020 vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
21 vec4.s01z; // expected-error {{illegal vector component name 'z'}}
22 vec2 = vec4.s01; // legal, shorten
Nate Begeman131f4652009-06-25 21:06:09 +000023 vec2 = vec4.S01; // legal, shorten
Nate Begeman353417a2009-01-18 01:47:54 +000024
25 vec3 = vec4.xyz; // legal, shorten
26 f = vec2.x; // legal, shorten
27 f = vec4.xy.x; // legal, shorten
28
Nate Begeman353417a2009-01-18 01:47:54 +000029 vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
30 vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
31 vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
32 vec2.x = f;
33 vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
34 vec2.yx = vec2_2.xy;
35 vec4 = (float4){ 1,2,3,4 };
36 vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
37 vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
Nate Begeman131f4652009-06-25 21:06:09 +000038 vec4.x = vec16.sf;
39 vec4.x = vec16.sF;
Chris Lattner73525de2009-02-16 21:11:58 +000040
41 vec4p->yz = vec4p->xy;
Nate Begeman353417a2009-01-18 01:47:54 +000042}
Nate Begeman0479a0b2009-12-15 18:13:04 +000043
44float2 lo(float3 x) { return x.lo; }
45float2 hi(float3 x) { return x.hi; }
46float2 ev(float3 x) { return x.even; }
47float2 od(float3 x) { return x.odd; }