aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/dec_union_3.f90
blob: ce5ae79785942fa1e949fca18471de91b377c0ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
! { dg-do run }
! { dg-options "-fdec-structure" }
!
! Test UNIONs with initializations.
!

subroutine aborts (s)
  character(*), intent(in) :: s
  print *, s
  call abort()
end subroutine

! Initialization expressions
structure /s3/
  integer(4) :: i = 8
  union ! U7
    map
      integer(4) :: x = 1600
      integer(4) :: y = 1800
    end map
    map
      integer(2) a, b, c
    end map
  end union
end structure

record /s3/ r3

! Initialized unions
if ( r3.x .ne. 1600 .or. r3.y .ne. 1800) then
  r3.x = r3.y ! If r3 isn't used the initializations are optimized out
  call aborts ("union initialization")
endif

end