* gold-threads.cc (Lock_impl_threads::Lock_impl_threads): Correct
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / koenig.exp
CommitLineData
7322dca9
SW
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
16if $tracelevel then {
17 strace $tracelevel
18}
19
7322dca9
SW
20set testfile koenig
21set srcfile ${testfile}.cc
22set binfile ${objdir}/${subdir}/${testfile}
23if { [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
30gdb_exit
31gdb_start
32gdb_reinitialize_dir $srcdir/$subdir
33gdb_load ${binfile}
34
35############################################
36
37if ![runto_main] then {
38 perror "couldn't run to breakpoint main"
39 continue
40}
41
42# Test that koenig lookup finds correct function
43gdb_test "p first(c)" "= 11"
44
45# Change the number of parameters and position of
46# the qualifying parameter
47gdb_test "p second(0,0,c,0,0)" "= 33"
48
49# Test that koenig lookup finds correct function
50# even if it is overloaded
51gdb_test "p first(0,c)" "= 22"
52
53# Test that koenig lookup finds correct function
54# when the argument is an expression
55gdb_test "p first(b.c)" "= 11"
56
57# test that resolutions can be made across namespaces
58gdb_test "p foo(eo)" "= 1"
59gdb_test "p foo(eo, eo)" "= 2"
60gdb_test "p foo(eo, eo, 1)" "= 3"
61gdb_test "p foo(fo, eo)" "= 4"
62gdb_test "p foo(1 ,fo, eo)" "= 5"
63gdb_test "p foo(go, fo, eo)" "= 6"
64
65#test that gdb fails gracefully
66gdb_test "p fake(eo)" "No symbol \"fake\" in current context."
7d3fe98e 67gdb_test "p foo (fake)" "No symbol \"fake\" in current context."
7322dca9
SW
68
69#test that namespaces of base classes are searched
70gdb_test "p foo(io)" "= 7"
71gdb_test "p foo(ix)" "Cannot resolve function foo to any overloaded instance"
72
73#test for other types
74gdb_test "p foo(ju)" "= 8"
75gdb_test "p foo(js)" "= 9"
76gdb_test "p foo(je)" "= 10"
77
78#test for class members
79setup_xfail "*-*-*"
80gdb_test "p foo(jab)" "= 11"
81
82gdb_test "p foo(jap)" "= 12"
83gdb_test "p foo(japp)" "= 13"
84gdb_test "p foo(jca)" "= 14"
85
86#test overload resolution
87gdb_test "p foo(ko,1)" "= 15"
88gdb_test "p foo(ko,1.0f)" "= 16"
89setup_xfail "*-*-*"
90gdb_test "p bar(ko,1)" "= -1"
91
92#test lookup of objects belonging to nested namespaces
93gdb_test "p foo(labo)" "= 17"
94
95#test koenig found function do not compete with qualified
96#names
97gdb_test "p ma.foo('a')" "= 18"
98gdb_test "p foo(ma,'a')" "= 19"
99gdb_test "p M::N::foo(ma,'a')" "= 20"
100gdb_test "p M::FAKE::foo(ma,'a')" "No type \"FAKE\" within class or namespace \"M\"."
101gdb_test "p M::N::fake(ma,'a')" "No symbol \"fake\" in namespace \"M::N\"."
102
103gdb_test "p M::bar('a')" "= 21"
104gdb_test "p M::N::bar('a')" "= 22"
105
106#test that lookup supports typedef
107gdb_test "p foo(ttoa, 'a')" "= 23"
7d3fe98e
SW
108
109#test that lookup is not thwarted by anonymous types
110gdb_test "p foo (p_union)" \
111 "Cannot resolve function foo to any overloaded instance"
This page took 0.038137 seconds and 4 git commands to generate.