blob: 54d092308909a7e52d5b39b34e82fbf1860712cb [file] [log] [blame]
John Kessenich65c78a02015-08-10 17:08:55 -06001#version 430
2
3float[4][5][6] many[1][2][3];
4
5float gu[][7];
6float gimp[][]; // ERROR, implicit inner
7float g4[4][7];
8float g5[5][7];
9
10float[4][7] foo(float a[5][7])
11{
12 float r[7];
13 r = a[2];
14 float[](a[0], a[1], r, a[3]); // ERROR, too few dims
15 float[4][7][4](a[0], a[1], r, a[3]); // ERROR, too many dims
16 return float[4][7](a[0], a[1], r, a[3]);
17 return float[][](a[0], a[1], r, a[3]);
18 return float[][7](a[0], a[1], a[2], a[3]);
19}
20
21void bar(float[5][7]) {}
22
23void main()
24{
25 {
26 float gu[3][4][2];
27
28 gu[2][4][1] = 4.0; // ERROR, overflow
29 }
30 vec4 ca4[3][2] = vec4[][](vec4[2](vec4(0.0), vec4(1.0)),
31 vec4[2](vec4(0.0), vec4(1.0)),
32 vec4[2](vec4(0.0), vec4(1.0)));
33 vec4 caim[][2] = vec4[][](vec4[2](vec4(4.0), vec4(2.0)),
34 vec4[2](vec4(4.0), vec4(2.0)),
35 vec4[2](vec4(4.0), vec4(2.0)));
36 vec4 caim2[][] = vec4[][](vec4[2](vec4(4.0), vec4(2.0)),
37 vec4[2](vec4(4.0), vec4(2.0)),
38 vec4[2](vec4(4.0), vec4(2.0)));
39 vec4 caim3[3][] = vec4[][](vec4[2](vec4(4.0), vec4(2.0)),
40 vec4[2](vec4(4.0), vec4(2.0)),
41 vec4[2](vec4(4.0), vec4(2.0)));
42
43 vec4 a4[3][2] = {vec4[](vec4(0.0), vec4(1.0)),
44 vec4[2](vec4(0.0), vec4(1.0)),
45 vec4[2](vec4(0.0), vec4(1.0)) };
46 vec4 aim[][2] = {vec4[2](vec4(4.0), vec4(2.0)),
47 vec4[](vec4(4.0), vec4(2.0)),
48 vec4[2](vec4(4.0), vec4(2.0)) };
49 vec4 aim2[][] = {vec4[2](vec4(4.0), vec4(2.0)),
50 vec4[2](vec4(4.0), vec4(2.0)),
51 vec4[](vec4(4.0), vec4(2.0)) };
52 vec4 aim3[3][] = {vec4[2](vec4(4.0), vec4(2.0)),
53 vec4[2](vec4(4.0), vec4(2.0)),
54 vec4[2](vec4(4.0), vec4(2.0)) };
55
56 vec4 bad2[3][] = {vec4[2](vec4(4.0), vec4(2.0)), // ERROR
57 vec4[3](vec4(4.0), vec4(2.0), vec4(5.0)),
58 vec4[2](vec4(4.0), vec4(2.0)) };
59
60 vec4 bad3[3][] = {vec4[3](vec4(4.0), vec4(2.0), vec4(5.0)), // ERROR
61 vec4[2](vec4(4.0), vec4(2.0)),
62 vec4[2](vec4(4.0), vec4(2.0)) };
63
64 vec4 bad4[4][] = {vec4[2](vec4(4.0), vec4(2.0)), // ERROR
65 vec4[2](vec4(4.0), vec4(2.0)),
66 vec4[2](vec4(4.0), vec4(2.0)) };
67
68
69 g4 = foo(g5);
70 g5 = g4; // ERROR, wrong types
71 gu = g4; // ERROR, not yet sized
72
73 foo(gu); // ERROR, not yet sized
74 bar(g5);
75
76 if (foo(g5) == g4)
77 ;
78 if (foo(g5) == g5) // ERROR, different types
79 ;
80
81 float u[][7];
82 u[2][2] = 3.0;
83 float u[5][7];
84 u[5][2] = 5.0; // ERROR
85 foo(u);
86}
87
88void foo3()
89{
90 float resize1[][5][7];
91 resize1.length(); // ERROR
92 resize1[1][4][5] = 2.0;
93 resize1.length(); // ERROR
94 float resize1[3][5][7];
95 resize1.length(); // 3 in AST
96 resize1[1].length(); // 5 in AST
97 resize1[1][1].length(); // 7 in AST
98 resize1[1][1][1].length(); // ERROR
99
100 float resize2[][5][7];
101 float resize2[3][4][7]; // ERROR, inner dim change
102
103 float resize3[][5][7];
104 float resize3[3][5][9]; // ERROR, inner dim changed
105
106 float resize4[][5][7];
107 int resize4[3][5][7]; // ERROR, element type
108}