Merge pull request #2865 from alan-baker/update-license
[platform/upstream/glslang.git] / Test / 110scope.vert
1 #version 110\r
2 \r
3 int f(int a, int b, int c)\r
4 {\r
5         int a = b;  // ERROR, redefinition\r
6 \r
7     {\r
8                 float a = float(a) + 1.0; // okay\r
9     }\r
10 \r
11         return a;\r
12 }\r
13 \r
14 int f(int a, int b, int c);  // okay to redeclare\r
15 \r
16 bool b;\r
17 float b(int a);      // okay, b and b() are different\r
18 \r
19 float c(int a);\r
20 bool c;              // okay, and c() are different\r
21 \r
22 float f;             // okay f and f() are different\r
23 float tan;           // okay, hides built-in function\r
24 float sin(float x);  // okay, can redefine built-in functions\r
25 float cos(float x)   // okay, can redefine built-in functions\r
26 {\r
27         return 1.0;\r
28 }\r
29 bool radians(bool x) // okay, can overload built-in functions\r
30 {\r
31     return true;\r
32 }\r
33 \r
34 int gi = f(1,2,3);  // ERROR, can't call user-defined function from global scope\r
35 \r
36 void main()\r
37 {\r
38     int g();    // okay\r
39     g();\r
40 \r
41     float sin; // okay\r
42     sin;\r
43     sin(0.7);  // okay\r
44     f(1,2,3);\r
45 \r
46     float f;\r
47     f = 3.0;\r
48 \r
49     gl_Position = vec4(f);\r
50 \r
51     for (int f = 0; f < 10; ++f)\r
52         ++f;\r
53 \r
54     int x = 1;\r
55     { \r
56         float x = 2.0, /* 2nd x visible here */ y = x; // y is initialized to 2\r
57         int z = z; // ERROR: z not previously defined.\r
58     }\r
59     {\r
60         int x = x; // x is initialized to '1'\r
61     }\r
62 \r
63     struct S \r
64     { \r
65         int x; \r
66     };\r
67     {\r
68         S S = S(0); // 'S' is only visible as a struct and constructor \r
69         S.x;        // 'S' is now visible as a variable\r
70     }\r
71 \r
72     int degrees;\r
73     degrees(3.2);\r
74 \r
75     {\r
76         S s;\r
77         s.x = 3;\r
78         struct S {   // okay, hides S\r
79             bool b;\r
80         };\r
81         S t;\r
82         t.b = true;\r
83         struct S {    // ERROR, redefinition of struct S\r
84             float f;\r
85         };\r
86     }\r
87 }\r