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