Home | History | Annotate | Line # | Download | only in lib
fortran.exp revision 1.1.1.6
      1 # This test code is part of GDB, the GNU debugger.
      2 
      3 # Copyright 2010-2020 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 {gcc-4-[012]-*}]} {
     34 	return "int4"
     35     } elseif {[test_compiler_info {gcc-*}]} {
     36 	return "integer\\(kind=4\\)"
     37     } elseif {[test_compiler_info {clang-*}]} {
     38 	return "integer"
     39     } elseif {[test_compiler_info {icc-*}]} {
     40 	return "INTEGER\\(4\\)"
     41     } else {
     42 	return "unknown"
     43     }
     44 }
     45 
     46 proc fortran_int8 {} {
     47     if {[test_compiler_info {gcc-4-[012]-*}]} {
     48 	return "int8"
     49     } elseif {[test_compiler_info {gcc-*}]} {
     50 	return "integer\\(kind=8\\)"
     51     } elseif {[test_compiler_info {clang-*}]} {
     52 	return "integer*8"
     53     } elseif {[test_compiler_info {icc-*}]} {
     54 	return "INTEGER\\(8\\)"
     55     } else {
     56 	return "unknown"
     57     }
     58 }
     59 
     60 proc fortran_real4 {} {
     61     if {[test_compiler_info {gcc-4-[012]-*}]} {
     62 	return "real4"
     63     } elseif {[test_compiler_info {gcc-*}]} {
     64 	return "real\\(kind=4\\)"
     65     } elseif {[test_compiler_info {clang-*}]} {
     66 	return "real"
     67     } elseif {[test_compiler_info {icc-*}]} {
     68 	return "REAL\\(4\\)"
     69     } else {
     70 	return "unknown"
     71     }
     72 }
     73 
     74 proc fortran_real8 {} {
     75     if {[test_compiler_info {gcc-4-[012]-*}]} {
     76 	return "real8"
     77     } elseif {[test_compiler_info {gcc-*}]} {
     78 	return "real\\(kind=8\\)"
     79     } elseif {[test_compiler_info {clang-*}]} {
     80 	return "double precision"
     81     } elseif {[test_compiler_info {icc-*}]} {
     82 	return "REAL\\(8\\)"
     83     } else {
     84 	return "unknown"
     85     }
     86 }
     87 
     88 proc fortran_complex4 {} {
     89     if {[test_compiler_info {gcc-4-[012]-*}]} {
     90 	return "complex4"
     91     } elseif {[test_compiler_info {gcc-*}]} {
     92 	return "complex\\(kind=4\\)"
     93     } elseif {[test_compiler_info {clang-*}]} {
     94 	return "complex"
     95     } elseif {[test_compiler_info {icc-*}]} {
     96 	return "COMPLEX\\(4\\)"
     97     } else {
     98 	return "unknown"
     99     }
    100 }
    101 
    102 proc fortran_complex8 {} {
    103     if {[test_compiler_info {gcc-4-[012]-*}]} {
    104 	return "complex8"
    105     } elseif {[test_compiler_info {gcc-*}]} {
    106 	return "complex\\(kind=8\\)"
    107     } elseif {[test_compiler_info {clang-*}]} {
    108 	return "double complex"
    109     } elseif {[test_compiler_info {icc-*}]} {
    110 	return "COMPLEX\\(8\\)"
    111     } else {
    112 	return "unknown"
    113     }
    114 }
    115 
    116 proc fortran_complex16 {} {
    117     if {[test_compiler_info {gcc-4-[012]-*}]} {
    118 	return "complex16"
    119     } elseif {[test_compiler_info {gcc-*}]} {
    120 	return "complex\\(kind=16\\)"
    121     } elseif {[test_compiler_info {clang-*}]} {
    122 	return "quad complex"
    123     } elseif {[test_compiler_info {icc-*}]} {
    124 	return "COMPLEX\\(16\\)"
    125     } else {
    126 	return "unknown"
    127     }
    128 }
    129 
    130 proc fortran_logical4 {} {
    131     if {[test_compiler_info {gcc-4-[012]-*}]} {
    132 	return "logical4"
    133     } elseif {[test_compiler_info {gcc-*}]} {
    134 	return "logical\\(kind=4\\)"
    135     } elseif {[test_compiler_info {clang-*}]} {
    136 	return "logical"
    137     } elseif {[test_compiler_info {icc-*}]} {
    138 	return "LOGICAL\\(4\\)"
    139     } else {
    140 	return "unknown"
    141     }
    142 }
    143 
    144 proc fortran_character1 {} {
    145     if {[test_compiler_info {gcc-4-[012]-*}]} {
    146 	return "character1"
    147     } elseif {[test_compiler_info {gcc-*}]} {
    148 	return "character\\(kind=1\\)"
    149     } elseif {[test_compiler_info {clang-*}]} {
    150 	return "character"
    151     } elseif {[test_compiler_info {icc-*}]} {
    152 	return "CHARACTER\\(1\\)"
    153     } else {
    154 	return "unknown"
    155     }
    156 }
    157 
    158 # Return name of the main procedure based on the compiler version.
    159 
    160 proc fortran_main {} {
    161     if {[test_compiler_info {gcc-4-[012]-*}]
    162          || [test_compiler_info {gcc-*}]
    163          || [test_compiler_info {icc-*}]} {
    164 	return "MAIN__"
    165     } elseif {[test_compiler_info {clang-*}]} {
    166 	return "MAIN_"
    167     } else {
    168 	return "unknown"
    169     }
    170 }
    171 
    172 # Fortran version of runto_main.
    173 
    174 proc fortran_runto_main { } {
    175     return [runto [fortran_main]]
    176 }
    177