# Copyright 2019 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # This is a set of tests related to GDB's ability to parse and # correctly handle the (kind=N) type adjustment mechanism within # Fortran. load_lib "fortran.exp" if { [skip_fortran_tests] } { continue } # Cast the value 1 to the type 'BASE_TYPE (kind=TYPE_KIND)'. The # expected result of the cast is CAST_RESULT, and the size of the # value returned by the cast should be SIZE_RESULT. proc test_cast_1_to_type_kind {base_type type_kind cast_result size_result} { set type_string "$base_type (kind=$type_kind)" gdb_test "p (($type_string) 1)" " = $cast_result" if {($base_type == "real" || $base_type == "complex") && $type_kind == 16} { setup_kfail gdb/18644 "*-*-*" } gdb_test "p sizeof (($type_string) 1)" " = $size_result" } # Test parsing of `(kind=N)` type modifiers. proc test_basic_parsing_of_type_kinds {} { test_cast_1_to_type_kind "character" "1" "1" "1" test_cast_1_to_type_kind "complex" "4" "\\(1,0\\)" "8" test_cast_1_to_type_kind "complex" "8" "\\(1,0\\)" "16" test_cast_1_to_type_kind "complex" "16" "\\(1,0\\)" "32" test_cast_1_to_type_kind "real" "4" "1" "4" test_cast_1_to_type_kind "real" "8" "1" "8" test_cast_1_to_type_kind "real" "16" "1" "16" test_cast_1_to_type_kind "logical" "1" "\\.TRUE\\." "1" test_cast_1_to_type_kind "logical" "4" "\\.TRUE\\." "4" test_cast_1_to_type_kind "logical" "8" "\\.TRUE\\." "8" test_cast_1_to_type_kind "integer" "2" "1" "2" test_cast_1_to_type_kind "integer" "4" "1" "4" } proc test_parsing_invalid_type_kinds {} { foreach typename {complex real logical integer} { foreach typesize {3 5 7 9} { gdb_test "p (($typename (kind=$typesize)) 1)" "unsupported kind $typesize for type $typename.*" } } } clean_restart if [set_lang_fortran] then { test_basic_parsing_of_type_kinds test_parsing_invalid_type_kinds } else { warning "$test_name tests suppressed." 0 }