xref: /llvm-project/flang/test/Transforms/debug-assumed-shape-array-2.fir (revision fc4b1a303b296d02f6243a083510c4ee7f290ab0)
1// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
2
3// Test assumed shape array with variable lower bound.
4
5module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
6  func.func private @_QFPfn(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "b"}, %arg1: !fir.ref<i32> {fir.bindc_name = "n"}) attributes {} {
7    %c23_i32 = arith.constant 23 : i32
8    %c6_i32 = arith.constant 6 : i32
9    %c20_i32 = arith.constant 20 : i32
10    %0 = fir.undefined !fir.dscope
11    %1 = fircg.ext_declare %arg1 dummy_scope %0 {uniq_name = "_QFFfnEn"} : (!fir.ref<i32>, !fir.dscope) -> !fir.ref<i32> loc(#loc1)
12    %2 = fir.load %1 : !fir.ref<i32>
13    %3 = fir.convert %2 : (i32) -> index
14    %4 = fircg.ext_declare %arg0 origin %3 dummy_scope %0 {uniq_name = "_QFFfnEb"} : (!fir.box<!fir.array<?xi32>>, index, !fir.dscope) -> !fir.box<!fir.array<?xi32>> loc(#loc2)
15    return
16  } loc(#loc3)
17}
18#loc1 = loc("test1.f90":1:1)
19#loc2 = loc("test1.f90":3:16)
20#loc3 = loc("test1.f90":4:16)
21
22// CHECK: #[[VAR:.*]] = #llvm.di_local_variable<{{.*}}name = "._QFFfnEb1"{{.*}}flags = Artificial>
23// CHECK: #llvm.di_composite_type<tag = DW_TAG_array_type{{.*}}elements = #llvm.di_subrange<count = #llvm.di_expression<[{{.*}}]>, lowerBound = #[[VAR]], stride = #llvm.di_expression<[{{.*}}]>>, dataLocation = <[DW_OP_push_object_address, DW_OP_deref]>>
24