Fix ADL anonymous name crash.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / koenig.exp
1 # Copyright 2008 Free Software Foundation, Inc.
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
16 if $tracelevel then {
17 strace $tracelevel
18 }
19
20 set testfile koenig
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"
25 return -1
26 }
27
28 # Get things started.
29
30 gdb_exit
31 gdb_start
32 gdb_reinitialize_dir $srcdir/$subdir
33 gdb_load ${binfile}
34
35 ############################################
36
37 if ![runto_main] then {
38 perror "couldn't run to breakpoint main"
39 continue
40 }
41
42 # Test that koenig lookup finds correct function
43 gdb_test "p first(c)" "= 11"
44
45 # Change the number of parameters and position of
46 # the qualifying parameter
47 gdb_test "p second(0,0,c,0,0)" "= 33"
48
49 # Test that koenig lookup finds correct function
50 # even if it is overloaded
51 gdb_test "p first(0,c)" "= 22"
52
53 # Test that koenig lookup finds correct function
54 # when the argument is an expression
55 gdb_test "p first(b.c)" "= 11"
56
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"
64
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."
68
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"
72
73 #test for other types
74 gdb_test "p foo(ju)" "= 8"
75 gdb_test "p foo(js)" "= 9"
76 gdb_test "p foo(je)" "= 10"
77
78 #test for class members
79 setup_xfail "*-*-*"
80 gdb_test "p foo(jab)" "= 11"
81
82 gdb_test "p foo(jap)" "= 12"
83 gdb_test "p foo(japp)" "= 13"
84 gdb_test "p foo(jca)" "= 14"
85
86 #test overload resolution
87 gdb_test "p foo(ko,1)" "= 15"
88 gdb_test "p foo(ko,1.0f)" "= 16"
89 setup_xfail "*-*-*"
90 gdb_test "p bar(ko,1)" "= -1"
91
92 #test lookup of objects belonging to nested namespaces
93 gdb_test "p foo(labo)" "= 17"
94
95 #test koenig found function do not compete with qualified
96 #names
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\"."
102
103 gdb_test "p M::bar('a')" "= 21"
104 gdb_test "p M::N::bar('a')" "= 22"
105
106 #test that lookup supports typedef
107 gdb_test "p foo(ttoa, 'a')" "= 23"
108
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"
This page took 0.033962 seconds and 5 git commands to generate.