83 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 global variables (module, saved, common).6 7 8module somemod9 implicit none10 real :: test_var_xmod11 interface12 subroutine may_capture(x)13 real, target :: x14 end subroutine15 end interface16end module17 18subroutine test_module19 use somemod, only : test_var_xmod20 implicit none21 call test_effect_external()22end subroutine23! CHECK-LABEL: Testing : "_QPtest_module"24! CHECK: test_effect_external -> test_var_xmod#0: ModRef25 26subroutine test_saved_local27 use somemod, only : may_capture28 implicit none29 real, save :: test_var_xsaved30 ! Capture is invalid after the call because test_var_xsaved does not have the31 ! target attribute.32 call may_capture(test_var_xsaved)33 call test_effect_external()34end subroutine35! CHECK-LABEL: Testing : "_QPtest_saved_local"36! CHECK: test_effect_external -> test_var_xsaved#0: NoModRef37 38subroutine test_saved_target39 use somemod, only : may_capture40 implicit none41 real, save, target :: test_var_target_xsaved42 call may_capture(test_var_target_xsaved)43 call test_effect_external()44end subroutine45! CHECK-LABEL: Testing : "_QPtest_saved_target"46! CHECK: test_effect_external -> test_var_target_xsaved#0: ModRef47 48subroutine test_saved_target_249 use somemod, only : may_capture50 implicit none51 real, save, target :: test_var_target_xsaved52 ! Pointer associations made to SAVE variables remain valid after the53 ! procedure exit, so it cannot be ruled out that the variable has been54 ! captured in a previous call to `test_var_target_xsaved` even though the55 ! call to `test_effect_external` appears first here.56 call test_effect_external()57 call may_capture(test_var_target_xsaved)58end subroutine59! CHECK-LABEL: Testing : "_QPtest_saved_target_2"60! CHECK: test_effect_external -> test_var_target_xsaved#0: ModRef61 62subroutine test_saved_used_in_internal63 implicit none64 real, save :: test_var_saved_captured65 call may_capture_procedure_pointer(internal)66 call test_effect_external()67contains68 subroutine internal69 test_var_saved_captured = 0.70 end subroutine71end subroutine72! CHECK-LABEL: Testing : "_QPtest_saved_used_in_internal"73! CHECK: test_effect_external -> test_var_saved_captured#0: ModRef74 75subroutine test_common76 implicit none77 real :: test_var_x_common78 common /comm/ test_var_x_common79 call test_effect_external()80end subroutine81! CHECK-LABEL: Testing : "_QPtest_common"82! CHECK: test_effect_external -> test_var_x_common#0: ModRef83