Commit | Line | Data |
---|---|---|
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 | ||
20 | if {$tracelevel} { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | if {[skip_cplus_tests]} { | |
25 | continue | |
26 | } | |
27 | ||
28 | set testfile "temargs" | |
29 | set srcfile "${testfile}.cc" | |
30 | ||
31 | if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { | |
32 | return -1 | |
33 | } | |
34 | ||
35 | if {![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. | |
42 | verbose -log "compiler_info: $compiler_info" | |
43 | set have_older_template_gcc 0 | |
d0e53741 TT |
44 | set have_pr_41736_fixed 1 |
45 | set have_pr_45024_fixed 1 | |
c98ee71b DE |
46 | if {[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 |
58 | set line [gdb_get_line_number "Breakpoint 1" $srcfile] |
59 | gdb_test "break $srcfile:$line" "Breakpoint 2.*" \ | |
60 | "set first breakpoint for temargs" | |
c98ee71b | 61 | |
34eaf542 TT |
62 | set line [gdb_get_line_number "Breakpoint 2" $srcfile] |
63 | gdb_test "break $srcfile:$line" "Breakpoint 3.*" \ | |
64 | "set second breakpoint for temargs" | |
c98ee71b | 65 | |
34eaf542 TT |
66 | set line [gdb_get_line_number "Breakpoint 3" $srcfile] |
67 | gdb_test "break $srcfile:$line" "Breakpoint 4.*" \ | |
68 | "set third breakpoint for temargs" | |
c98ee71b | 69 | |
34eaf542 TT |
70 | set line [gdb_get_line_number "Breakpoint 4" $srcfile] |
71 | gdb_test "break $srcfile:$line" "Breakpoint 5.*" \ | |
72 | "set fourth breakpoint for temargs" | |
73 | ||
d0e53741 TT |
74 | set line [gdb_get_line_number "Breakpoint 5" $srcfile] |
75 | gdb_test "break $srcfile:$line" "Breakpoint 6.*" \ | |
76 | "set fifth breakpoint for temargs" | |
77 | ||
85a20c42 JK |
78 | set line [gdb_get_line_number "Breakpoint 6" $srcfile] |
79 | gdb_test "break $srcfile:$line" "Breakpoint 7.*" \ | |
80 | "set sixth breakpoint for temargs" | |
81 | ||
34eaf542 TT |
82 | # |
83 | # Tests in Base::base_m. | |
84 | # | |
85 | ||
86 | gdb_continue_to_breakpoint "continue to first breakpoint for temargs" | |
87 | ||
c98ee71b | 88 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 89 | gdb_test "ptype T" "double" "test type of T in base_m" |
c98ee71b DE |
90 | |
91 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 92 | gdb_test "print I" " = 23" "test value of I in base_m" |
c98ee71b DE |
93 | |
94 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 95 | gdb_test "print P == &a_global" " = true" "test value of P in base_m" |
c98ee71b | 96 | |
d0e53741 | 97 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 TT |
98 | gdb_test "print MP" "&S::f" "test value of MP in base_m" |
99 | ||
100 | # | |
101 | # Tests in Inner::inner_m. | |
102 | # | |
103 | ||
104 | gdb_continue_to_breakpoint "continue to second breakpoint for temargs" | |
105 | ||
d0e53741 TT |
106 | |
107 | if {!$have_pr_45024_fixed} { setup_xfail *-*-* } | |
34eaf542 | 108 | gdb_test "ptype T" "long" "test type of T in inner_m" |
c98ee71b | 109 | |
d0e53741 | 110 | if {!$have_pr_45024_fixed} { setup_xfail *-*-* } |
34eaf542 | 111 | gdb_test "print I" " = 47" "test value of I in inner_m" |
c98ee71b DE |
112 | |
113 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 114 | gdb_test "print P == &a_global" " = true" "test value of P in inner_m" |
c98ee71b | 115 | |
d0e53741 | 116 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 | 117 | gdb_test "print MP" "&S::f" "test value of MP in inner_m" |
c98ee71b DE |
118 | |
119 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 TT |
120 | gdb_test "whatis Z" "float" "test type of Z in inner_m" |
121 | ||
122 | # | |
123 | # Tests in func. | |
124 | # | |
125 | ||
126 | gdb_continue_to_breakpoint "continue to third breakpoint for temargs" | |
127 | ||
c98ee71b | 128 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 129 | gdb_test "ptype T" "unsigned char" "test type of T in func" |
c98ee71b DE |
130 | |
131 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 132 | gdb_test "print I" " = 91" "test value of I in func" |
c98ee71b DE |
133 | |
134 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 135 | gdb_test "print P == &a_global" " = true" "test value of P in func" |
c98ee71b | 136 | |
d0e53741 | 137 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 TT |
138 | gdb_test "print MP" "&S::f" "test value of MP in func" |
139 | ||
140 | # | |
141 | # Tests in Base::templ_m. | |
142 | # | |
143 | ||
144 | gdb_continue_to_breakpoint "continue to fourth breakpoint for temargs" | |
145 | ||
c98ee71b | 146 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 147 | gdb_test "ptype T" "double" "test type of T in templ_m" |
c98ee71b DE |
148 | |
149 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 150 | gdb_test "print I" " = 23" "test value of I in templ_m" |
c98ee71b DE |
151 | |
152 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 153 | gdb_test "print P == &a_global" " = true" "test value of P in templ_m" |
c98ee71b | 154 | |
d0e53741 | 155 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 | 156 | gdb_test "print MP" "&S::f" "test value of MP in templ_m" |
c98ee71b DE |
157 | |
158 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 159 | gdb_test "whatis Q" "short" "test type of Q in templ_m" |
d0e53741 TT |
160 | |
161 | # | |
162 | # Tests in K2::k2_m. | |
163 | # | |
164 | ||
165 | gdb_continue_to_breakpoint "continue to fifth breakpoint for temargs" | |
166 | ||
167 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
168 | gdb_test "ptype F" "type = void \\\(S::\\\*\\\)\\\(S \\\* const\\\)" \ | |
169 | "test type of F in k2_m" | |
170 | ||
171 | setup_kfail gcc/49366 "*-*-*" | |
172 | gdb_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 | ||
181 | gdb_continue_to_breakpoint "continue to sixth breakpoint for temargs" | |
182 | ||
900e11f9 JK |
183 | if $have_older_template_gcc { setup_xfail "*-*-*" |
184 | } else { setup_kfail gcc/49546 "*-*-*" } | |
85a20c42 JK |
185 | gdb_test "ptype F" {type = void \(\*\)\(int\)} "test type of F in k3_m" |
186 | ||
900e11f9 JK |
187 | if $have_older_template_gcc { setup_xfail "*-*-*" |
188 | } else { setup_kfail gcc/49546 "*-*-*" } | |
85a20c42 JK |
189 | gdb_test "print F" { = \(void \(\*\)\(int\)\) 0x[0-9a-f]+ <S3::m\(int\)>} \ |
190 | "test value of F in k3_m" |