[gdb/testsuite] Fix .debug_aranges in watch-loc.c
[external/binutils.git] / gdb / testsuite / gdb.dlang / properties.exp
1 # Copyright (C) 2015-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 # Test basic builtin types.
17 # NOTE: The tests here intentionally do not require a D compiler.
18
19 load_lib "d-support.exp"
20
21 if { [skip_d_tests] } { continue }
22
23 proc test_d_sizeof {} {
24     # Test use of .sizeof with types and expressions.
25     gdb_test "print bool.sizeof" " = 1"
26     gdb_test "print (bool).sizeof" " = 1"
27
28     gdb_test "print char.sizeof" " = 1"
29     gdb_test "print wchar.sizeof" " = 2"
30     gdb_test "print dchar.sizeof" " = 4"
31
32     gdb_test "print byte.sizeof" " = 1"
33     gdb_test "print ubyte.sizeof" " = 1"
34     gdb_test "print short.sizeof" " = 2"
35     gdb_test "print ushort.sizeof" " = 2"
36     gdb_test "print int.sizeof" " = 4"
37     gdb_test "print uint.sizeof" " = 4"
38     gdb_test "print long.sizeof" " = 8"
39     gdb_test "print ulong.sizeof" " = 8"
40     gdb_test "print cent.sizeof" " = 16"
41     gdb_test "print ucent.sizeof" " = 16"
42
43     gdb_test "print float.sizeof" " = 4"
44     gdb_test "print ifloat.sizeof" " = 4"
45     gdb_test "print double.sizeof" " = 8"
46     gdb_test "print idouble.sizeof" " = 8"
47
48     gdb_test "print (1).sizeof" " = 4"
49     gdb_test "print (1U).sizeof" " = 4"
50     gdb_test "print (1L).sizeof" " = 8"
51     gdb_test "print (1UL).sizeof" " = 8"
52     gdb_test "print (1.0).sizeof" " = 8"
53     gdb_test "print (1.0f).sizeof" " = 4"
54
55     gdb_test "print (7 ^^ 3).sizeof" " = 4"
56     gdb_test "print (7L ^^ 3).sizeof" " = 8"
57     gdb_test "print (7.0 ^^ 3).sizeof" " = 8"
58     gdb_test "print (7.0f ^^ 3).sizeof" " = 4"
59 }
60
61 proc test_d_typeof {} {
62     # Test use of typeof() with expressions.
63     gdb_test "ptype typeof(false)" "type = bool"
64
65     gdb_test "ptype typeof(1)" "type = int"
66     gdb_test "ptype typeof(1U)" "type = uint"
67     gdb_test "ptype typeof(1L)" "type = long"
68     gdb_test "ptype typeof(1UL)" "type = ulong"
69     gdb_test "ptype typeof(1.0)" "type = double"
70     gdb_test "ptype typeof(1.0L)" "type = real"
71     gdb_test "ptype typeof(1.0f)" "type = float"
72
73     gdb_test "ptype typeof(cast(byte) 1)" "type = byte"
74     gdb_test "ptype typeof(cast(short) 1)" "type = short"
75
76     gdb_test "ptype typeof(7 ^^ 3)" "type = int"
77     gdb_test "ptype typeof(7L ^^ 3)" "type = long"
78     gdb_test "ptype typeof(7.0 ^^ 3)" "type = double"
79     gdb_test "ptype typeof(7.0L ^^ 3)" "type = real"
80     gdb_test "ptype typeof(7.0f ^^ 3)" "type = float"
81 }
82
83 # Start with a fresh gdb.
84
85 gdb_exit
86 gdb_start
87
88 if [set_lang_d] {
89     test_d_sizeof
90     test_d_typeof
91 } else {
92     warning "D type tests suppressed."
93 }