gcc/testsuite/gnat.dg/protected_self_ref1.adb
raw| 1 | -- { dg-do run } |
| 2 | with System; |
| 3 | |
| 4 | procedure Protected_Self_Ref1 is |
| 5 | |
| 6 | protected type P is |
| 7 | procedure Foo; |
| 8 | end P; |
| 9 | |
| 10 | protected body P is |
| 11 | procedure Foo is |
| 12 | Ptr : access P; -- here P denotes the type P |
| 13 | T : Integer; |
| 14 | A : System.Address; |
| 15 | begin |
| 16 | Ptr := P'Access; -- here P denotes the "this" instance of P |
| 17 | T := P'Size; |
| 18 | A := P'Address; |
| 19 | end; |
| 20 | end P; |
| 21 | |
| 22 | O : P; |
| 23 | begin |
| 24 | O.Foo; |
| 25 | end Protected_Self_Ref1; |