53 lines · plain
1! RUN: bbc -emit-hlfir %s -o - | %python %S/gen_mod_ref_test.py | \2! RUN: fir-opt -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis-modref))' \3! RUN: --mlir-disable-threading -o /dev/null 2>&1 | FileCheck %s4 5! Test fir.call modref for local variables.6 7module somemod8 interface9 subroutine may_capture(x)10 real, target :: x11 end subroutine12 subroutine set_pointer(x)13 real, pointer :: x14 end subroutine15 end interface16end module17 18subroutine test_local19 use somemod, only : may_capture20 implicit none21 real :: test_var_x22 ! Capture is invalid after the call because test_var_xsaved does not have the23 ! target attribute.24 call may_capture(test_var_x)25 call test_effect_external()26end subroutine27! CHECK-LABEL: Testing : "_QPtest_local"28! CHECK: test_effect_external -> test_var_x#0: NoModRef29 30subroutine test_local_target31 use somemod, only : may_capture32 implicit none33 real, target :: test_var_x_target34 call may_capture(test_var_x_target)35 call test_effect_external()36end subroutine37! CHECK-LABEL: Testing : "_QPtest_local_target"38! CHECK: test_effect_external -> test_var_x_target#0: ModRef39 40subroutine test_local_pointer41 use somemod, only : set_pointer42 implicit none43 real, pointer :: p44 call set_pointer(p)45 ! Use associated to test the pointer target address, no the46 ! address of the pointer descriptor.47 associate(test_var_p_target => p)48 call test_effect_external()49 end associate50end subroutine51! CHECK-LABEL: Testing : "_QPtest_local_pointer"52! CHECK: test_effect_external -> test_var_p_target#0: ModRef53