1! { dg-do run } 2! { dg-options "-fdec-structure -finit-derived -finit-local-zero" } 3! 4! Test a UNION with explicit initialization and -finit-derived. 5! 6 7subroutine sub 8 structure /s2/ 9 integer(4) :: i = 8 10 union ! U7 11 map 12 integer(4) :: x = 1600 13 integer(4) :: y = 1800 14 end map 15 map 16 integer(2) a, b, c, d, e, f, g, h 17 end map 18 end union 19 end structure 20 record /s2/ r2 21 22 ! Initialized unions 23 if ( r2.i .ne. 8 ) then 24 print *, 'structure init' 25 STOP 1 26 endif 27 28 ! Explicit initializations 29 if ( r2.x .ne. 1600 .or. r2.y .ne. 1800) then 30 r2.x = r2.y 31 print *, 'union explicit init' 32 STOP 2 33 endif 34 35 ! Initialization from -finit-derived 36 if ( r2.h .ne. 0 ) then 37 r2.h = 135 38 print *, 'union default init' 39 STOP 3 40 endif 41 42end subroutine 43 44! Initialization expressions 45structure /s3/ 46 integer(4) :: i = 8 47 union ! U7 48 map 49 integer(4) :: x = 1600 50 integer(4) :: y = 1800 51 end map 52 map 53 integer(2) a, b, c, d, e 54 end map 55 end union 56end structure 57 58record /s3/ r3 59 60! Initialized unions 61if ( r3.i .ne. 8 ) then 62 print *, 'structure init' 63 STOP 4 64endif 65 66! Explicit initializations 67if ( r3.x .ne. 1600 .or. r3.y .ne. 1800) then 68 r3.x = r3.y 69 print *, 'union explicit init' 70 STOP 5 71endif 72 73! Initialization from -finit-derived 74if ( r3.e .ne. 0 ) then 75 r3.e = 135 76 print *, 'union default init' 77 STOP 6 78endif 79 80end 81