| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-fdec-structure" } |
| 3 |
! |
| 4 |
! PR fortran/82511 |
| 5 |
! |
| 6 |
! Verify that structure variables with UNION components |
| 7 |
! are accepted in an I/O-list READ. |
| 8 |
! |
| 9 |
implicit none |
| 10 |
|
| 11 |
structure /s/ |
| 12 |
union |
| 13 |
map |
| 14 |
character(16) :: c16_1 |
| 15 |
end map |
| 16 |
map |
| 17 |
character(16) :: c16_2 |
| 18 |
end map |
| 19 |
end union |
| 20 |
end structure |
| 21 |
|
| 22 |
record /s/ r |
| 23 |
character(32) :: instr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^" |
| 24 |
|
| 25 |
r.c16_1 = ' ' |
| 26 |
r.c16_2 = ' ' |
| 27 |
! The record r shall be treated as if its components are listed: |
| 28 |
! read(...) r.c16_1, r.c16_2 |
| 29 |
! This shall correspond to the formatted read of A16,A16 |
| 30 |
read(instr, '(A16,A16)') r |
| 31 |
|
| 32 |
! r.c16_1 and r.c16_2 are in a union, thus share the same memory |
| 33 |
! and the first 16 bytes of instr are overwritten |
| 34 |
if ( r.c16_1 .ne. instr(17:32) .or. r.c16_2 .ne. instr(17:32) ) then |
| 35 |
STOP 1 |
| 36 |
endif |
| 37 |
|
| 38 |
end |