SPV: Fix #1575, fix #1593: Support HLSL #line
[platform/upstream/glslang.git] / Test / switch.frag
1 #version 300 es
2 precision highp float;
3 uniform int c, d;
4 in highp float x;
5
6 void main()
7 {
8     float f;
9     int a[2];
10
11     switch(f) {      // ERROR
12     }
13
14     switch(a) {      // ERROR
15     }
16
17     switch(c)
18     {
19     }
20
21     switch(c)        // WARNING, not enough stuff after last label
22     {
23     case 2:
24     }
25
26     switch(c)
27     {
28         f = sin(x);   // ERRROR
29     case 2:
30         f = cos(x);
31         break;
32     }
33
34     switch (c) {
35     default:
36         break;
37     case 1:
38         f = sin(x);
39         break;
40     case 2:
41         f = cos(x);
42         break;
43     default:           // ERROR, 2nd default
44         f = tan(x);
45     }
46
47     switch (c) {
48     case 1:
49         f = sin(x);
50         break;
51     case 2:
52         switch (d) {
53         case 1:
54             f = x * x * x;
55             break;
56         case 2:
57             f = x * x;
58             break;
59         }
60         break;
61     default:
62         f = tan(x);
63     case 1:           // ERROR, 2nd 'case 1'
64         break;
65     case 3.8:         // ERROR, non-int
66         break;
67     case c:           // ERROR, non-constant
68         break;       
69     }
70
71     switch (c) {      // a no-error normal switch
72     case 1:
73         f = sin(x);
74         break;
75     case 2:
76         switch (d) {
77         case 1:
78             f = x * x * x;
79             break;
80         case 2:
81             f = x * x;
82             break;
83         }
84         break;
85     default:
86         f = tan(x);
87     }
88
89     break;            // ERROR
90
91     switch (c) {
92     case 1:
93         f = sin(x);
94         break;
95     case 2:
96         switch (d) {
97         case 1:
98             {
99                 case 4:        // ERROR
100                     break;
101             }
102             f = x * x * x;
103             if (c < d) {
104                 case 2:         // ERROR
105                     f = x * x;
106             }
107             if (d < c)
108                 case 3:         // ERROR
109             break;
110         }
111         break;
112     case 4:
113         f = tan(x);
114         if (f < 0.0)
115             default:            // ERROR
116                 break;
117     }
118
119     case 5:  // ERROR
120     default: // ERROR
121
122     switch (0) {
123         default:
124         int onlyInSwitch = 0;
125     }
126     onlyInSwitch;   // ERROR
127    
128     switch (0) {
129         default:
130             int x;  // WARNING (was "no statement" ERROR, but spec. changed because unclear what a statement is)
131     }
132
133     switch (c) {
134     case 1:
135     {
136         int nestedX;
137         break;
138     }
139     case 2:
140         nestedX;    // ERROR
141         int nestedZ;
142         float a;    // okay, hiding outer 'a'
143         break;
144     case 3:
145         int linearZ;
146         break;
147         break;
148     case 4:
149         int linearY = linearZ;
150         break;
151     case 5:         // okay that branch bypassed an initializer
152         const int linearC = 4;
153         break;
154     case 6:         // okay that branch bypassed an initializer
155         linearC;
156     }
157     nestedZ;        // ERROR, no longer in scope
158 }