]>
Commit | Line | Data |
---|---|---|
34eaf542 TT |
1 | # temargs.exp - Template argument tests |
2 | # | |
e2882c85 | 3 | # Copyright 2010-2018 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 | ||
34eaf542 TT |
20 | if {[skip_cplus_tests]} { |
21 | continue | |
22 | } | |
23 | ||
f5f3a911 | 24 | standard_testfile .cc |
34eaf542 | 25 | |
5b362f04 | 26 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
34eaf542 TT |
27 | return -1 |
28 | } | |
29 | ||
30 | if {![runto_main]} { | |
31 | return -1 | |
32 | } | |
33 | ||
c98ee71b DE |
34 | # NOTE: prepare_for_testing calls get_compiler_info, which we need |
35 | # for the test_compiler_info calls. | |
36 | # gcc 4.4 and earlier don't emit enough info for some of our template tests. | |
c98ee71b | 37 | set have_older_template_gcc 0 |
d0e53741 TT |
38 | set have_pr_41736_fixed 1 |
39 | set have_pr_45024_fixed 1 | |
c98ee71b DE |
40 | if {[test_compiler_info {gcc-[0-3]-*}] |
41 | || [test_compiler_info {gcc-4-[0-4]-*}]} { | |
42 | set have_older_template_gcc 1 | |
d0e53741 TT |
43 | set have_pr_41736_fixed 0 |
44 | set have_pr_45024_fixed 0 | |
45 | } elseif {[test_compiler_info {gcc-4-5-*}]} { | |
46 | set have_pr_41736_fixed 0 | |
47 | set have_pr_45024_fixed 0 | |
c98ee71b DE |
48 | } |
49 | ||
34eaf542 TT |
50 | set line [gdb_get_line_number "Breakpoint 1" $srcfile] |
51 | gdb_test "break $srcfile:$line" "Breakpoint 2.*" \ | |
52 | "set first breakpoint for temargs" | |
c98ee71b | 53 | |
34eaf542 TT |
54 | set line [gdb_get_line_number "Breakpoint 2" $srcfile] |
55 | gdb_test "break $srcfile:$line" "Breakpoint 3.*" \ | |
56 | "set second breakpoint for temargs" | |
c98ee71b | 57 | |
34eaf542 TT |
58 | set line [gdb_get_line_number "Breakpoint 3" $srcfile] |
59 | gdb_test "break $srcfile:$line" "Breakpoint 4.*" \ | |
60 | "set third breakpoint for temargs" | |
c98ee71b | 61 | |
34eaf542 TT |
62 | set line [gdb_get_line_number "Breakpoint 4" $srcfile] |
63 | gdb_test "break $srcfile:$line" "Breakpoint 5.*" \ | |
64 | "set fourth breakpoint for temargs" | |
65 | ||
d0e53741 TT |
66 | set line [gdb_get_line_number "Breakpoint 5" $srcfile] |
67 | gdb_test "break $srcfile:$line" "Breakpoint 6.*" \ | |
68 | "set fifth breakpoint for temargs" | |
69 | ||
85a20c42 JK |
70 | set line [gdb_get_line_number "Breakpoint 6" $srcfile] |
71 | gdb_test "break $srcfile:$line" "Breakpoint 7.*" \ | |
72 | "set sixth breakpoint for temargs" | |
73 | ||
34eaf542 TT |
74 | # |
75 | # Tests in Base::base_m. | |
76 | # | |
77 | ||
78 | gdb_continue_to_breakpoint "continue to first breakpoint for temargs" | |
79 | ||
c98ee71b | 80 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 81 | gdb_test "ptype T" "double" "test type of T in base_m" |
c98ee71b DE |
82 | |
83 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 84 | gdb_test "print I" " = 23" "test value of I in base_m" |
c98ee71b DE |
85 | |
86 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 87 | gdb_test "print P == &a_global" " = true" "test value of P in base_m" |
c98ee71b | 88 | |
d0e53741 | 89 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 TT |
90 | gdb_test "print MP" "&S::f" "test value of MP in base_m" |
91 | ||
92 | # | |
93 | # Tests in Inner::inner_m. | |
94 | # | |
95 | ||
96 | gdb_continue_to_breakpoint "continue to second breakpoint for temargs" | |
97 | ||
d0e53741 TT |
98 | |
99 | if {!$have_pr_45024_fixed} { setup_xfail *-*-* } | |
34eaf542 | 100 | gdb_test "ptype T" "long" "test type of T in inner_m" |
c98ee71b | 101 | |
d0e53741 | 102 | if {!$have_pr_45024_fixed} { setup_xfail *-*-* } |
34eaf542 | 103 | gdb_test "print I" " = 47" "test value of I in inner_m" |
c98ee71b | 104 | |
e17476d7 JK |
105 | if $have_older_template_gcc { setup_xfail "*-*-*" |
106 | } elseif {[test_compiler_info {gcc-[0-3]-*}] | |
107 | || [test_compiler_info {gcc-4-[0-5]-*}]} { | |
108 | # gcc-4.5.x still does not emit inner DW_TAG_structure_type. | |
109 | setup_xfail "*-*-*" | |
110 | } | |
34eaf542 | 111 | gdb_test "print P == &a_global" " = true" "test value of P in inner_m" |
c98ee71b | 112 | |
d0e53741 | 113 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 | 114 | gdb_test "print MP" "&S::f" "test value of MP in inner_m" |
c98ee71b | 115 | |
e17476d7 JK |
116 | if $have_older_template_gcc { setup_xfail "*-*-*" |
117 | } elseif {[test_compiler_info {gcc-[0-3]-*}] | |
118 | || [test_compiler_info {gcc-4-[0-5]-*}]} { | |
119 | # gcc-4.5.x still does not emit outer DW_TAG_structure_type. | |
120 | setup_xfail "*-*-*" | |
121 | } | |
34eaf542 TT |
122 | gdb_test "whatis Z" "float" "test type of Z in inner_m" |
123 | ||
124 | # | |
125 | # Tests in func. | |
126 | # | |
127 | ||
128 | gdb_continue_to_breakpoint "continue to third breakpoint for temargs" | |
129 | ||
c98ee71b | 130 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 131 | gdb_test "ptype T" "unsigned char" "test type of T in func" |
c98ee71b DE |
132 | |
133 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 134 | gdb_test "print I" " = 91" "test value of I in func" |
c98ee71b | 135 | |
3e1d3d8c TT |
136 | # PR symtab/16842 - gdb used to crash here. |
137 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
138 | gdb_test "info addr I" "Symbol \"I\" is constant." "test address of I in templ_m" | |
139 | ||
c98ee71b | 140 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 141 | gdb_test "print P == &a_global" " = true" "test value of P in func" |
c98ee71b | 142 | |
d0e53741 | 143 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 TT |
144 | gdb_test "print MP" "&S::f" "test value of MP in func" |
145 | ||
146 | # | |
147 | # Tests in Base::templ_m. | |
148 | # | |
149 | ||
150 | gdb_continue_to_breakpoint "continue to fourth breakpoint for temargs" | |
151 | ||
c98ee71b | 152 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 153 | gdb_test "ptype T" "double" "test type of T in templ_m" |
c98ee71b DE |
154 | |
155 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 156 | gdb_test "print I" " = 23" "test value of I in templ_m" |
c98ee71b | 157 | |
3e1d3d8c TT |
158 | # PR symtab/16842 - gdb used to crash here. |
159 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
160 | gdb_test "info addr I" "Symbol \"I\" is constant." "test address of I in templ_m" | |
161 | ||
c98ee71b | 162 | if $have_older_template_gcc { setup_xfail "*-*-*" } |
34eaf542 | 163 | gdb_test "print P == &a_global" " = true" "test value of P in templ_m" |
c98ee71b | 164 | |
d0e53741 | 165 | if {!$have_pr_41736_fixed} { setup_xfail *-*-* } |
34eaf542 | 166 | gdb_test "print MP" "&S::f" "test value of MP in templ_m" |
c98ee71b DE |
167 | |
168 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
34eaf542 | 169 | gdb_test "whatis Q" "short" "test type of Q in templ_m" |
d0e53741 TT |
170 | |
171 | # | |
172 | # Tests in K2::k2_m. | |
173 | # | |
174 | ||
175 | gdb_continue_to_breakpoint "continue to fifth breakpoint for temargs" | |
176 | ||
177 | if $have_older_template_gcc { setup_xfail "*-*-*" } | |
178 | gdb_test "ptype F" "type = void \\\(S::\\\*\\\)\\\(S \\\* const\\\)" \ | |
179 | "test type of F in k2_m" | |
180 | ||
13ac8d2c | 181 | setup_xfail gcc/49366 "*-*-*" |
d0e53741 | 182 | gdb_test "print F" "&S::somefunc" "test value of F in k2_m" |
85a20c42 JK |
183 | |
184 | # | |
185 | # Tests in K3::k3_m, GCC PR debug/49546. | |
186 | # The problem reproduces with DW_AT_MIPS_linkage_name. It does not happen with | |
187 | # GDB physname - GDB's own computation of the linkage name based on | |
188 | # (incorrectly output by GCC) DW_AT_name. | |
189 | # | |
190 | ||
191 | gdb_continue_to_breakpoint "continue to sixth breakpoint for temargs" | |
192 | ||
900e11f9 | 193 | if $have_older_template_gcc { setup_xfail "*-*-*" |
13ac8d2c | 194 | } else { setup_xfail gcc/49546 "*-*-*" } |
85a20c42 JK |
195 | gdb_test "ptype F" {type = void \(\*\)\(int\)} "test type of F in k3_m" |
196 | ||
900e11f9 | 197 | if $have_older_template_gcc { setup_xfail "*-*-*" |
13ac8d2c | 198 | } else { setup_xfail gcc/49546 "*-*-*" } |
85a20c42 JK |
199 | gdb_test "print F" { = \(void \(\*\)\(int\)\) 0x[0-9a-f]+ <S3::m\(int\)>} \ |
200 | "test value of F in k3_m" |