xref: /llvm-project/flang/test/Lower/attributes.f90 (revision 0b54e33fd5ab362dfa5eacb61d7cbdb9cc3a89ac)
1! RUN: bbc -emit-fir %s -o - | FileCheck %s
2
3! Test propagation of Fortran attributes to FIR.
4
5
6! CHECK-LABEL: func @_QPfoo1(
7! CHECK-SAME: %arg0: !fir.ref<f32> {fir.bindc_name = "x", fir.optional},
8! CHECK-SAME: %arg1: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "y", fir.optional},
9! CHECK-SAME: %arg2: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "i", fir.optional},
10! CHECK-SAME: %arg3: !fir.boxchar<1> {fir.bindc_name = "c", fir.optional}
11subroutine foo1(x, y, i, c)
12  real, optional :: x, y(:)
13  integer, allocatable, optional :: i(:)
14  character, optional :: c
15end subroutine
16
17! CHECK-LABEL: func @_QPfoo2(
18! CHECK-SAME: %arg0: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x", fir.contiguous},
19! CHECK-SAME: %arg1: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {fir.bindc_name = "i", fir.contiguous}
20subroutine foo2(x, i)
21  real, contiguous :: x(:)
22  integer, pointer, contiguous :: i(:)
23end subroutine
24
25! CHECK-LABEL: func @_QPfoo3
26! CHECK-SAME: %arg0: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x", fir.contiguous, fir.optional}
27subroutine foo3(x)
28  real, optional, contiguous :: x(:)
29end subroutine
30
31! CHECK-LABEL: func @_QPfoo4
32! CHECK-SAME: %arg0: !fir.ref<f32> {fir.bindc_name = "x", fir.target}
33! CHECK-SAME: %arg1: !fir.ref<f32> {fir.asynchronous, fir.bindc_name = "y"}
34subroutine foo4(x, y)
35  real, target :: x
36  real, asynchronous :: y
37end subroutine
38