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