X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Ftestsuite%2Fgdb.cp%2Fconverts.exp;h=8a12de7dc0f9a4708ba0120aa4dd533e9aa61301;hb=e2882c85786571175a0b0bfc3bcd2f14620b1ea3;hp=4e4c2ea39ab861cba2078d135558f87f5e1d4510;hpb=026ffab798b81c8b752a5b277361efec7b96b564;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/testsuite/gdb.cp/converts.exp b/gdb/testsuite/gdb.cp/converts.exp index 4e4c2ea39a..8a12de7dc0 100644 --- a/gdb/testsuite/gdb.cp/converts.exp +++ b/gdb/testsuite/gdb.cp/converts.exp @@ -1,4 +1,4 @@ -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008-2018 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set testfile converts -set srcfile ${testfile}.cc -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } { +standard_testfile .cc + +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } { return -1 } @@ -49,3 +49,73 @@ gdb_test "p foo2_1 (b)" "= 21" "pointer pointer to pointer pointer" gdb_test "p foo2_2 (b)" "Cannot resolve.*" "pointer pointer to array of arrays" gdb_test "p foo2_3 (b)" "= 23" "pointer pointer to array of pointers" gdb_test "p foo2_4 (b)" "Cannot resolve.*" "pointer pointer to array of wrong pointers" + +gdb_test "p foo3_1 ((char *) 0, ta)" "Cannot resolve.*" \ + "check all parameters for badness" + +# Tests for null pointer conversion +global gdb_prompt +set nl {[\r\n]+} +set t "null pointer conversion" +gdb_test_multiple "p foo3_1 (0, 0)" $t { + -re "warning: Using non-standard conversion.*$nl$gdb_prompt $" { + fail "$t (warning issued)" + } + + -re "Cannot resolve function foo3_1 to any overloaded instance$nl$gdb_prompt $" { + fail "$t (conversion failed)" + } + + -re "\\$\[0-9\]+ = 31$nl$gdb_prompt $" { + pass $t + } +} + +gdb_test "p foo3_1 (0, 1)" \ + "Cannot resolve function foo3_1 to any overloaded instance" +gdb_test "p foo3_1 (0, (const char**) 1)" " = 31" +gdb_test "p foo3_2 (0, 0)" "= 32" +gdb_test "p foo3_2 (0, (char const**) 0)" " = 320" + +# Tests for boolean conversions allowed by the standard +gdb_test "p foo1_7(0)" " = 17" +gdb_test "p foo1_7(integer)" " = 17" +gdb_test "p foo1_7(long_int)" " = 17" +gdb_test "p foo1_7(*a)" " = 17" +gdb_test "p foo1_7(MY_A)" " = 17" +gdb_test "p foo1_7(&foo1_7)" " = 17" +gdb_test "p foo1_7(&A::member_)" " = 17" +gdb_test "p foo1_7(a)" " = 17" +gdb_test "p foo1_7(fp)" " = 17" +gdb_test "p foo1_7(dp)" " = 17" +gdb_test "p foo1_7(-1.23)" " = 17" +gdb_test "p foo1_7(ta)" \ + "Cannot resolve function foo1_7 to any overloaded instance" + +# Test for strict type checking +set error_str "Cannot resolve function %s to any overloaded instance" +gdb_test "show check type" "Strict type checking is on\." +gdb_test "p foo1_type_check (123)" [format $error_str "foo1_type_check"] +gdb_test "p foo2_type_check (0, 1)" [format $error_str "foo2_type_check"] +gdb_test "p foo2_type_check (1, 0)" [format $error_str "foo2_type_check"] +gdb_test "p foo2_type_check (1, 1)" [format $error_str "foo2_type_check"] +gdb_test "p foo3_type_check (0, 0, 1)" [format $error_str "foo3_type_check"] +gdb_test "p foo3_type_check (0, 1, 0)" [format $error_str "foo3_type_check"] +gdb_test "p foo3_type_check (1, 0, 0)" [format $error_str "foo3_type_check"] +gdb_test "p foo3_type_check (0, 1, 1)" [format $error_str "foo3_type_check"] +gdb_test "p foo3_type_check (1, 1, 0)" [format $error_str "foo3_type_check"] +gdb_test "p foo3_type_check (1, 1, 1)" [format $error_str "foo3_type_check"] + +gdb_test_no_output "set check type off" +gdb_test "show check type" "Strict type checking is off\." +gdb_test "p foo1_type_check (123)" " = 1000" +gdb_test "p foo2_type_check (0, 1)" " = 1001" +gdb_test "p foo2_type_check (1, 0)" " = 1001" +gdb_test "p foo2_type_check (1, 1)" " = 1001" +gdb_test "p foo3_type_check (0, 0, 1)" " = 1002" +gdb_test "p foo3_type_check (0, 1, 0)" " = 1002" +gdb_test "p foo3_type_check (1, 0, 0)" " = 1002" +gdb_test "p foo3_type_check (0, 1, 1)" " = 1002" +gdb_test "p foo3_type_check (1, 1, 0)" " = 1002" +gdb_test "p foo3_type_check (1, 1, 1)" " = 1002" +gdb_test "p foo3_2 (1,1)" " = 32"