]>
Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2008-2020 Free Software Foundation, Inc. |
7322dca9 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++}] } { |
4c3376c8 | 19 | return -1 |
7322dca9 SW |
20 | } |
21 | ||
7322dca9 SW |
22 | ############################################ |
23 | ||
24 | if ![runto_main] then { | |
25 | perror "couldn't run to breakpoint main" | |
26 | continue | |
27 | } | |
28 | ||
29 | # Test that koenig lookup finds correct function | |
30 | gdb_test "p first(c)" "= 11" | |
31 | ||
32 | # Change the number of parameters and position of | |
33 | # the qualifying parameter | |
34 | gdb_test "p second(0,0,c,0,0)" "= 33" | |
35 | ||
23be8da7 RB |
36 | # Test evaluating function under EVAL_SKIP |
37 | gdb_test "p true || second(0,0,c,0,0)" "= true" | |
38 | ||
36b11add JK |
39 | # Test the name "entry" being used for `variablename@entry' entry values. |
40 | gdb_test "p entry (c)" " = 44" | |
41 | ||
7322dca9 SW |
42 | # Test that koenig lookup finds correct function |
43 | # even if it is overloaded | |
44 | gdb_test "p first(0,c)" "= 22" | |
45 | ||
46 | # Test that koenig lookup finds correct function | |
47 | # when the argument is an expression | |
48 | gdb_test "p first(b.c)" "= 11" | |
49 | ||
50 | # test that resolutions can be made across namespaces | |
51 | gdb_test "p foo(eo)" "= 1" | |
52 | gdb_test "p foo(eo, eo)" "= 2" | |
53 | gdb_test "p foo(eo, eo, 1)" "= 3" | |
54 | gdb_test "p foo(fo, eo)" "= 4" | |
55 | gdb_test "p foo(1 ,fo, eo)" "= 5" | |
56 | gdb_test "p foo(go, fo, eo)" "= 6" | |
57 | ||
58 | #test that gdb fails gracefully | |
59 | gdb_test "p fake(eo)" "No symbol \"fake\" in current context." | |
7d3fe98e | 60 | gdb_test "p foo (fake)" "No symbol \"fake\" in current context." |
7322dca9 SW |
61 | |
62 | #test that namespaces of base classes are searched | |
63 | gdb_test "p foo(io)" "= 7" | |
64 | gdb_test "p foo(ix)" "Cannot resolve function foo to any overloaded instance" | |
65 | ||
66 | #test for other types | |
67 | gdb_test "p foo(ju)" "= 8" | |
68 | gdb_test "p foo(js)" "= 9" | |
69 | gdb_test "p foo(je)" "= 10" | |
70 | ||
71 | #test for class members | |
72 | setup_xfail "*-*-*" | |
73 | gdb_test "p foo(jab)" "= 11" | |
74 | ||
75 | gdb_test "p foo(jap)" "= 12" | |
76 | gdb_test "p foo(japp)" "= 13" | |
77 | gdb_test "p foo(jca)" "= 14" | |
78 | ||
79 | #test overload resolution | |
80 | gdb_test "p foo(ko,1)" "= 15" | |
81 | gdb_test "p foo(ko,1.0f)" "= 16" | |
82 | setup_xfail "*-*-*" | |
83 | gdb_test "p bar(ko,1)" "= -1" | |
84 | ||
85 | #test lookup of objects belonging to nested namespaces | |
86 | gdb_test "p foo(labo)" "= 17" | |
87 | ||
88 | #test koenig found function do not compete with qualified | |
89 | #names | |
90 | gdb_test "p ma.foo('a')" "= 18" | |
91 | gdb_test "p foo(ma,'a')" "= 19" | |
92 | gdb_test "p M::N::foo(ma,'a')" "= 20" | |
93 | gdb_test "p M::FAKE::foo(ma,'a')" "No type \"FAKE\" within class or namespace \"M\"." | |
94 | gdb_test "p M::N::fake(ma,'a')" "No symbol \"fake\" in namespace \"M::N\"." | |
95 | ||
96 | gdb_test "p M::bar('a')" "= 21" | |
97 | gdb_test "p M::N::bar('a')" "= 22" | |
98 | ||
99 | #test that lookup supports typedef | |
100 | gdb_test "p foo(ttoa, 'a')" "= 23" | |
7d3fe98e SW |
101 | |
102 | #test that lookup is not thwarted by anonymous types | |
103 | gdb_test "p foo (p_union)" \ | |
104 | "Cannot resolve function foo to any overloaded instance" | |
4c3376c8 SW |
105 | |
106 | # test lookup of namespace user-defined operators | |
107 | # and overload resolution: | |
108 | ||
109 | # within class | |
110 | gdb_test "p q == 5" "= 24" | |
111 | gdb_test "p q == 5.0f" "= 25" | |
112 | ||
113 | # within namespace | |
114 | gdb_test "p q != 5" "= 27" | |
115 | gdb_test "p q != 5.0f" "= 28" | |
116 | ||
117 | # across namespace and class | |
118 | gdb_test "p q + 5.0f" "= 26" | |
119 | gdb_test "p q + 5" "= 29" | |
120 | ||
121 | # some unary operators for good measure | |
122 | # Cannot resolve function operator++ to any overloaded instance | |
123 | gdb_test "p ++q" "= 30" | |
450ca57c SW |
124 | |
125 | # Test that koening lookup does not affect | |
126 | # member variable lookup. | |
127 | gdb_test "p r.rfoo()" "= 31" | |
128 | ||
129 | # Do the same from inside class R. | |
130 | gdb_breakpoint [gdb_get_line_number "marker1"] | |
131 | gdb_continue_to_breakpoint "marker1" | |
132 | ||
133 | gdb_test "p rfoo()" "= 31" | |
134 | gdb_test "p this->rfoo()" "= 31" |