blob: b0a72d1f191d80c3f357b4bcce08e8d23fa60e40 [file] [log] [blame]
John Kessenich44e8cae2013-10-02 01:30:14 +00001#version 100
2
3int f(int a, int b, int c)
4{
5 int a = b; // ERROR, redefinition
6
7 {
8 float a = float(a) + 1.0;
9 }
10
11 return a;
12}
13
14int f(int a, int b, int c); // okay to redeclare
15
16bool b;
17float b(int a); // ERROR: redefinition
18
John Kessenich3a4687d2013-12-11 22:38:19 +000019float c(int a);
20bool c; // ERROR: redefinition
21
John Kessenich44e8cae2013-10-02 01:30:14 +000022float f; // ERROR: redefinition
John Kessenicha4351c52013-11-11 04:21:31 +000023float tan; // okay, built-in is in an outer scope
John Kesseniche1f0f5b2013-12-04 17:23:03 +000024float sin(float x); // ERROR: can't redefine built-in functions
25float cos(float x) // ERROR: can't redefine built-in functions
John Kessenich44e8cae2013-10-02 01:30:14 +000026{
27 return 1.0;
28}
John Kessenicha4351c52013-11-11 04:21:31 +000029bool radians(bool x) // okay, can overload built-in functions
30{
31 return true;
32}
John Kessenich44e8cae2013-10-02 01:30:14 +000033
34invariant gl_Position;
35
36void main()
37{
38 int g(); // ERROR: no local function declarations
39 g();
40
41 float sin; // okay
42 sin;
John Kessenich3a4687d2013-12-11 22:38:19 +000043 sin(0.7); // ERROR, use of hidden function
John Kessenich44e8cae2013-10-02 01:30:14 +000044 f(1,2,3);
45
46 float f; // hides f()
47 f = 3.0;
48
49 gl_Position = vec4(f);
50
51 for (int f = 0; f < 10; ++f)
52 ++f;
53
54 int x = 1;
55 {
56 float x = 2.0, /* 2nd x visible here */ y = x; // y is initialized to 2
57 int z = z; // ERROR: z not previously defined.
58 }
59 {
John Kesseniche1f0f5b2013-12-04 17:23:03 +000060 int x = x; // x is initialized to '1'
John Kessenich44e8cae2013-10-02 01:30:14 +000061 }
62
63 struct S
64 {
65 int x;
66 };
67 {
John Kesseniche1f0f5b2013-12-04 17:23:03 +000068 S S = S(0); // 'S' is only visible as a struct and constructor
69 S.x; // 'S' is now visible as a variable
John Kessenich44e8cae2013-10-02 01:30:14 +000070 }
John Kessenich3a4687d2013-12-11 22:38:19 +000071
72 int degrees;
73 degrees(3.2); // ERROR, use of hidden built-in function
John Kessenich44e8cae2013-10-02 01:30:14 +000074}
John Kessenichafda2412013-12-04 20:41:33 +000075
76varying struct SSS { float f; } s; // ERROR