1# Copyright 2006-2020 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# Tests for rvalue reference parameters of types and their subtypes in GDB,
17# based on gdb.cp/ref-params.exp.
18
19if {[skip_cplus_tests]} { continue }
20
21standard_testfile .cc
22
23if {[prepare_for_testing $testfile.exp $testfile $srcfile \
24    {debug c++ additional_flags="-std=gnu++11"}] == -1} {
25    return -1
26}
27
28proc gdb_start_again {text prefix} {
29    global binfile
30    global srcfile
31
32    with_test_prefix $prefix {
33	clean_restart $binfile
34
35	runto ${srcfile}:[gdb_get_line_number $text]
36    }
37}
38
39set t "print value of f1 on (Child&&) in main"
40gdb_start_again "marker1 here" $t
41gdb_test "print f1(static_cast<Child&&>(Q))" ".* = 40.*" $t
42
43set t "print value of f2 on (Child&&) in main"
44gdb_start_again "marker1 here" $t
45gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 40.*" $t
46
47set t "print value of Child&& in f2"
48gdb_start_again "marker2 here" $t
49gdb_test "print C" ".*id = 42.*" $t
50
51gdb_test "print f1 (static_cast<Child&&> (C))" ".* = 42.*" \
52    "print value of f1 on Child&& in f2"
53
54set t "print value of Parent&& in f1"
55gdb_start_again "marker3 here" $t
56gdb_test "print R" ".*id = 41.*" $t
57
58set t "print f1(static_cast<MultiChild&&>(MQ))"
59gdb_start_again "breakpoint MQ here" $t
60gdb_test $t ".* = 53"
61
62set t "print mf1(static_cast<MultiChild&&>(MQ))"
63gdb_start_again "breakpoint MQ here" $t
64gdb_test $t ".* = 106"
65
66set t "print mf2(static_cast<MultiChild&&>(MQ))"
67gdb_start_again "breakpoint MQ here" $t
68gdb_test $t ".* = 106"
69