From 6501c2fce12bc44b5759a33c2c7259cfdb4169e1 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Fri, 14 Oct 2011 20:22:50 +0000 Subject: PR c++/13225 * gdb.cp/converts.cc (foo3_1): New function. (foo3_2): New functions. * gdb.cp/converts.exp: Add tests for int to pointer conversion and null pointer conversions of integer constant zero. Add test to check if all arguments are checked for incompatible conversion BADNESS. --- gdb/testsuite/ChangeLog | 10 ++++++++++ gdb/testsuite/gdb.cp/converts.cc | 9 +++++++++ gdb/testsuite/gdb.cp/converts.exp | 27 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2786a53..1de5d3c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2011-10-14 Keith Seitz + + PR c++/13225 + * gdb.cp/converts.cc (foo3_1): New function. + (foo3_2): New functions. + * gdb.cp/converts.exp: Add tests for int to pointer conversion + and null pointer conversions of integer constant zero. + Add test to check if all arguments are checked for incompatible + conversion BADNESS. + 2011-10-14 Tom Tromey * gdb.threads/attachstop-mt.exp: Add $srcfile to the linespecs. diff --git a/gdb/testsuite/gdb.cp/converts.cc b/gdb/testsuite/gdb.cp/converts.cc index 34b6927..26a45f5 100644 --- a/gdb/testsuite/gdb.cp/converts.cc +++ b/gdb/testsuite/gdb.cp/converts.cc @@ -23,6 +23,10 @@ int foo2_2 (char[][1]) {return 22;} int foo2_3 (char *[]) {return 23;} int foo2_4 (int *[]) {return 24;} +int foo3_1 (int a, const char **b) { return 31; } +int foo3_2 (int a, int b) { return 32; } +int foo3_2 (int a, const char **b) { return 320; } + int main() { @@ -53,5 +57,10 @@ int main() foo2_2 (ba); // ..array of arrays foo2_3 (b); // ..array of pointers foo2_4 ((int**)b); // ..array of wrong pointers + + foo3_1 (0, 0); + foo3_2 (0, static_cast (0)); + foo3_2 (0, 0); + return 0; // end of main } diff --git a/gdb/testsuite/gdb.cp/converts.exp b/gdb/testsuite/gdb.cp/converts.exp index 3f3b3c8..b6a2ad3 100644 --- a/gdb/testsuite/gdb.cp/converts.exp +++ b/gdb/testsuite/gdb.cp/converts.exp @@ -49,3 +49,30 @@ 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" + -- cgit v1.1