File: common_16.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (34 lines) | stat: -rw-r--r-- 921 bytes parent folder | download
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
! Test: COMMON block alignment edge case
! Tests storage association with types that might need alignment padding
! if the struct were not packed. COMMON blocks should be storage-associated
! (consecutive in memory) regardless of natural alignment requirements.
program common_16
    implicit none
    integer(1) :: i1
    real(8) :: r8
    integer(4) :: i4
    common /align/ i1, r8, i4

    i1 = 42
    r8 = 3.14159d0
    i4 = 999

    call sub_verify()
    if (i1 /= 100) error stop "i1 should be 100 after subroutine"
    print *, "PASS: common_16"
end program

subroutine sub_verify()
    implicit none
    ! Same layout - verify values persist
    integer(1) :: a
    real(8) :: b
    integer(4) :: c
    common /align/ a, b, c

    if (a /= 42) error stop "a should be 42"
    if (abs(b - 3.14159d0) > 1.0d-10) error stop "b should be pi"
    if (c /= 999) error stop "c should be 999"

    a = 100
end subroutine