[v2,PR,gdb/16841] virtual inheritance via typedef cannot find base
Commit Message
Here's a suggestion of modifications for the test, implementing what
I mentioned. Feel free to change it as you wish.
From 70cc479b7465b119c2aacd092167ebb5c60dd70b Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Fri, 7 Sep 2018 23:00:28 +0100
Subject: [PATCH] Modifications to the test
---
gdb/testsuite/gdb.cp/virtbase2.cc | 7 +++-
gdb/testsuite/gdb.cp/virtbase2.exp | 68 +++++++++++++++++++++++++++-----------
2 files changed, 54 insertions(+), 21 deletions(-)
@@ -1,4 +1,9 @@
-struct base {
+struct superbase {
+ int x;
+ superbase () : x(22) {}
+};
+
+struct base : superbase {
int i; double d;
base() : i(55), d(6.6) {}
};
@@ -28,23 +28,51 @@ if {![runto_main]} then {
continue
}
-gdb_breakpoint "derived::func_d"
-gdb_continue_to_breakpoint "continue to derived::func_d"
-gdb_test "print i" " = 55" "i in base class"
-gdb_test "print derived::i" " = 55" "i in base class"
-gdb_test "print derived::base::i" " = 55" "i in base class"
-gdb_test "print base::i" " = 55" "i in base class"
-gdb_test "print d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print base::d" " = 6.5999999999999996" "d in base class"
-gdb_breakpoint "foo::func_f"
-gdb_continue_to_breakpoint "continue to foo::func_f"
-gdb_test "print i" " = 55" "i in base class"
-gdb_test "print derived::i" " = 55" "i in base class"
-gdb_test "print derived::base::i" " = 55" "i in base class"
-gdb_test "print base::i" " = 55" "i in base class"
-gdb_test "print d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print derived::base::d" " = 6.5999999999999996" "d in base class"
-gdb_test "print base::d" " = 6.5999999999999996" "d in base class"
+proc make_scope_list { scopes } {
+ if { [llength $scopes] == 1 } {
+ return [list "" "${scopes}::"]
+ }
+
+ # Pop the first element, save the first scope.
+ set this_scope [lindex $scopes 0]
+ set scopes [lreplace $scopes 0 0]
+
+ set child_result [make_scope_list $scopes]
+
+ # Add a copy of the child's result without this scope...
+ set result $child_result
+
+ # ... and a copy of the child's result with this scope.
+ foreach r $child_result {
+ lappend result "${this_scope}::$r"
+ }
+
+ return $result
+}
+
+proc test_variables_in_base { scopes } {
+ foreach scope [make_scope_list $scopes] {
+ gdb_test "print ${scope}i" " = 55"
+ gdb_test "print ${scope}d" " = 6.5999999999999996"
+ }
+}
+
+proc test_variables_in_superbase { scopes } {
+ foreach scope [make_scope_list $scopes] {
+ gdb_test "print ${scope}x" " = 22"
+ }
+}
+
+with_test_prefix "derived::func_d" {
+ gdb_breakpoint "derived::func_d"
+ gdb_continue_to_breakpoint "continue to derived::func_d"
+ test_variables_in_base {derived base}
+ test_variables_in_superbase {derived base superbase}
+}
+
+with_test_prefix "foo::func_f" {
+ gdb_breakpoint "foo::func_f"
+ gdb_continue_to_breakpoint "continue to foo::func_f"
+ test_variables_in_base {foo derived base}
+ test_variables_in_superbase {foo derived base superbase}
+}