xref: /llvm-project/flang/test/Lower/common-block.f90 (revision 3b19e480c056a35a60e3c65de476b6097329ceac)
1*3b19e480STom Eccles! REQUIRES: flang-supports-f128-math
25d25267dSValentin Clement! RUN: bbc %s -o - | tco | FileCheck %s
3cc3c6b61SAndrzej Warzynski! RUN: %flang -emit-llvm -S -mmlir -disable-external-name-interop %s -o - | FileCheck %s
45d25267dSValentin Clement
56ffea74fSjeanPerier! CHECK: @__BLNK__ = common global [8 x i8] zeroinitializer
6c1654c38SValentin Clement (バレンタイン クレメン)! CHECK: @co1_ = common global [16 x i8] zeroinitializer, align 16
76ffea74fSjeanPerier! CHECK: @rien_ = common global [1 x i8] zeroinitializer
86ffea74fSjeanPerier! CHECK: @with_empty_equiv_ = common global [8 x i8] zeroinitializer
96ffea74fSjeanPerier! CHECK: @x_ = global { float, float } { float 1.0{{.*}}, float 2.0{{.*}} }
106ffea74fSjeanPerier! CHECK: @y_ = common global [12 x i8] zeroinitializer
1187e25210SjeanPerier! CHECK: @z_ = global { i32, [4 x i8], float } { i32 42, [4 x i8] zeroinitializer, float 3.000000e+00 }
125d25267dSValentin Clement
135d25267dSValentin Clement! CHECK-LABEL: _QPs0
145d25267dSValentin Clementsubroutine s0
155d25267dSValentin Clement  common // a0, b0
165d25267dSValentin Clement
176ffea74fSjeanPerier  ! CHECK: call void @_QPs(ptr @__BLNK__, ptr getelementptr (i8, ptr @__BLNK__, i64 4))
185d25267dSValentin Clement  call s(a0, b0)
195d25267dSValentin Clementend subroutine s0
205d25267dSValentin Clement
215d25267dSValentin Clement! CHECK-LABEL: _QPs1
225d25267dSValentin Clementsubroutine s1
235d25267dSValentin Clement  common /x/ a1, b1
245d25267dSValentin Clement  data a1 /1.0/, b1 /2.0/
255d25267dSValentin Clement
266ffea74fSjeanPerier  ! CHECK: call void @_QPs(ptr @x_, ptr getelementptr (i8, ptr @x_, i64 4))
275d25267dSValentin Clement  call s(a1, b1)
285d25267dSValentin Clementend subroutine s1
295d25267dSValentin Clement
305d25267dSValentin Clement! CHECK-LABEL: _QPs2
315d25267dSValentin Clementsubroutine s2
325d25267dSValentin Clement  common /y/ a2, b2, c2
335d25267dSValentin Clement
346ffea74fSjeanPerier  ! CHECK: call void @_QPs(ptr @y_, ptr getelementptr (i8, ptr @y_, i64 4))
355d25267dSValentin Clement  call s(a2, b2)
365d25267dSValentin Clementend subroutine s2
375d25267dSValentin Clement
385d25267dSValentin Clement! Test that common initialized through aliases of common members are getting
395d25267dSValentin Clement! the correct initializer.
405d25267dSValentin Clement! CHECK-LABEL: _QPs3
415d25267dSValentin Clementsubroutine s3
425d25267dSValentin Clement integer :: i = 42
435d25267dSValentin Clement real :: x
445d25267dSValentin Clement complex :: c
455d25267dSValentin Clement real :: glue(2)
465d25267dSValentin Clement real :: y = 3.
475d25267dSValentin Clement equivalence (i, x), (glue(1), c), (glue(2), y)
485d25267dSValentin Clement ! x and c are not directly initialized, but overlapping aliases are.
495d25267dSValentin Clement common /z/ x, c
505d25267dSValentin Clementend subroutine s3
515d25267dSValentin Clement
525d25267dSValentin Clementmodule mod_with_common
535d25267dSValentin Clement  integer :: i, j
545d25267dSValentin Clement  common /c_in_mod/ i, j
555d25267dSValentin Clementend module
565d25267dSValentin Clement! CHECK-LABEL: _QPs4
575d25267dSValentin Clementsubroutine s4
585d25267dSValentin Clement  use mod_with_common
596ffea74fSjeanPerier  ! CHECK: load i32, ptr @c_in_mod_
605d25267dSValentin Clement  print *, i
616ffea74fSjeanPerier  ! CHECK: load i32, ptr getelementptr (i8, ptr @c_in_mod_, i64 4)
625d25267dSValentin Clement  print *, j
635d25267dSValentin Clementend subroutine s4
645d25267dSValentin Clement
655d25267dSValentin Clement! CHECK-LABEL: _QPs5
665d25267dSValentin Clementsubroutine s5
675d25267dSValentin Clement  real r(1:0)
685d25267dSValentin Clement  common /rien/ r
695d25267dSValentin Clementend subroutine s5
705d25267dSValentin Clement
715d25267dSValentin Clement! CHECK-LABEL: _QPs6
725d25267dSValentin Clementsubroutine s6
735d25267dSValentin Clement  real r1(1:0), r2(1:0), x, y
745d25267dSValentin Clement  common /with_empty_equiv/ x, r1, y
755d25267dSValentin Clement  equivalence(r1, r2)
765d25267dSValentin Clementend subroutine s6
77c1654c38SValentin Clement (バレンタイン クレメン)
78c1654c38SValentin Clement (バレンタイン クレメン)subroutine s7()
79c1654c38SValentin Clement (バレンタイン クレメン)  real(16) r16
80c1654c38SValentin Clement (バレンタイン クレメン)  common /co1/ r16
81c1654c38SValentin Clement (バレンタイン クレメン)end subroutine
82