Logical short circuiting with argument lists
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / short-circuit-argument-list.f90
CommitLineData
23be8da7
RB
1! Copyright 2018 Free Software Foundation, Inc.
2!
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.
7!
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.
12!
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/> .
15
16! Source code for short-circuit-argument-list.exp.
17
18logical function function_no_arg()
19 print *, "No, return true."
20 function_no_arg = .TRUE.
21end function function_no_arg
22
23logical function function_no_arg_false()
24 function_no_arg_false = .FALSE.
25end function function_no_arg_false
26
27logical function function_one_arg(x)
28 logical, intent(in) :: x
29 print *, "One, return true."
30 function_one_arg = .TRUE.
31end function function_one_arg
32
33logical function function_two_arg(x, y)
34 logical, intent(in) :: x, y
35 print *, "Two, return true."
36 function_two_arg = .TRUE.
37end function function_two_arg
38
39logical function function_array(logical_array)
40 logical, dimension(4,2), target, intent(in) :: logical_array
41 logical, dimension(:,:), pointer :: p
42 p => logical_array
43 print *, "Array, return true.", p(1,1), logical_array(1,1)
44 function_array = .TRUE.
45end function function_array
46
47program generate_truth_table
48 implicit none
49 interface
50 logical function function_no_arg()
51 end function function_no_arg
52 logical function function_no_arg_false()
53 end function
54 logical function function_one_arg(x)
55 logical, intent(in) :: x
56 end function
57 logical function function_two_arg(x, y)
58 logical, intent(in) :: x, y
59 end function
60 logical function function_array(logical_array)
61 logical, dimension(4,2), target, intent(in) :: logical_array
62 end function function_array
63 end interface
64 logical, dimension (4,2) :: truth_table
65 logical :: a, b, c, d, e
66 character(2) :: binary_string
67 binary_string = char(0) // char(1)
68 truth_table = .FALSE.
69 truth_table(3:4,1) = .TRUE.
70 truth_table(2::2,2) = .TRUE.
71 a = function_no_arg() ! post_truth_table_init
72 b = function_no_arg_false()
73 c = function_one_arg(b)
74 d = function_two_arg(a, b)
75 e = function_array(truth_table)
76 print *, truth_table(:, 1), a, b, e
77 print *, truth_table(:, 2), c, d
78end program generate_truth_table
This page took 0.045498 seconds and 4 git commands to generate.