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