2010-01-27 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / namespace-using.exp
CommitLineData
4c38e0a4 1# Copyright 2008, 2010 Free Software Foundation, Inc.
27aa8d6a
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
16if $tracelevel then {
17 strace $tracelevel
18}
19
20set prms_id 0
21set bug_id 0
22
23set testfile namespace-using
24set srcfile ${testfile}.cc
25set binfile ${objdir}/${subdir}/${testfile}
26if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
27 untested "Couldn't compile test program"
28 return -1
29}
30
8540c487
SW
31if [get_compiler_info ${binfile}] {
32 return -1
33}
34
35
27aa8d6a
SW
36# Get things started.
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43############################################
44# test printing of namespace imported within
45# the function.
46
47if ![runto_main] then {
48 perror "couldn't run to breakpoint main"
49 continue
50}
51
52gdb_test "print _a" "= 1"
53
54############################################
55# test printing of namespace imported into
56# a scope containing the pc.
57
58gdb_breakpoint [gdb_get_line_number "marker1 stop"]
59gdb_continue_to_breakpoint "marker1 stop"
60
61gdb_test "print _a" "= 1" "print _a in a nested scope"
62
63############################################
64# Test printing of namespace aliases
65
66setup_kfail "gdb/7935" "*-*-*"
67if ![runto marker2] then {
68 perror "couldn't run to breakpoint marker2"
69 continue
70}
71
72gdb_test "print B::a" "= 1"
73
74############################################
75# Test that names are not printed when they
76# are not imported
77
78gdb_breakpoint "marker3"
79gdb_continue_to_breakpoint "marker3"
80
8540c487
SW
81# gcc-4-3 puts import statements for aliases in
82# the global scope instead of the corresponding
83# function scope. These wrong import statements throw
84# this test off. This is fixed in gcc-4-4.
85if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* }
86
87gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import"
27aa8d6a
SW
88
89############################################
90# Test printing of individually imported elements
91
92setup_kfail "gdb/7936" "*-*-*"
93if ![runto marker4] then {
94 perror "couldn't run to breakpoint marker4"
95 continue
96}
97
98gdb_test "print x" "= 2"
8540c487
SW
99
100############################################
101# test printing of namespace imported into
102# file scope.
103
104if ![runto marker5] then {
105 perror "couldn't run to marker5"
106 continue
107}
108
109gdb_test "print cc" "= 3"
110
111############################################
112# test printing of namespace imported into
113# file scope.
114
115if ![runto PQ::marker6] then {
116 perror "couldn't run to PQ::marker6"
117 continue
118}
119
120gdb_test "print ox" "No symbol \"ox\" in current context."
This page took 0.093314 seconds and 4 git commands to generate.