gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / temargs.exp
CommitLineData
34eaf542
TT
1# temargs.exp - Template argument tests
2#
7b6bb8da 3# Copyright 2010, 2011 Free Software Foundation, Inc.
34eaf542
TT
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18# This file is part of the gdb testsuite.
19
20if {$tracelevel} {
21 strace $tracelevel
22}
23
24if {[skip_cplus_tests]} {
25 continue
26}
27
28set testfile "temargs"
29set srcfile "${testfile}.cc"
30
31if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
32 return -1
33}
34
35if {![runto_main]} {
36 return -1
37}
38
c98ee71b
DE
39# NOTE: prepare_for_testing calls get_compiler_info, which we need
40# for the test_compiler_info calls.
41# gcc 4.4 and earlier don't emit enough info for some of our template tests.
42verbose -log "compiler_info: $compiler_info"
43set have_older_template_gcc 0
d0e53741
TT
44set have_pr_41736_fixed 1
45set have_pr_45024_fixed 1
c98ee71b
DE
46if {[test_compiler_info {gcc-[0-3]-*}]
47 || [test_compiler_info {gcc-4-[0-4]-*}]} {
48 set have_older_template_gcc 1
d0e53741
TT
49 set have_pr_41736_fixed 0
50 set have_pr_45024_fixed 0
51} elseif {[test_compiler_info {gcc-4-5-*}]} {
52 set have_pr_41736_fixed 0
53 set have_pr_45024_fixed 0
54} elseif {[test_compiler_info {gcc-4-6-*}]} {
55 set have_pr_45024_fixed 0
c98ee71b
DE
56}
57
34eaf542
TT
58set line [gdb_get_line_number "Breakpoint 1" $srcfile]
59gdb_test "break $srcfile:$line" "Breakpoint 2.*" \
60 "set first breakpoint for temargs"
c98ee71b 61
34eaf542
TT
62set line [gdb_get_line_number "Breakpoint 2" $srcfile]
63gdb_test "break $srcfile:$line" "Breakpoint 3.*" \
64 "set second breakpoint for temargs"
c98ee71b 65
34eaf542
TT
66set line [gdb_get_line_number "Breakpoint 3" $srcfile]
67gdb_test "break $srcfile:$line" "Breakpoint 4.*" \
68 "set third breakpoint for temargs"
c98ee71b 69
34eaf542
TT
70set line [gdb_get_line_number "Breakpoint 4" $srcfile]
71gdb_test "break $srcfile:$line" "Breakpoint 5.*" \
72 "set fourth breakpoint for temargs"
73
d0e53741
TT
74set line [gdb_get_line_number "Breakpoint 5" $srcfile]
75gdb_test "break $srcfile:$line" "Breakpoint 6.*" \
76 "set fifth breakpoint for temargs"
77
85a20c42
JK
78set line [gdb_get_line_number "Breakpoint 6" $srcfile]
79gdb_test "break $srcfile:$line" "Breakpoint 7.*" \
80 "set sixth breakpoint for temargs"
81
34eaf542
TT
82#
83# Tests in Base::base_m.
84#
85
86gdb_continue_to_breakpoint "continue to first breakpoint for temargs"
87
c98ee71b 88if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 89gdb_test "ptype T" "double" "test type of T in base_m"
c98ee71b
DE
90
91if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 92gdb_test "print I" " = 23" "test value of I in base_m"
c98ee71b
DE
93
94if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 95gdb_test "print P == &a_global" " = true" "test value of P in base_m"
c98ee71b 96
d0e53741 97if {!$have_pr_41736_fixed} { setup_xfail *-*-* }
34eaf542
TT
98gdb_test "print MP" "&S::f" "test value of MP in base_m"
99
100#
101# Tests in Inner::inner_m.
102#
103
104gdb_continue_to_breakpoint "continue to second breakpoint for temargs"
105
d0e53741
TT
106
107if {!$have_pr_45024_fixed} { setup_xfail *-*-* }
34eaf542 108gdb_test "ptype T" "long" "test type of T in inner_m"
c98ee71b 109
d0e53741 110if {!$have_pr_45024_fixed} { setup_xfail *-*-* }
34eaf542 111gdb_test "print I" " = 47" "test value of I in inner_m"
c98ee71b
DE
112
113if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 114gdb_test "print P == &a_global" " = true" "test value of P in inner_m"
c98ee71b 115
d0e53741 116if {!$have_pr_41736_fixed} { setup_xfail *-*-* }
34eaf542 117gdb_test "print MP" "&S::f" "test value of MP in inner_m"
c98ee71b
DE
118
119if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542
TT
120gdb_test "whatis Z" "float" "test type of Z in inner_m"
121
122#
123# Tests in func.
124#
125
126gdb_continue_to_breakpoint "continue to third breakpoint for temargs"
127
c98ee71b 128if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 129gdb_test "ptype T" "unsigned char" "test type of T in func"
c98ee71b
DE
130
131if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 132gdb_test "print I" " = 91" "test value of I in func"
c98ee71b
DE
133
134if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 135gdb_test "print P == &a_global" " = true" "test value of P in func"
c98ee71b 136
d0e53741 137if {!$have_pr_41736_fixed} { setup_xfail *-*-* }
34eaf542
TT
138gdb_test "print MP" "&S::f" "test value of MP in func"
139
140#
141# Tests in Base::templ_m.
142#
143
144gdb_continue_to_breakpoint "continue to fourth breakpoint for temargs"
145
c98ee71b 146if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 147gdb_test "ptype T" "double" "test type of T in templ_m"
c98ee71b
DE
148
149if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 150gdb_test "print I" " = 23" "test value of I in templ_m"
c98ee71b
DE
151
152if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 153gdb_test "print P == &a_global" " = true" "test value of P in templ_m"
c98ee71b 154
d0e53741 155if {!$have_pr_41736_fixed} { setup_xfail *-*-* }
34eaf542 156gdb_test "print MP" "&S::f" "test value of MP in templ_m"
c98ee71b
DE
157
158if $have_older_template_gcc { setup_xfail "*-*-*" }
34eaf542 159gdb_test "whatis Q" "short" "test type of Q in templ_m"
d0e53741
TT
160
161#
162# Tests in K2::k2_m.
163#
164
165gdb_continue_to_breakpoint "continue to fifth breakpoint for temargs"
166
167if $have_older_template_gcc { setup_xfail "*-*-*" }
168gdb_test "ptype F" "type = void \\\(S::\\\*\\\)\\\(S \\\* const\\\)" \
169 "test type of F in k2_m"
170
171setup_kfail gcc/49366 "*-*-*"
172gdb_test "print F" "&S::somefunc" "test value of F in k2_m"
85a20c42
JK
173
174#
175# Tests in K3::k3_m, GCC PR debug/49546.
176# The problem reproduces with DW_AT_MIPS_linkage_name. It does not happen with
177# GDB physname - GDB's own computation of the linkage name based on
178# (incorrectly output by GCC) DW_AT_name.
179#
180
181gdb_continue_to_breakpoint "continue to sixth breakpoint for temargs"
182
900e11f9
JK
183if $have_older_template_gcc { setup_xfail "*-*-*"
184} else { setup_kfail gcc/49546 "*-*-*" }
85a20c42
JK
185gdb_test "ptype F" {type = void \(\*\)\(int\)} "test type of F in k3_m"
186
900e11f9
JK
187if $have_older_template_gcc { setup_xfail "*-*-*"
188} else { setup_kfail gcc/49546 "*-*-*" }
85a20c42
JK
189gdb_test "print F" { = \(void \(\*\)\(int\)\) 0x[0-9a-f]+ <S3::m\(int\)>} \
190 "test value of F in k3_m"
This page took 0.144768 seconds and 4 git commands to generate.