1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 typedef __attribute__(( ext_vector_type(2) )) float float2;
4 typedef __attribute__(( ext_vector_type(3) )) float float3;
5 typedef __attribute__(( ext_vector_type(4) )) float float4;
6 typedef __attribute__(( ext_vector_type(16) )) float float16;
7
8 static float4 vec4_0 = (float4)0.5f;
9
test()10 static void test() {
11 float2 vec2, vec2_2;
12 float3 vec3;
13 float4 vec4, vec4_2, *vec4p;
14 float16 vec16;
15 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'}}
19 vec4.xyzw; // expected-warning {{expression result unused}}
20 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
23 vec2 = vec4.S01; // legal, shorten
24
25 vec3 = vec4.xyz; // legal, shorten
26 f = vec2.x; // legal, shorten
27 f = vec4.xy.x; // legal, shorten
28
29 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'}}
38 vec4.x = vec16.sf;
39 vec4.x = vec16.sF;
40
41 vec4p->yz = vec4p->xy;
42
43 vec2.a; // expected-error {{vector component access exceeds type 'float2'}}
44 vec2.rgba; // expected-error {{vector component access exceeds type 'float2'}}
45 vec4.rgba; // expected-warning {{expression result unused}}
46 vec4.rgbz; // expected-error {{illegal vector component name 'z'}}
47 vec4.rgbc; // expected-error {{illegal vector component name 'c'}}
48 vec4.xyzr; // expected-error {{illegal vector component name 'r'}}
49 vec4.s01b; // expected-error {{vector component access exceeds type 'float4'}}
50
51 vec3 = vec4.rgb; // legal, shorten
52 f = vec2.r; // legal, shorten
53 f = vec4.rg.r; // legal, shorten
54 vec4_2.rgba = vec4.xyzw; // legal, no intermingling
55
56 vec4_2.rgbr = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
57 vec4_2.rgbb = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
58 vec4_2.rgga = vec4.rgba; // expected-error {{vector is not assignable (contains duplicate components)}}
59 vec2.x = f;
60 vec2.rr = vec2_2.rg; // expected-error {{vector is not assignable (contains duplicate components)}}
61 vec2.gr = vec2_2.rg;
62 vec2.gr.g = vec2_2.r;
63 vec4 = (float4){ 1,2,3,4 };
64 vec4.rg.b; // expected-error {{vector component access exceeds type 'float2'}}
65 vec4.r = vec16.sf;
66 vec4.g = vec16.sF;
67
68 vec4p->gb = vec4p->rg;
69 }
70
lo(float3 x)71 float2 lo(float3 x) { return x.lo; }
hi(float3 x)72 float2 hi(float3 x) { return x.hi; }
ev(float3 x)73 float2 ev(float3 x) { return x.even; }
od(float3 x)74 float2 od(float3 x) { return x.odd; }
75