diff --git a/flang/test/Lower/global-format-strings.f90 b/flang/test/Lower/global-format-strings.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/global-format-strings.f90 @@ -0,0 +1,14 @@ +! RUN: bbc -emit-fir -o - %s | FileCheck %s + +! Test checks whether the text of the format statement is hashconed into a +! global similar to a CHARACTER literal and then referenced. + +program other + write(10, 1008) + ! CHECK: fir.address_of(@{{.*}}) : +1008 format('ok') +end +! CHECK-LABEL: fir.global linkonce @_QQcl.28276F6B2729 constant +! CHECK: %[[lit:.*]] = fir.string_lit "('ok')"(6) : !fir.char<1,6> +! CHECK: fir.has_value %[[lit]] : !fir.char<1,6> +! CHECK: } diff --git a/flang/test/Lower/global-initialization.f90 b/flang/test/Lower/global-initialization.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/global-initialization.f90 @@ -0,0 +1,43 @@ +! RUN: bbc %s -o - | FileCheck %s + +program bar +! CHECK: fir.address_of(@[[name1:.*]]my_data) + integer, save :: my_data = 1 + print *, my_data +contains + +! CHECK-LABEL: func @_QFPfoo +subroutine foo() +! CHECK: fir.address_of(@[[name2:.*foo.*my_data]]) + integer, save :: my_data = 2 + print *, my_data + 1 +end subroutine + +! CHECK-LABEL: func @_QFPfoo2 +subroutine foo2() +! CHECK: fir.address_of(@[[name3:.*foo2.*my_data]]) + integer, save :: my_data + my_data = 4 + print *, my_data +end subroutine + +! CHECK-LABEL: func @_QFPfoo3 +subroutine foo3() +! CHECK-DAG: fir.address_of(@[[name4:.*foo3.*idata]]){{.*}}fir.array<5xi32> +! CHECK-DAG: fir.address_of(@[[name5:.*foo3.*rdata]]){{.*}}fir.array<3xf16> +! CHECK-DAG: fir.address_of(@[[name6:.*foo3.*my_data]]){{.*}}fir.array<2x4xi64> + integer*4, dimension(5), save :: idata = (/ (i*i, i=1,5) /) + integer*8, dimension(2, 10:13), save :: my_data = reshape((/1,2,3,4,5,6,7,8/), shape(my_data)) + real*2, dimension(7:9), save :: rdata = (/100., 99., 98./) + print *, rdata(9) + print *, idata(3) + print *, my_data(1,11) +end subroutine +end program + +! CHECK: fir.global internal @[[name1]] +! CHECK: fir.global internal @[[name2]] +! CHECK: fir.global internal @[[name3]] +! CHECK-DAG: fir.global internal @[[name4]]{{.*}}fir.array<5xi32> +! CHECK-DAG: fir.global internal @[[name5]]{{.*}}fir.array<3xf16> +! CHECK-DAG: fir.global internal @[[name6]]{{.*}}fir.array<2x4xi64>