1 1.1 christos # This test code is part of GDB, the GNU debugger. 2 1.1 christos 3 1.11 christos # Copyright 2010-2024 Free Software Foundation, Inc. 4 1.1 christos # 5 1.1 christos # This program is free software; you can redistribute it and/or modify 6 1.1 christos # it under the terms of the GNU General Public License as published by 7 1.1 christos # the Free Software Foundation; either version 3 of the License, or 8 1.1 christos # (at your option) any later version. 9 1.1 christos # 10 1.1 christos # This program is distributed in the hope that it will be useful, 11 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos # GNU General Public License for more details. 14 1.1 christos # 15 1.1 christos # You should have received a copy of the GNU General Public License 16 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 1.1 christos 18 1.1 christos # Auxiliary function to set the language to fortran. 19 1.1 christos # The result is 1 (true) for success, 0 (false) for failure. 20 1.1 christos 21 1.1 christos proc set_lang_fortran {} { 22 1.1 christos if [gdb_test_no_output "set language fortran"] { 23 1.1 christos return 0 24 1.1 christos } 25 1.1 christos if [gdb_test "show language" ".* source language is \"fortran\"." \ 26 1.1 christos "set language to \"fortran\""] { 27 1.1 christos return 0 28 1.1 christos } 29 1.1 christos return 1 30 1.1 christos } 31 1.6 christos 32 1.6 christos proc fortran_int4 {} { 33 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 34 1.6 christos return "int4" 35 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 36 1.6 christos return "integer\\(kind=4\\)" 37 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 38 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 39 1.9 christos return "integer" 40 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 41 1.6 christos return "INTEGER\\(4\\)" 42 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 43 1.10 christos return "INTEGER\\*4" 44 1.6 christos } else { 45 1.6 christos return "unknown" 46 1.6 christos } 47 1.6 christos } 48 1.6 christos 49 1.9 christos proc fortran_int8 {} { 50 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 51 1.9 christos return "int8" 52 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 53 1.9 christos return "integer\\(kind=8\\)" 54 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 55 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 56 1.10 christos return "integer\\*8" 57 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 58 1.9 christos return "INTEGER\\(8\\)" 59 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 60 1.10 christos return "INTEGER\\*8" 61 1.9 christos } else { 62 1.9 christos return "unknown" 63 1.9 christos } 64 1.9 christos } 65 1.9 christos 66 1.6 christos proc fortran_real4 {} { 67 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 68 1.6 christos return "real4" 69 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 70 1.6 christos return "real\\(kind=4\\)" 71 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 72 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 73 1.9 christos return "real" 74 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 75 1.6 christos return "REAL\\(4\\)" 76 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 77 1.10 christos return "REAL\\*4" 78 1.6 christos } else { 79 1.6 christos return "unknown" 80 1.6 christos } 81 1.6 christos } 82 1.6 christos 83 1.6 christos proc fortran_real8 {} { 84 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 85 1.6 christos return "real8" 86 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 87 1.6 christos return "real\\(kind=8\\)" 88 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 89 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 90 1.9 christos return "double precision" 91 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 92 1.6 christos return "REAL\\(8\\)" 93 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 94 1.10 christos return "REAL\\*8" 95 1.6 christos } else { 96 1.6 christos return "unknown" 97 1.6 christos } 98 1.6 christos } 99 1.6 christos 100 1.6 christos proc fortran_complex4 {} { 101 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 102 1.6 christos return "complex4" 103 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 104 1.6 christos return "complex\\(kind=4\\)" 105 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 106 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 107 1.9 christos return "complex" 108 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 109 1.6 christos return "COMPLEX\\(4\\)" 110 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 111 1.10 christos return "COMPLEX\\*8" 112 1.6 christos } else { 113 1.6 christos return "unknown" 114 1.6 christos } 115 1.6 christos } 116 1.6 christos 117 1.9 christos proc fortran_complex8 {} { 118 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 119 1.9 christos return "complex8" 120 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 121 1.9 christos return "complex\\(kind=8\\)" 122 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 123 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 124 1.9 christos return "double complex" 125 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 126 1.9 christos return "COMPLEX\\(8\\)" 127 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 128 1.10 christos return "COMPLEX\\*16" 129 1.9 christos } else { 130 1.9 christos return "unknown" 131 1.9 christos } 132 1.9 christos } 133 1.9 christos 134 1.9 christos proc fortran_complex16 {} { 135 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 136 1.9 christos return "complex16" 137 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 138 1.9 christos return "complex\\(kind=16\\)" 139 1.10 christos } elseif {[test_compiler_info {flang-*} f90]} { 140 1.9 christos return "quad complex" 141 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 142 1.9 christos return "COMPLEX\\(16\\)" 143 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 144 1.10 christos return "COMPLEX\\*32" 145 1.9 christos } else { 146 1.9 christos return "unknown" 147 1.9 christos } 148 1.9 christos } 149 1.9 christos 150 1.6 christos proc fortran_logical4 {} { 151 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 152 1.6 christos return "logical4" 153 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 154 1.6 christos return "logical\\(kind=4\\)" 155 1.11 christos } elseif {[test_compiler_info {flang-*} f90] 156 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 157 1.9 christos return "logical" 158 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 159 1.6 christos return "LOGICAL\\(4\\)" 160 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 161 1.10 christos return "LOGICAL\\*4" 162 1.6 christos } else { 163 1.6 christos return "unknown" 164 1.6 christos } 165 1.6 christos } 166 1.9 christos 167 1.9 christos proc fortran_character1 {} { 168 1.10 christos if {[test_compiler_info {gfortran-4-[012]-*} f90]} { 169 1.9 christos return "character1" 170 1.10 christos } elseif {[test_compiler_info {gfortran-*} f90]} { 171 1.9 christos return "character\\(kind=1\\)" 172 1.10 christos } elseif {[test_compiler_info {flang-*} f90]} { 173 1.9 christos return "character" 174 1.11 christos } elseif {[test_compiler_info {nvfortran-*} f90]} { 175 1.11 christos return "character\\*1" 176 1.10 christos } elseif {[test_compiler_info {ifort-*} f90]} { 177 1.9 christos return "CHARACTER\\(1\\)" 178 1.10 christos } elseif {[test_compiler_info {ifx-*} f90]} { 179 1.10 christos return "CHARACTER\\*1" 180 1.9 christos } else { 181 1.9 christos return "unknown" 182 1.9 christos } 183 1.9 christos } 184 1.9 christos 185 1.9 christos # Return name of the main procedure based on the compiler version. 186 1.9 christos 187 1.9 christos proc fortran_main {} { 188 1.10 christos if {[test_compiler_info {gfortran-*} f90] 189 1.10 christos || [test_compiler_info {ifort-*} f90] 190 1.10 christos || [test_compiler_info {ifx-*} f90] 191 1.10 christos || [test_compiler_info {flang-llvm-*} f90]} { 192 1.9 christos return "MAIN__" 193 1.11 christos } elseif {[test_compiler_info {flang-classic-*} f90] 194 1.11 christos || [test_compiler_info {nvfortran-*} f90]} { 195 1.9 christos return "MAIN_" 196 1.9 christos } else { 197 1.9 christos return "unknown" 198 1.9 christos } 199 1.9 christos } 200 1.9 christos 201 1.9 christos # Fortran version of runto_main. 202 1.9 christos 203 1.9 christos proc fortran_runto_main { } { 204 1.9 christos return [runto [fortran_main]] 205 1.9 christos } 206