rvalue-ref-params.exp revision 1.1.1.4
1# Copyright 2006-2023 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 {[build_executable $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 43gdb_test "print f3(static_cast<int&&> (global_int))" " = 8" 44gdb_test "print f4(static_cast<float&&> (global_float))" " = 3" 45 46gdb_test "print static_cast<int&> (global_int)" " = \\(int &\\) @$hex: 7" 47gdb_test "print static_cast<int&&> (global_int)" " = \\(int &&\\) @$hex: 7" 48 49gdb_test "print static_cast<float&> (global_float)" " = \\(float &\\) @$hex: 3\\.$decimal" 50gdb_test "print static_cast<float&&> (global_float)" " = \\(float &&\\) @$hex: 3\\.$decimal" 51 52set t "print value of f2 on (Child&&) in main" 53gdb_start_again "marker1 here" $t 54gdb_test "print f2(static_cast<Child&&>(Q))" ".* = 40.*" $t 55 56set t "print value of Child&& in f2" 57gdb_start_again "marker2 here" $t 58gdb_test "print C" ".*id = 42.*" $t 59 60gdb_test "print f1 (static_cast<Child&&> (C))" ".* = 42.*" \ 61 "print value of f1 on Child&& in f2" 62 63set t "print value of Parent&& in f1" 64gdb_start_again "marker3 here" $t 65gdb_test "print R" ".*id = 41.*" $t 66 67set t "print f1(static_cast<MultiChild&&>(MQ))" 68gdb_start_again "breakpoint MQ here" $t 69gdb_test $t ".* = 53" 70 71set t "print mf1(static_cast<MultiChild&&>(MQ))" 72gdb_start_again "breakpoint MQ here" $t 73gdb_test $t ".* = 106" 74 75set t "print mf2(static_cast<MultiChild&&>(MQ))" 76gdb_start_again "breakpoint MQ here" $t 77gdb_test $t ".* = 106" 78