| 1 |
! RUN: bbc %s -o - | tco | FileCheck %s |
| 2 |
! RUN: %flang -emit-llvm -S -mmlir -disable-external-name-interop %s -o - | FileCheck %s |
| 3 |
|
| 4 |
! CHECK: @__BLNK__ = common global [8 x i8] zeroinitializer |
| 5 |
! CHECK: @co1_ = common global [16 x i8] zeroinitializer, align 16 |
| 6 |
! CHECK: @rien_ = common global [1 x i8] zeroinitializer |
| 7 |
! CHECK: @with_empty_equiv_ = common global [8 x i8] zeroinitializer |
| 8 |
! CHECK: @x_ = global { float, float } { float 1.0{{.*}}, float 2.0{{.*}} } |
| 9 |
! CHECK: @y_ = common global [12 x i8] zeroinitializer |
| 10 |
! CHECK: @z_ = global { i32, [4 x i8], float } { i32 42, [4 x i8] zeroinitializer, float 3.000000e+00 } |
| 11 |
|
| 12 |
! CHECK-LABEL: _QPs0 |
| 13 |
subroutine s0 |
| 14 |
common // a0, b0 |
| 15 |
|
| 16 |
! CHECK: call void @_QPs(ptr @__BLNK__, ptr getelementptr (i8, ptr @__BLNK__, i64 4)) |
| 17 |
call s(a0, b0) |
| 18 |
end subroutine s0 |
| 19 |
|
| 20 |
! CHECK-LABEL: _QPs1 |
| 21 |
subroutine s1 |
| 22 |
common /x/ a1, b1 |
| 23 |
data a1 /1.0/, b1 /2.0/ |
| 24 |
|
| 25 |
! CHECK: call void @_QPs(ptr @x_, ptr getelementptr (i8, ptr @x_, i64 4)) |
| 26 |
call s(a1, b1) |
| 27 |
end subroutine s1 |
| 28 |
|
| 29 |
! CHECK-LABEL: _QPs2 |
| 30 |
subroutine s2 |
| 31 |
common /y/ a2, b2, c2 |
| 32 |
|
| 33 |
! CHECK: call void @_QPs(ptr @y_, ptr getelementptr (i8, ptr @y_, i64 4)) |
| 34 |
call s(a2, b2) |
| 35 |
end subroutine s2 |
| 36 |
|
| 37 |
! Test that common initialized through aliases of common members are getting |
| 38 |
! the correct initializer. |
| 39 |
! CHECK-LABEL: _QPs3 |
| 40 |
subroutine s3 |
| 41 |
integer :: i = 42 |
| 42 |
real :: x |
| 43 |
complex :: c |
| 44 |
real :: glue(2) |
| 45 |
real :: y = 3. |
| 46 |
equivalence (i, x), (glue(1), c), (glue(2), y) |
| 47 |
! x and c are not directly initialized, but overlapping aliases are. |
| 48 |
common /z/ x, c |
| 49 |
end subroutine s3 |
| 50 |
|
| 51 |
module mod_with_common |
| 52 |
integer :: i, j |
| 53 |
common /c_in_mod/ i, j |
| 54 |
end module |
| 55 |
! CHECK-LABEL: _QPs4 |
| 56 |
subroutine s4 |
| 57 |
use mod_with_common |
| 58 |
! CHECK: load i32, ptr @c_in_mod_ |
| 59 |
print *, i |
| 60 |
! CHECK: load i32, ptr getelementptr (i8, ptr @c_in_mod_, i64 4) |
| 61 |
print *, j |
| 62 |
end subroutine s4 |
| 63 |
|
| 64 |
! CHECK-LABEL: _QPs5 |
| 65 |
subroutine s5 |
| 66 |
real r(1:0) |
| 67 |
common /rien/ r |
| 68 |
end subroutine s5 |
| 69 |
|
| 70 |
! CHECK-LABEL: _QPs6 |
| 71 |
subroutine s6 |
| 72 |
real r1(1:0), r2(1:0), x, y |
| 73 |
common /with_empty_equiv/ x, r1, y |
| 74 |
equivalence(r1, r2) |
| 75 |
end subroutine s6 |
| 76 |
|
| 77 |
subroutine s7() |
| 78 |
real(16) r16 |
| 79 |
common /co1/ r16 |
| 80 |
end subroutine |
| 81 |
|