1 # Copyright 2006-2021 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Tests for rvalue reference parameters of types and their subtypes in GDB,
17 # based on gdb.cp/ref-params.exp.
19 if {[skip_cplus_tests]} { continue }
23 if {[prepare_for_testing $testfile.exp $testfile $srcfile \
24 {debug c++ additional_flags="-std=gnu++11"}] == -1} {
28 proc gdb_start_again {text prefix} {
32 with_test_prefix $prefix {
33 clean_restart $binfile
35 runto ${srcfile}:[gdb_get_line_number $text]
39 set t "print value of f1 on (Child&&) in main"
40 gdb_start_again "marker1 here" $t
41 gdb_test "print f1(static_cast<Child&&>(Q))" ".* = 40.*" $t
43 gdb_test "print f3(static_cast<int&&> (global_int))" " = 8"
44 gdb_test "print f4(static_cast<float&&> (global_float))" " = 3"
46 gdb_test "print static_cast<int&> (global_int)" " = \\(int &\\) @$hex: 7"
47 gdb_test "print static_cast<int&&> (global_int)" " = \\(int &&\\) @$hex: 7"
49 gdb_test "print static_cast<float&> (global_float)" " = \\(float &\\) @$hex: 3\\.$decimal"
50 gdb_test "print static_cast<float&&> (global_float)" " = \\(float &&\\) @$hex: 3\\.$decimal"
52 set t "print value of f2 on (Child&&) in main"
53 gdb_start_again "marker1 here" $t
54 gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 40.*" $t
56 set t "print value of Child&& in f2"
57 gdb_start_again "marker2 here" $t
58 gdb_test "print C" ".*id = 42.*" $t
60 gdb_test "print f1 (static_cast<Child&&> (C))" ".* = 42.*" \
61 "print value of f1 on Child&& in f2"
63 set t "print value of Parent&& in f1"
64 gdb_start_again "marker3 here" $t
65 gdb_test "print R" ".*id = 41.*" $t
67 set t "print f1(static_cast<MultiChild&&>(MQ))"
68 gdb_start_again "breakpoint MQ here" $t
71 set t "print mf1(static_cast<MultiChild&&>(MQ))"
72 gdb_start_again "breakpoint MQ here" $t
73 gdb_test $t ".* = 106"
75 set t "print mf2(static_cast<MultiChild&&>(MQ))"
76 gdb_start_again "breakpoint MQ here" $t
77 gdb_test $t ".* = 106"