2017-01-01 07:50:51 +01:00
|
|
|
# Copyright 2013-2017 Free Software Foundation, Inc.
|
2013-04-15 19:36:14 +02:00
|
|
|
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
standard_testfile .cc
|
|
|
|
|
|
|
|
if {[skip_cplus_tests]} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:52:18 +01:00
|
|
|
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
|
2013-04-15 19:36:14 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
proc do_typeid_tests {started} {
|
|
|
|
global hex
|
|
|
|
|
|
|
|
# We might see the standard type or gdb's internal type.
|
|
|
|
set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
|
|
|
|
|
|
|
|
|
|
|
|
foreach simple_var {i cp ccp ca b} {
|
|
|
|
gdb_test "print &typeid($simple_var)" \
|
|
|
|
" = \\($type_re \\*\\) $hex.*"
|
|
|
|
|
|
|
|
# Note that we test pointer equality rather than object
|
|
|
|
# equality here. That is because std::type_info's operator==
|
|
|
|
# is not present in the libstdc++ .so.
|
|
|
|
gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \
|
|
|
|
" = true"
|
|
|
|
}
|
|
|
|
|
|
|
|
# typeid for these is Derived. Don't try these tests until the
|
|
|
|
# inferior has started.
|
|
|
|
if {$started} {
|
|
|
|
foreach der_var {*b *vb1 *vb2 *bv d {const Derived} {const Derived &}} {
|
|
|
|
gdb_test "print &typeid($der_var)" \
|
|
|
|
" = \\($type_re \\*\\) $hex.*"
|
|
|
|
gdb_test "print &typeid($der_var) == &typeid(d)" \
|
|
|
|
" = true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
with_test_prefix "before starting" {
|
|
|
|
do_typeid_tests 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![runto_main] {
|
|
|
|
untested typeid
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
with_test_prefix "after starting" {
|
|
|
|
do_typeid_tests 1
|
|
|
|
}
|