| 1 |
*> { dg-do run } |
| 2 |
*> { dg-output-file "group2/ALLOCATE___FREE_basic_default_versions.out" } |
| 3 |
|
| 4 |
program-id. prog. |
| 5 |
data division. |
| 6 |
working-storage section. |
| 7 |
01 based-var pic x(100) based. |
| 8 |
01 mem-pointer pointer. |
| 9 |
01 mem-size pic 999 value 100. |
| 10 |
01 counter pic 99 value zero. |
| 11 |
procedure division. |
| 12 |
allocate 100 characters returning mem-pointer. |
| 13 |
if mem-pointer equal NULL |
| 14 |
display "allocate 100 should not be NULL (1)" |
| 15 |
else |
| 16 |
add 1 to counter. |
| 17 |
free mem-pointer |
| 18 |
if mem-pointer not equal NULL |
| 19 |
display "mem-pointer should be NULL again (1)" |
| 20 |
else |
| 21 |
add 1 to counter. |
| 22 |
|
| 23 |
allocate mem-size characters returning mem-pointer. |
| 24 |
if mem-pointer equal null |
| 25 |
display "allocate mem-size should not be NULL (2)" |
| 26 |
else |
| 27 |
add 1 to counter. |
| 28 |
free mem-pointer |
| 29 |
if mem-pointer not equal null |
| 30 |
display "mem-pointer should be NULL again (2)" |
| 31 |
else |
| 32 |
add 1 to counter. |
| 33 |
|
| 34 |
allocate based-var |
| 35 |
if address of based-var equal NULL |
| 36 |
display "address of based-var should not be NULL (1)" |
| 37 |
else |
| 38 |
add 1 to counter |
| 39 |
free based-var |
| 40 |
if address of based-var not equal NULL |
| 41 |
display "address of based-var be NULL (1)" |
| 42 |
else |
| 43 |
add 1 to counter. |
| 44 |
|
| 45 |
allocate based-var |
| 46 |
if address of based-var equal NULL |
| 47 |
display "address of based-var should not be NULL (2)" |
| 48 |
else |
| 49 |
add 1 to counter. |
| 50 |
free address of based-var |
| 51 |
if address of based-var not equal NULL |
| 52 |
display "address of based-var be NULL (2)" |
| 53 |
else |
| 54 |
add 1 to counter. |
| 55 |
|
| 56 |
allocate based-var returning mem-pointer. |
| 57 |
if address of based-var equal NULL |
| 58 |
display "address of based-var should not be NULL (3)" |
| 59 |
else |
| 60 |
add 1 to counter. |
| 61 |
if mem-pointer equal NULL |
| 62 |
display "address of mem-pointer should not be NULL (3)" |
| 63 |
else |
| 64 |
add 1 to counter. |
| 65 |
if address of based-var not equal mem-pointer |
| 66 |
display "address of mem-pointer should be equal to mem-pointer (3)" |
| 67 |
else |
| 68 |
add 1 to counter. |
| 69 |
|
| 70 |
display "There were " counter " successful tests; should be 11." |
| 71 |
goback. |
| 72 |
end program prog. |
| 73 |
|