1 # Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>.
21 set srcfile ${testfile}.cc
22 set binfile ${objdir}/${subdir}/${testfile}
23 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
24 untested "Couldn't compile test program"
32 gdb_reinitialize_dir $srcdir/$subdir
35 ############################################
37 if ![runto_main] then {
38 perror "couldn't run to breakpoint main"
42 # Test that koenig lookup finds correct function
43 gdb_test "p first(c)" "= 11"
45 # Change the number of parameters and position of
46 # the qualifying parameter
47 gdb_test "p second(0,0,c,0,0)" "= 33"
49 # Test that koenig lookup finds correct function
50 # even if it is overloaded
51 gdb_test "p first(0,c)" "= 22"
53 # Test that koenig lookup finds correct function
54 # when the argument is an expression
55 gdb_test "p first(b.c)" "= 11"
57 # test that resolutions can be made across namespaces
58 gdb_test "p foo(eo)" "= 1"
59 gdb_test "p foo(eo, eo)" "= 2"
60 gdb_test "p foo(eo, eo, 1)" "= 3"
61 gdb_test "p foo(fo, eo)" "= 4"
62 gdb_test "p foo(1 ,fo, eo)" "= 5"
63 gdb_test "p foo(go, fo, eo)" "= 6"
65 #test that gdb fails gracefully
66 gdb_test "p fake(eo)" "No symbol \"fake\" in current context."
67 gdb_test "p foo (fake)" "No symbol \"fake\" in current context."
69 #test that namespaces of base classes are searched
70 gdb_test "p foo(io)" "= 7"
71 gdb_test "p foo(ix)" "Cannot resolve function foo to any overloaded instance"
74 gdb_test "p foo(ju)" "= 8"
75 gdb_test "p foo(js)" "= 9"
76 gdb_test "p foo(je)" "= 10"
78 #test for class members
80 gdb_test "p foo(jab)" "= 11"
82 gdb_test "p foo(jap)" "= 12"
83 gdb_test "p foo(japp)" "= 13"
84 gdb_test "p foo(jca)" "= 14"
86 #test overload resolution
87 gdb_test "p foo(ko,1)" "= 15"
88 gdb_test "p foo(ko,1.0f)" "= 16"
90 gdb_test "p bar(ko,1)" "= -1"
92 #test lookup of objects belonging to nested namespaces
93 gdb_test "p foo(labo)" "= 17"
95 #test koenig found function do not compete with qualified
97 gdb_test "p ma.foo('a')" "= 18"
98 gdb_test "p foo(ma,'a')" "= 19"
99 gdb_test "p M::N::foo(ma,'a')" "= 20"
100 gdb_test "p M::FAKE::foo(ma,'a')" "No type \"FAKE\" within class or namespace \"M\"."
101 gdb_test "p M::N::fake(ma,'a')" "No symbol \"fake\" in namespace \"M::N\"."
103 gdb_test "p M::bar('a')" "= 21"
104 gdb_test "p M::N::bar('a')" "= 22"
106 #test that lookup supports typedef
107 gdb_test "p foo(ttoa, 'a')" "= 23"
109 #test that lookup is not thwarted by anonymous types
110 gdb_test "p foo (p_union)" \
111 "Cannot resolve function foo to any overloaded instance"