1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Testing 15.6.2.2 point 4 (What function-name refers to depending on the
7 ! Without RESULT, it refers to the result object (no recursive
10 ! testing with data object results
13 !ERROR: Recursive call to 'f1' requires a distinct RESULT in its declaration
21 !ERROR: Recursive call to 'f2' requires a distinct RESULT in its declaration
29 ! OK reference to array result f1
35 ! testing with function pointer results
40 procedure(rf
), pointer :: f4
42 ! OK call to f4 pointer (rf)
44 !ERROR: Actual argument for 'x=' may not be a procedure
50 real function rfunc(x
)
54 procedure(rfunc
), pointer :: f5
56 ! OK call to f5 pointer
58 !ERROR: Actual argument for 'x=' may not be a procedure
61 ! Sanity test: f18 handles C1560 violation by ignoring RESULT
62 !WARNING: The function name should not appear in RESULT, references to 'f6' inside the function will be considered as references to the result only
63 function f6() result(f6
)
65 !WARNING: The function name should not appear in RESULT, references to 'f7' inside the function will be considered as references to the result only
66 function f7() result(f7
)
68 !ERROR: Recursive call to 'f7' requires a distinct RESULT in its declaration
76 ! With RESULT, it refers to the function (recursive calls possible)
79 ! testing with data object results
80 function f1() result(r
)
82 r
= acos(f1()) !OK, recursive call
83 !ERROR: Actual argument for 'x=' may not be a procedure
86 function f2(i
) result(r
)
89 r
= acos(f2(i
+1)) ! OK, recursive call
90 !ERROR: Actual argument for 'x=' may not be a procedure
93 function f3(i
) result(r
)
96 r
= acos(f3(i
+1)) !OK recursive call
97 !ERROR: Actual argument for 'x=' may not be a procedure
101 ! testing with function pointer results
105 function f4() result(r
)
107 procedure(rf
), pointer :: r
109 !ERROR: Actual argument for 'x=' may not be a procedure
110 x
= acos(f4()) ! recursive call
111 !ERROR: Actual argument for 'x=' may not be a procedure
115 function f5(x
) result(r
)
117 procedure(acos
), pointer :: r
119 !ERROR: Actual argument for 'x=' may not be a procedure
120 x
= acos(f5(x
+1)) ! recursive call
121 !ERROR: Actual argument for 'x=' may not be a procedure
123 x
= acos(r(x
+1)) ! OK
126 ! testing that calling the result is also caught
127 function f6() result(r
)
129 !ERROR: 'r' is not a callable procedure
134 subroutine array_rank_test()
136 !ERROR: Reference to rank-2 object 'x' has 1 subscripts
138 !ERROR: Reference to rank-2 object 'x' has 3 subscripts