1 ! Copyright 2018-2021 Free Software Foundation, Inc.
3 ! This program is free software; you can redistribute it and/or modify
4 ! it under the terms of the GNU General Public License as published by
5 ! the Free Software Foundation; either version 3 of the License, or
6 ! (at your option) any later version.
8 ! This program is distributed in the hope that it will be useful,
9 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ! GNU General Public License for more details.
13 ! You should have received a copy of the GNU General Public License
14 ! along with this program. If not, see <http://www.gnu.org/licenses/> .
16 ! Source code for short-circuit-argument-list.exp.
21 integer :: function_no_arg_called
= 0
22 integer :: function_no_arg_false_called
= 0
23 integer :: function_one_arg_called
= 0
24 integer :: function_two_arg_called
= 0
25 integer :: function_array_called
= 0
27 type(called_counts
) :: calls
28 end module called_state
30 logical function function_no_arg()
33 calls
%function_no_arg_called
= calls
%function_no_arg_called
+ 1
34 function_no_arg
= .TRUE
.
35 end function function_no_arg
37 logical function function_no_arg_false()
40 calls
%function_no_arg_false_called
= calls
%function_no_arg_false_called
+ 1
41 function_no_arg_false
= .FALSE
.
42 end function function_no_arg_false
44 logical function function_one_arg(x
)
47 logical, intent(in
) :: x
48 calls
%function_one_arg_called
= calls
%function_one_arg_called
+ 1
49 function_one_arg
= .TRUE
.
50 end function function_one_arg
52 logical function function_two_arg(x
, y
)
55 logical, intent(in
) :: x
, y
56 calls
%function_two_arg_called
= calls
%function_two_arg_called
+ 1
57 function_two_arg
= .TRUE
.
58 end function function_two_arg
60 logical function function_array(logical_array
)
63 logical, dimension(4,2), target
, intent(in
) :: logical_array
64 logical, dimension(:,:), pointer :: p
65 calls
%function_array_called
= calls
%function_array_called
+ 1
66 function_array
= .TRUE
.
67 end function function_array
69 program generate_truth_table
73 logical function function_no_arg()
74 end function function_no_arg
75 logical function function_no_arg_false()
77 logical function function_one_arg(x
)
78 logical, intent(in
) :: x
80 logical function function_two_arg(x
, y
)
81 logical, intent(in
) :: x
, y
83 logical function function_array(logical_array
)
84 logical, dimension(4,2), target
, intent(in
) :: logical_array
85 end function function_array
87 logical, dimension (4,2) :: truth_table
88 logical :: a
, b
, c
, d
, e
89 character(2) :: binary_string
90 binary_string
= char(0) // char(1)
92 truth_table(3:4,1) = .TRUE
.
93 truth_table(2::2,2) = .TRUE
.
94 a
= function_no_arg() ! post_truth_table_init
95 b
= function_no_arg_false()
96 c
= function_one_arg(b
)
97 d
= function_two_arg(a
, b
)
98 e
= function_array(truth_table
)
99 print *, truth_table(:, 1), a
, b
, e
100 print *, truth_table(:, 2), c
, d
101 end program generate_truth_table