]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2013-2023 Free Software Foundation, Inc. |
6e72ca20 TT |
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 | standard_testfile .cc | |
17 | ||
18 | if {[skip_cplus_tests]} { | |
19 | return -1 | |
20 | } | |
21 | ||
5b362f04 | 22 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
6e72ca20 TT |
23 | return -1 |
24 | } | |
25 | ||
26 | proc do_typeid_tests {started} { | |
27 | global hex | |
28 | ||
29 | # We might see the standard type or gdb's internal type. | |
e86ca25f | 30 | set type_re "(std::type_info|gdb_gnu_v3_type_info)" |
6e72ca20 | 31 | |
ebe9ddbc BL |
32 | set var {ca b} |
33 | if {$started || ![test_compiler_info clang-*-* c++]} { | |
34 | # Clang doesn't place type information for the base types in | |
35 | # the executable, and relies on this being linked in from the | |
36 | # standard library. As a result, type information for these | |
37 | # variables is only available once the inferior is started. | |
38 | lappend var i cp ccp | |
39 | } | |
6e72ca20 | 40 | |
ebe9ddbc | 41 | foreach simple_var $var { |
6e72ca20 TT |
42 | gdb_test "print &typeid($simple_var)" \ |
43 | " = \\($type_re \\*\\) $hex.*" | |
44 | ||
45 | # Note that we test pointer equality rather than object | |
46 | # equality here. That is because std::type_info's operator== | |
47 | # is not present in the libstdc++ .so. | |
48 | gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \ | |
49 | " = true" | |
50 | } | |
51 | ||
52 | # typeid for these is Derived. Don't try these tests until the | |
53 | # inferior has started. | |
54 | if {$started} { | |
55 | foreach der_var {*b *vb1 *vb2 *bv d {const Derived} {const Derived &}} { | |
56 | gdb_test "print &typeid($der_var)" \ | |
57 | " = \\($type_re \\*\\) $hex.*" | |
58 | gdb_test "print &typeid($der_var) == &typeid(d)" \ | |
59 | " = true" | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | with_test_prefix "before starting" { | |
65 | do_typeid_tests 0 | |
66 | } | |
67 | ||
68 | if ![runto_main] { | |
6e72ca20 TT |
69 | return -1 |
70 | } | |
71 | ||
72 | with_test_prefix "after starting" { | |
73 | do_typeid_tests 1 | |
74 | } |