yum-mirror/glslang

git clone https://git.yummers.dev/yum-mirror/glslang

Diego NovilloFix erroneous parse errors in variable declarations using existing struct names (#4005)b4e66d7b

main
1.8 KiB77 linesraw
1#version 400
2
3struct Inner {
4    int id;
5    float value;
6};
7
8struct Outer {
9    int before;
10    uint padding;
11    mat2 matrix;
12    int after;
13};
14
15struct Complex {
16    Inner nested;
17    Inner array[2];
18};
19
20struct Point {
21    float x;
22    float y;
23};
24
25struct Color {
26    vec3 rgb;
27    float alpha;
28};
29
30void store_data(Inner data[4]) {
31    // Function that takes array of structs
32}
33
34void store_outer(Outer value) {
35    // Function that takes single struct
36}
37
38void process_point(Point p) {
39    // Function that takes single struct
40}
41
42void main() {
43    // Pattern 1: Complex array constructors (most common tint failure pattern)
44    Outer data[4] = Outer[4](
45        Outer(0, 0u, mat2(vec2(0.0), vec2(0.0)), 0),
46        Outer(1, 1u, mat2(vec2(1.0), vec2(1.0)), 1),
47        Outer(2, 2u, mat2(vec2(2.0), vec2(2.0)), 2),
48        Outer(3, 3u, mat2(vec2(3.0), vec2(3.0)), 3)
49    );
50    
51    // Pattern 2: Nested struct array constructors
52    Inner inner_array[4] = Inner[4](
53        Inner(0, 0.0),
54        Inner(1, 1.0),
55        Inner(2, 2.0),
56        Inner(3, 3.0)
57    );
58    
59    // Pattern 3: Struct with nested struct constructors
60    Complex complex_data = Complex(
61        Inner(42, 3.14),
62        Inner[2](Inner(1, 1.0), Inner(2, 2.0))
63    );
64    
65    // Pattern 4: Function calls with array constructors
66    store_data(Inner[4](Inner(1, 1.0), Inner(2, 2.0), Inner(3, 3.0), Inner(4, 4.0)));
67    store_outer(Outer(10, 10u, mat2(vec2(5.0), vec2(6.0)), 20));
68    
69    // Pattern 5: Basic struct constructors (from deleted basic_struct_constructor.frag)
70    Point p1 = Point(1.0, 2.0);
71    Color c1 = Color(vec3(1.0, 0.0, 0.0), 1.0);
72    Point p2;
73    p2 = Point(3.0, 4.0);
74    
75    // Pattern 6: Struct constructors in function calls (from deleted struct_constructor_in_function_call.frag)
76    process_point(Point(5.0, 6.0));
77}