John Kessenich | 44e8cae | 2013-10-02 01:30:14 +0000 | [diff] [blame] | 1 | #version 100
|
| 2 |
|
| 3 | int 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 |
|
| 14 | int f(int a, int b, int c); // okay to redeclare
|
| 15 |
|
| 16 | bool b;
|
| 17 | float b(int a); // ERROR: redefinition
|
| 18 |
|
| 19 | float f; // ERROR: redefinition
|
John Kessenich | a4351c5 | 2013-11-11 04:21:31 +0000 | [diff] [blame] | 20 | float tan; // okay, built-in is in an outer scope
|
John Kessenich | e1f0f5b | 2013-12-04 17:23:03 +0000 | [diff] [blame^] | 21 | float sin(float x); // ERROR: can't redefine built-in functions
|
| 22 | float cos(float x) // ERROR: can't redefine built-in functions
|
John Kessenich | 44e8cae | 2013-10-02 01:30:14 +0000 | [diff] [blame] | 23 | {
|
| 24 | return 1.0;
|
| 25 | }
|
John Kessenich | a4351c5 | 2013-11-11 04:21:31 +0000 | [diff] [blame] | 26 | bool radians(bool x) // okay, can overload built-in functions
|
| 27 | {
|
| 28 | return true;
|
| 29 | }
|
John Kessenich | 44e8cae | 2013-10-02 01:30:14 +0000 | [diff] [blame] | 30 |
|
| 31 | invariant gl_Position;
|
| 32 |
|
| 33 | void main()
|
| 34 | {
|
| 35 | int g(); // ERROR: no local function declarations
|
| 36 | g();
|
| 37 |
|
| 38 | float sin; // okay
|
| 39 | sin;
|
| 40 |
|
| 41 | f(1,2,3);
|
| 42 |
|
| 43 | float f; // hides f()
|
| 44 | f = 3.0;
|
| 45 |
|
| 46 | gl_Position = vec4(f);
|
| 47 |
|
| 48 | for (int f = 0; f < 10; ++f)
|
| 49 | ++f;
|
| 50 |
|
| 51 | int x = 1;
|
| 52 | {
|
| 53 | float x = 2.0, /* 2nd x visible here */ y = x; // y is initialized to 2
|
| 54 | int z = z; // ERROR: z not previously defined.
|
| 55 | }
|
| 56 | {
|
John Kessenich | e1f0f5b | 2013-12-04 17:23:03 +0000 | [diff] [blame^] | 57 | int x = x; // x is initialized to '1'
|
John Kessenich | 44e8cae | 2013-10-02 01:30:14 +0000 | [diff] [blame] | 58 | }
|
| 59 |
|
| 60 | struct S
|
| 61 | {
|
| 62 | int x;
|
| 63 | };
|
| 64 | {
|
John Kessenich | e1f0f5b | 2013-12-04 17:23:03 +0000 | [diff] [blame^] | 65 | S S = S(0); // 'S' is only visible as a struct and constructor
|
| 66 | S.x; // 'S' is now visible as a variable
|
John Kessenich | 44e8cae | 2013-10-02 01:30:14 +0000 | [diff] [blame] | 67 | }
|
| 68 | }
|