gdb/fortran: Add builtin 8-byte integer type with (kind=8) support
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / type-kinds.exp
CommitLineData
4d00f5d8
AB
1# Copyright 2019 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# This is a set of tests related to GDB's ability to parse and
17# correctly handle the (kind=N) type adjustment mechanism within
18# Fortran.
19
20load_lib "fortran.exp"
21
22if { [skip_fortran_tests] } { continue }
23
3be47f7a
AB
24# Cast the value 1 to the type 'BASE_TYPE (kind=TYPE_KIND)'. The
25# expected result of the cast is CAST_RESULT, and the size of the
26# value returned by the cast should be SIZE_RESULT.
27proc test_cast_1_to_type_kind {base_type type_kind cast_result size_result} {
28 set type_string "$base_type (kind=$type_kind)"
29 gdb_test "p (($type_string) 1)" " = $cast_result"
30
31 if {($base_type == "real" || $base_type == "complex")
32 && $type_kind == 16} {
33 setup_kfail gdb/18644 "*-*-*"
34 }
35
36 gdb_test "p sizeof (($type_string) 1)" " = $size_result"
37}
38
4d00f5d8
AB
39# Test parsing of `(kind=N)` type modifiers.
40proc test_basic_parsing_of_type_kinds {} {
3be47f7a
AB
41 test_cast_1_to_type_kind "character" "1" "1" "1"
42
43 test_cast_1_to_type_kind "complex" "4" "\\(1,0\\)" "8"
44 test_cast_1_to_type_kind "complex" "8" "\\(1,0\\)" "16"
45 test_cast_1_to_type_kind "complex" "16" "\\(1,0\\)" "32"
46
47 test_cast_1_to_type_kind "real" "4" "1" "4"
48 test_cast_1_to_type_kind "real" "8" "1" "8"
49 test_cast_1_to_type_kind "real" "16" "1" "16"
50
51 test_cast_1_to_type_kind "logical" "1" "\\.TRUE\\." "1"
52 test_cast_1_to_type_kind "logical" "4" "\\.TRUE\\." "4"
53 test_cast_1_to_type_kind "logical" "8" "\\.TRUE\\." "8"
54
55 test_cast_1_to_type_kind "integer" "2" "1" "2"
56 test_cast_1_to_type_kind "integer" "4" "1" "4"
067630bd 57 test_cast_1_to_type_kind "integer" "8" "1" "8"
3be47f7a
AB
58}
59
60proc test_parsing_invalid_type_kinds {} {
61 foreach typename {complex real logical integer} {
62 foreach typesize {3 5 7 9} {
63 gdb_test "p (($typename (kind=$typesize)) 1)" "unsupported kind $typesize for type $typename.*"
64 }
65 }
4d00f5d8
AB
66}
67
68clean_restart
69
70if [set_lang_fortran] then {
71 test_basic_parsing_of_type_kinds
3be47f7a 72 test_parsing_invalid_type_kinds
4d00f5d8
AB
73} else {
74 warning "$test_name tests suppressed." 0
75}
This page took 0.028047 seconds and 4 git commands to generate.