]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/converts.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / converts.exp
CommitLineData
618f726f 1# Copyright 2008-2016 Free Software Foundation, Inc.
7062b0a0
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
f5f3a911
TT
16standard_testfile .cc
17
7062b0a0
SW
18if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
19 return -1
20}
21
22############################################
23
24if ![runto_main] then {
25 perror "couldn't run to breakpoint main"
26 continue
27}
28
29gdb_breakpoint [gdb_get_line_number "end of main"]
30gdb_continue_to_breakpoint "end of main"
31
32gdb_test "p foo0_1 (ta)" "= 1" "typedef to another typedef"
33gdb_test "p foo0_2 (ta)" "= 2" "typedef to typedef of a typedef"
34gdb_test "p foo0_3 (bppp)" "Cannot resolve.*" \
35 "Pointer-to-pointer-to-pointer derived to Pointer-to-pointer-to-pointer base."
36
37gdb_test "p foo1_1 (a)" "= 11" "pointer to pointer"
38gdb_test "p foo1_2 (a)" "= 12" "pointer to array"
39gdb_test "p foo1_3 (a)" "Cannot resolve.*" "pointer to pointer of wrong type"
40gdb_test "p foo1_3 (bp)" "Cannot resolve.*" "pointer to pointer of wrong type"
41gdb_test "p foo1_4 (bp)" "= 14" "pointer to ancestor pointer"
42gdb_test "p foo1_5 (bp)" "= 15" "pointer to void pointer"
026ffab7
SW
43gdb_test "p foo1_6 (bp)" "Cannot resolve.*" "pointer to void pointer pointer"
44gdb_test "p foo1_7 (bp)" "= 17" "pointer to boolean"
45gdb_test "p foo1_8 (bp)" "Using non-standard.*" "pointer to long int"
7062b0a0
SW
46
47gdb_test "p foo1_5 (b)" "= 15" "pointer pointer to void pointer"
48gdb_test "p foo2_1 (b)" "= 21" "pointer pointer to pointer pointer"
49gdb_test "p foo2_2 (b)" "Cannot resolve.*" "pointer pointer to array of arrays"
50gdb_test "p foo2_3 (b)" "= 23" "pointer pointer to array of pointers"
51gdb_test "p foo2_4 (b)" "Cannot resolve.*" "pointer pointer to array of wrong pointers"
6501c2fc
KS
52
53gdb_test "p foo3_1 ((char *) 0, ta)" "Cannot resolve.*" \
54 "check all parameters for badness"
55
56# Tests for null pointer conversion
57global gdb_prompt
58set nl {[\r\n]+}
59set t "null pointer conversion"
60gdb_test_multiple "p foo3_1 (0, 0)" $t {
61 -re "warning: Using non-standard conversion.*$nl$gdb_prompt $" {
62 fail "$t (warning issued)"
63 }
64
65 -re "Cannot resolve function foo3_1 to any overloaded instance$nl$gdb_prompt $" {
66 fail "$t (conversion failed)"
67 }
68
69 -re "\\$\[0-9\]+ = 31$nl$gdb_prompt $" {
70 pass $t
71 }
72}
a451cb65 73
6501c2fc
KS
74gdb_test "p foo3_1 (0, 1)" \
75 "Cannot resolve function foo3_1 to any overloaded instance"
76gdb_test "p foo3_1 (0, (const char**) 1)" " = 31"
77gdb_test "p foo3_2 (0, 0)" "= 32"
78gdb_test "p foo3_2 (0, (char const**) 0)" " = 320"
79
5b4f6e25
KS
80# Tests for boolean conversions allowed by the standard
81gdb_test "p foo1_7(0)" " = 17"
82gdb_test "p foo1_7(integer)" " = 17"
83gdb_test "p foo1_7(long_int)" " = 17"
84gdb_test "p foo1_7(*a)" " = 17"
85gdb_test "p foo1_7(MY_A)" " = 17"
86gdb_test "p foo1_7(&foo1_7)" " = 17"
87gdb_test "p foo1_7(&A::member_)" " = 17"
88gdb_test "p foo1_7(a)" " = 17"
89gdb_test "p foo1_7(fp)" " = 17"
90gdb_test "p foo1_7(dp)" " = 17"
91gdb_test "p foo1_7(-1.23)" " = 17"
92gdb_test "p foo1_7(ta)" \
93 "Cannot resolve function foo1_7 to any overloaded instance"
94
a451cb65
KS
95# Test for strict type checking
96set error_str "Cannot resolve function %s to any overloaded instance"
97gdb_test "show check type" "Strict type checking is on\."
98gdb_test "p foo1_type_check (123)" [format $error_str "foo1_type_check"]
99gdb_test "p foo2_type_check (0, 1)" [format $error_str "foo2_type_check"]
100gdb_test "p foo2_type_check (1, 0)" [format $error_str "foo2_type_check"]
101gdb_test "p foo2_type_check (1, 1)" [format $error_str "foo2_type_check"]
102gdb_test "p foo3_type_check (0, 0, 1)" [format $error_str "foo3_type_check"]
103gdb_test "p foo3_type_check (0, 1, 0)" [format $error_str "foo3_type_check"]
104gdb_test "p foo3_type_check (1, 0, 0)" [format $error_str "foo3_type_check"]
105gdb_test "p foo3_type_check (0, 1, 1)" [format $error_str "foo3_type_check"]
106gdb_test "p foo3_type_check (1, 1, 0)" [format $error_str "foo3_type_check"]
107gdb_test "p foo3_type_check (1, 1, 1)" [format $error_str "foo3_type_check"]
108
109gdb_test_no_output "set check type off"
110gdb_test "show check type" "Strict type checking is off\."
111gdb_test "p foo1_type_check (123)" " = 1000"
112gdb_test "p foo2_type_check (0, 1)" " = 1001"
113gdb_test "p foo2_type_check (1, 0)" " = 1001"
114gdb_test "p foo2_type_check (1, 1)" " = 1001"
115gdb_test "p foo3_type_check (0, 0, 1)" " = 1002"
116gdb_test "p foo3_type_check (0, 1, 0)" " = 1002"
117gdb_test "p foo3_type_check (1, 0, 0)" " = 1002"
118gdb_test "p foo3_type_check (0, 1, 1)" " = 1002"
119gdb_test "p foo3_type_check (1, 1, 0)" " = 1002"
120gdb_test "p foo3_type_check (1, 1, 1)" " = 1002"
121gdb_test "p foo3_2 (1,1)" " = 32"