1 1.11 christos # Copyright 2008-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos standard_testfile .cc 17 1.1 christos 18 1.7 christos if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } { 19 1.1 christos return -1 20 1.1 christos } 21 1.1 christos 22 1.1 christos ############################################ 23 1.1 christos 24 1.10 christos if {![runto_main]} { 25 1.10 christos return 26 1.1 christos } 27 1.1 christos 28 1.1 christos gdb_breakpoint [gdb_get_line_number "end of main"] 29 1.1 christos gdb_continue_to_breakpoint "end of main" 30 1.1 christos 31 1.1 christos gdb_test "p foo0_1 (ta)" "= 1" "typedef to another typedef" 32 1.1 christos gdb_test "p foo0_2 (ta)" "= 2" "typedef to typedef of a typedef" 33 1.1 christos gdb_test "p foo0_3 (bppp)" "Cannot resolve.*" \ 34 1.1 christos "Pointer-to-pointer-to-pointer derived to Pointer-to-pointer-to-pointer base." 35 1.1 christos 36 1.1 christos gdb_test "p foo1_1 (a)" "= 11" "pointer to pointer" 37 1.1 christos gdb_test "p foo1_2 (a)" "= 12" "pointer to array" 38 1.9 christos gdb_test "p foo1_3 (a)" "Cannot resolve.*" \ 39 1.9 christos "pointer to pointer of wrong type, a" 40 1.9 christos gdb_test "p foo1_3 (bp)" "Cannot resolve.*" \ 41 1.9 christos "pointer to pointer of wrong type, bp" 42 1.1 christos gdb_test "p foo1_4 (bp)" "= 14" "pointer to ancestor pointer" 43 1.1 christos gdb_test "p foo1_5 (bp)" "= 15" "pointer to void pointer" 44 1.1 christos gdb_test "p foo1_6 (bp)" "Cannot resolve.*" "pointer to void pointer pointer" 45 1.1 christos gdb_test "p foo1_7 (bp)" "= 17" "pointer to boolean" 46 1.1 christos gdb_test "p foo1_8 (bp)" "Using non-standard.*" "pointer to long int" 47 1.1 christos 48 1.1 christos gdb_test "p foo1_5 (b)" "= 15" "pointer pointer to void pointer" 49 1.1 christos gdb_test "p foo2_1 (b)" "= 21" "pointer pointer to pointer pointer" 50 1.1 christos gdb_test "p foo2_2 (b)" "Cannot resolve.*" "pointer pointer to array of arrays" 51 1.11 christos gdb_test "p foo2_2 (ba)" "= 22" "array of arrays to array of arrays" 52 1.1 christos gdb_test "p foo2_3 (b)" "= 23" "pointer pointer to array of pointers" 53 1.1 christos gdb_test "p foo2_4 (b)" "Cannot resolve.*" "pointer pointer to array of wrong pointers" 54 1.1 christos 55 1.1 christos gdb_test "p foo3_1 ((char *) 0, ta)" "Cannot resolve.*" \ 56 1.1 christos "check all parameters for badness" 57 1.1 christos 58 1.1 christos # Tests for null pointer conversion 59 1.1 christos global gdb_prompt 60 1.1 christos set nl {[\r\n]+} 61 1.1 christos set t "null pointer conversion" 62 1.1 christos gdb_test_multiple "p foo3_1 (0, 0)" $t { 63 1.1 christos -re "warning: Using non-standard conversion.*$nl$gdb_prompt $" { 64 1.1 christos fail "$t (warning issued)" 65 1.1 christos } 66 1.1 christos 67 1.1 christos -re "Cannot resolve function foo3_1 to any overloaded instance$nl$gdb_prompt $" { 68 1.1 christos fail "$t (conversion failed)" 69 1.1 christos } 70 1.1 christos 71 1.1 christos -re "\\$\[0-9\]+ = 31$nl$gdb_prompt $" { 72 1.1 christos pass $t 73 1.1 christos } 74 1.1 christos } 75 1.1 christos 76 1.1 christos gdb_test "p foo3_1 (0, 1)" \ 77 1.1 christos "Cannot resolve function foo3_1 to any overloaded instance" 78 1.1 christos gdb_test "p foo3_1 (0, (const char**) 1)" " = 31" 79 1.1 christos gdb_test "p foo3_2 (0, 0)" "= 32" 80 1.1 christos gdb_test "p foo3_2 (0, (char const**) 0)" " = 320" 81 1.1 christos 82 1.1 christos # Tests for boolean conversions allowed by the standard 83 1.1 christos gdb_test "p foo1_7(0)" " = 17" 84 1.1 christos gdb_test "p foo1_7(integer)" " = 17" 85 1.1 christos gdb_test "p foo1_7(long_int)" " = 17" 86 1.1 christos gdb_test "p foo1_7(*a)" " = 17" 87 1.1 christos gdb_test "p foo1_7(MY_A)" " = 17" 88 1.1 christos gdb_test "p foo1_7(&foo1_7)" " = 17" 89 1.1 christos gdb_test "p foo1_7(&A::member_)" " = 17" 90 1.1 christos gdb_test "p foo1_7(a)" " = 17" 91 1.1 christos gdb_test "p foo1_7(fp)" " = 17" 92 1.1 christos gdb_test "p foo1_7(dp)" " = 17" 93 1.1 christos gdb_test "p foo1_7(-1.23)" " = 17" 94 1.1 christos gdb_test "p foo1_7(ta)" \ 95 1.1 christos "Cannot resolve function foo1_7 to any overloaded instance" 96 1.1 christos 97 1.1 christos # Test for strict type checking 98 1.1 christos set error_str "Cannot resolve function %s to any overloaded instance" 99 1.9 christos gdb_test "show check type" "Strict type checking is on\." \ 100 1.9 christos "confirm check type on" 101 1.9 christos 102 1.9 christos with_test_prefix "strict type checking on" { 103 1.9 christos gdb_test "p foo1_type_check (123)" [format $error_str "foo1_type_check"] 104 1.9 christos gdb_test "p foo2_type_check (0, 1)" [format $error_str "foo2_type_check"] 105 1.9 christos gdb_test "p foo2_type_check (1, 0)" [format $error_str "foo2_type_check"] 106 1.9 christos gdb_test "p foo2_type_check (1, 1)" [format $error_str "foo2_type_check"] 107 1.9 christos gdb_test "p foo3_type_check (0, 0, 1)" [format $error_str "foo3_type_check"] 108 1.9 christos gdb_test "p foo3_type_check (0, 1, 0)" [format $error_str "foo3_type_check"] 109 1.9 christos gdb_test "p foo3_type_check (1, 0, 0)" [format $error_str "foo3_type_check"] 110 1.9 christos gdb_test "p foo3_type_check (0, 1, 1)" [format $error_str "foo3_type_check"] 111 1.9 christos gdb_test "p foo3_type_check (1, 1, 0)" [format $error_str "foo3_type_check"] 112 1.9 christos gdb_test "p foo3_type_check (1, 1, 1)" [format $error_str "foo3_type_check"] 113 1.9 christos } 114 1.1 christos 115 1.1 christos gdb_test_no_output "set check type off" 116 1.9 christos gdb_test "show check type" "Strict type checking is off\." \ 117 1.9 christos "confirm check type off" 118 1.9 christos 119 1.9 christos with_test_prefix "strict type checking off" { 120 1.9 christos gdb_test "p foo1_type_check (123)" " = 1000" 121 1.9 christos gdb_test "p foo2_type_check (0, 1)" " = 1001" 122 1.9 christos gdb_test "p foo2_type_check (1, 0)" " = 1001" 123 1.9 christos gdb_test "p foo2_type_check (1, 1)" " = 1001" 124 1.9 christos gdb_test "p foo3_type_check (0, 0, 1)" " = 1002" 125 1.9 christos gdb_test "p foo3_type_check (0, 1, 0)" " = 1002" 126 1.9 christos gdb_test "p foo3_type_check (1, 0, 0)" " = 1002" 127 1.9 christos gdb_test "p foo3_type_check (0, 1, 1)" " = 1002" 128 1.9 christos gdb_test "p foo3_type_check (1, 1, 0)" " = 1002" 129 1.9 christos gdb_test "p foo3_type_check (1, 1, 1)" " = 1002" 130 1.9 christos gdb_test "p foo3_2 (1,1)" " = 32" 131 1.9 christos } 132