aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/dec_union_4.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/dec_union_4.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/dec_union_4.f9062
1 files changed, 62 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/dec_union_4.f90 b/gcc/testsuite/gfortran.dg/dec_union_4.f90
new file mode 100644
index 00000000000..3bf6d618a8e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_union_4.f90
@@ -0,0 +1,62 @@
+! { dg-do run }
+! { dg-options "-fdec-structure" }
+!
+! Test nested UNIONs.
+!
+
+subroutine aborts (s)
+ character(*), intent(in) :: s
+ print *, s
+ call abort()
+end subroutine
+
+! Nested unions
+structure /s4/
+ union ! U0 ! rax
+ map
+ integer(8) rx
+ end map
+ map
+ integer(4) rh ! rah
+ union ! U1
+ map
+ integer(4) rl ! ral
+ end map
+ map
+ integer(4) ex ! eax
+ end map
+ map
+ integer(2) eh ! eah
+ union ! U2
+ map
+ integer(2) el ! eal
+ end map
+ map
+ integer(2) x ! ax
+ end map
+ map
+ integer(1) h ! ah
+ integer(1) l ! al
+ end map
+ end union
+ end map
+ end union
+ end map
+ end union
+end structure
+record /s4/ r4
+
+
+! Nested unions
+r4.rx = z'7A7B7CCC7FFFFFFF'
+if ( r4.rx .ne. z'7A7B7CCC7FFFFFFF' ) call aborts ("rax")
+if ( r4.rh .ne. z'7FFFFFFF' ) call aborts ("rah")
+if ( r4.rl .ne. z'7A7B7CCC' ) call aborts ("ral")
+if ( r4.ex .ne. z'7A7B7CCC' ) call aborts ("eax")
+if ( r4.eh .ne. z'7CCC' ) call aborts ("eah")
+if ( r4.el .ne. z'7A7B' ) call aborts ("eal")
+if ( r4.x .ne. z'7A7B' ) call aborts ("ax")
+if ( r4.h .ne. z'7B' ) call aborts ("ah")
+if ( r4.l .ne. z'7A' ) call aborts ("al")
+
+end