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