aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorNicholas Duffek <nsd@redhat.com>2000-07-09 05:16:11 +0000
committerNicholas Duffek <nsd@redhat.com>2000-07-09 05:16:11 +0000
commit546022221a0ddf4216735c8a6428f76c962cfe89 (patch)
tree1534d2c292afa12ec7a2e5d2542eaf97cbcb1c74 /gdb
parent6b1ba9a0022b6608ddf28ac2eb04d665aa06135b (diff)
downloadgdb-546022221a0ddf4216735c8a6428f76c962cfe89.zip
gdb-546022221a0ddf4216735c8a6428f76c962cfe89.tar.gz
gdb-546022221a0ddf4216735c8a6428f76c962cfe89.tar.bz2
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog8
-rw-r--r--gdb/testsuite/gdb.c++/classes.exp25
-rw-r--r--gdb/testsuite/gdb.c++/misc.cc26
3 files changed, 59 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 31e20db..dbc97e8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,13 @@
2000-07-09 Nick Duffek <nsd@redhat.com>
+ * 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 <nsd@redhat.com>
+
* gdb.c++/classes.exp (test_nonexistant_members): Fix name
spelling.
(test_enums): New procedure. Move enum tests from end of script
diff --git a/gdb/testsuite/gdb.c++/classes.exp b/gdb/testsuite/gdb.c++/classes.exp
index 8a0b148..9faa2fd 100644
--- a/gdb/testsuite/gdb.c++/classes.exp
+++ b/gdb/testsuite/gdb.c++/classes.exp
@@ -570,6 +570,30 @@ proc test_nonexistent_members {} {
}
#
+# 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 (&param)->a"
+ gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (&param)->x"
+ gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (&param)->a"
+ gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (&param)->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 &param"
+ 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 e4c3520..caa5451 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;
}