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