xref: /llvm-project/flang/test/Semantics/call30.f90 (revision caa0a2695e6caa4da088f6f933ac45839d425656)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror -pedantic
2! This test is responsible for checking the fix for passing non-variables as
3! actual arguments to subroutines/functions whose corresponding dummy argument
4! expects a VOLATILE variable
5! c.f. llvm-project GitHub issue #58973
6
7module m
8  contains
9  subroutine vol_dum_int(my_int)
10    integer, volatile :: my_int
11  end subroutine vol_dum_int
12
13  subroutine vol_dum_real(my_real)
14    real, volatile :: my_real
15  end subroutine vol_dum_real
16
17  subroutine vol_dum_complex(my_complex)
18    complex, volatile :: my_complex
19  end subroutine vol_dum_complex
20
21  subroutine vol_dum_int_arr(my_int_arr)
22    integer, dimension(2,2), volatile :: my_int_arr
23  end subroutine vol_dum_int_arr
24
25  subroutine test_all_subprograms()
26    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
27    !BECAUSE: '6_4' is not a variable or pointer
28    call vol_dum_int(6)
29    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
30    !BECAUSE: '18_4' is not a variable or pointer
31    call vol_dum_int(6+12)
32    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
33    !BECAUSE: '72_4' is not a variable or pointer
34    call vol_dum_int(6*12)
35    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
36    !BECAUSE: '-3_4' is not a variable or pointer
37    call vol_dum_int(-6/2)
38    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
39    !BECAUSE: '3.1415927410125732421875_4' is not a variable or pointer
40    call vol_dum_real(3.141592653)
41    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
42    !BECAUSE: '3.1415927410125732421875_4' is not a variable or pointer
43    call vol_dum_real(3.141592653 + (-10.6e-11))
44    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
45    !BECAUSE: '3.3300884272335906644002534449100494384765625e-10_4' is not a variable or pointer
46    call vol_dum_real(3.141592653 * 10.6e-11)
47    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
48    !BECAUSE: '-2.9637666816e10_4' is not a variable or pointer
49    call vol_dum_real(3.141592653 / (-10.6e-11))
50    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
51    !BECAUSE: '(1._4,3.2000000476837158203125_4)' is not a variable or pointer
52    call vol_dum_complex((1., 3.2))
53    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
54    !BECAUSE: '(-1._4,6.340000152587890625_4)' is not a variable or pointer
55    call vol_dum_complex((1., 3.2) + (-2., 3.14))
56    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
57    !BECAUSE: '(-1.2048000335693359375e1_4,-3.2599999904632568359375_4)' is not a variable or pointer
58    call vol_dum_complex((1., 3.2) * (-2., 3.14))
59    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
60    !BECAUSE: '(5.80680549144744873046875e-1_4,-6.8833148479461669921875e-1_4)' is not a variable or pointer
61    call vol_dum_complex((1., 3.2) / (-2., 3.14))
62    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
63    !BECAUSE: '[INTEGER(4)::1_4,2_4,3_4,4_4]' is not a variable or pointer
64    call vol_dum_int_arr((/ 1, 2, 3, 4 /))
65    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
66    !BECAUSE: 'reshape([INTEGER(4)::1_4,2_4,3_4,4_4],shape=[2,2])' is not a variable or pointer
67    call vol_dum_int_arr(reshape((/ 1, 2, 3, 4 /), (/ 2, 2/)))
68    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
69    !BECAUSE: '[INTEGER(4)::1_4,2_4,3_4,4_4]' is not a variable or pointer
70    call vol_dum_int_arr((/ 1, 2, 3, 4 /))
71  end subroutine test_all_subprograms
72end module m
73