From: Nicholas Duffek Date: Sun, 9 Jul 2000 05:16:11 +0000 (+0000) Subject: * gdb.c++/misc.cc (class ClassParam, class_param): Define. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=546022221a0ddf4216735c8a6428f76c962cfe89;p=binutils-gdb.git * gdb.c++/misc.cc (class ClassParam, class_param): Define. (use_methods): New function. (main): Call use_methods(). * gdb.c++/classes.exp (test_method_param_class): New procedure. (do_tests): Call test_method_param_class. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 31e20db6c4d..dbc97e811c1 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2000-07-09 Nick Duffek + + * gdb.c++/misc.cc (class ClassParam, class_param): Define. + (use_methods): New function. + (main): Call use_methods(). + * gdb.c++/classes.exp (test_method_param_class): New procedure. + (do_tests): Call test_method_param_class. + 2000-07-09 Nick Duffek * gdb.c++/classes.exp (test_nonexistant_members): Fix name diff --git a/gdb/testsuite/gdb.c++/classes.exp b/gdb/testsuite/gdb.c++/classes.exp index 8a0b14807c0..9faa2fdd8c2 100644 --- a/gdb/testsuite/gdb.c++/classes.exp +++ b/gdb/testsuite/gdb.c++/classes.exp @@ -569,6 +569,30 @@ proc test_nonexistent_members {} { gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" } +# +# Call a method that expects a base class parameter with base, inherited, +# and unrelated class arguments. +# + +proc test_method_param_class {} { + gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" + gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x" + gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a" + gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x" + gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (¶m)->a" + gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (¶m)->x" + gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (¶m)->a" + gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (¶m)->x" + gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a" + gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x" + gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a" + gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x" + + gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" + gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" + gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" +} + # # Examine a class with an enum field. # @@ -806,6 +830,7 @@ proc do_tests {} { test_non_inherited_member_access test_wrong_class_members test_nonexistent_members + test_method_param_class } gdb_breakpoint enums2 diff --git a/gdb/testsuite/gdb.c++/misc.cc b/gdb/testsuite/gdb.c++/misc.cc index e4c3520df4f..caa54511838 100644 --- a/gdb/testsuite/gdb.c++/misc.cc +++ b/gdb/testsuite/gdb.c++/misc.cc @@ -427,6 +427,18 @@ void enums1 () obj_with_enum.priv_enum = ClassWithEnum::green; } +class ClassParam { +public: + int Aptr_a (A *a) { return a->a; } + int Aptr_x (A *a) { return a->x; } + int Aref_a (A &a) { return a.a; } + int Aref_x (A &a) { return a.x; } + int Aval_a (A a) { return a.a; } + int Aval_x (A a) { return a.x; } +}; + +ClassParam class_param; + class Contains_static_instance { public: @@ -514,6 +526,18 @@ void dummy() v_bool_array[1] = v_bool; } +void use_methods () +{ + /* Refer to methods so that they don't get optimized away. */ + int i; + i = class_param.Aptr_a (&g_A); + i = class_param.Aptr_x (&g_A); + i = class_param.Aref_a (g_A); + i = class_param.Aref_x (g_A); + i = class_param.Aval_a (g_A); + i = class_param.Aval_x (g_A); +} + int main() @@ -536,6 +560,8 @@ main() /* Make sure the AIX linker doesn't remove the variable. */ v_tagless.one = 5; + use_methods (); + return foo.*pmi; }