]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2008-2023 Free Software Foundation, Inc. |
78c62cee SW |
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 | ||
f5f3a911 TT |
16 | standard_testfile .cc |
17 | ||
5b362f04 | 18 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } { |
78c62cee SW |
19 | return -1 |
20 | } | |
21 | ||
22 | ############################################ | |
23 | ||
95701cae | 24 | if {![runto_main]} { |
cdd42066 | 25 | return |
78c62cee SW |
26 | } |
27 | ||
28 | gdb_breakpoint [gdb_get_line_number "end of main"] | |
29 | gdb_continue_to_breakpoint "end of main" | |
30 | ||
31 | # Test that overloaded arrow operator works | |
32 | gdb_test "p mp->foo()" "= 11" | |
33 | ||
34 | # Test that regular arrow operator still works | |
35 | gdb_test "p mtp->foo()" "= 11" | |
36 | ||
37 | # Test that normal '.' operator still works. | |
38 | gdb_test "p mt1.foo()" "= 11" | |
39 | ||
40 | # test that gdb extension '.' for pointers still works. | |
41 | gdb_test "p mt4p.a" "= 11" | |
42 | ||
43 | # test that gdb extension '->' for structs still works. | |
44 | gdb_test "p mt4->a" "= 11" | |
45 | ||
46 | # Test that templated smart pointers work | |
47 | gdb_test "p sp1->foo()" "= 11" | |
48 | gdb_test "p sp2->foo()" "= 22" | |
49 | ||
50 | # Test that overload resolution works properly | |
51 | # with smart pointers | |
52 | gdb_test "p sp3->foo(1)" "= 33" | |
53 | gdb_test "p sp3->foo('a')" "= 44" | |
54 | ||
55 | # Test smart pointers work for member references | |
56 | gdb_test "p sp4->a" "= 11" | |
57 | gdb_test "p sp4->b" "= 12" | |
58 | ||
59 | # Test regular arrow operator still works for | |
60 | # member references | |
61 | gdb_test "p mt4p->a" "= 11" | |
62 | gdb_test "p mt4p->b" "= 12" | |
63 | ||
64 | # Test that incorrect use of the arrow operator | |
65 | # is still handled correctly. | |
66 | gdb_test "p mt4->fake" "There is no member named fake." | |
67 | gdb_test "p mt4->fake()" "Couldn't find method Type4::fake" | |
68 | ||
69 | # Test that overloading of -> works recursively | |
70 | gdb_test "p b->foo()" "= 66" | |
71 | gdb_test "p c->foo()" "= 66" | |
72 | gdb_test "p c->inta" "= 77" | |
73 | ||
78c62cee SW |
74 | gdb_test "p c2->inta" "= 77" |
75 |