+2002-12-11 David Carlton <carlton@math.stanford.edu>
+
+ * gdb.c++/m-data.exp: Add test for members that shadow global
+ variables: see PR gdb/804.
+ * gdb.c++/m-data.cc: Ditto.
+
2002-12-10 Daniel Jacobowitz <drow@mvista.com>
* gdb.base/foll-vfork.exp: Re-enable test on HP/UX.
public:
gnu_obj_3(antiquities b): data(etruscan) { }
};
-}
+}
+
+int shadow = 0;
+
+class C
+{
+public:
+ C (int x) : shadow (x) {}
+ void marker () {}
+private:
+ int shadow;
+};
int main()
{
gnu_obj_1 test1(egyptian, 4589);
gnu_obj_2<long> test2(roman);
gnu_obj_3<long> test3(greek);
+
+ C theC (1); // breakpoint: first-constructs-done
+ theC.marker ();
+
return 0;
}
continue
}
+# First, run to after we've constructed all the gnu_obj_N's:
+
+gdb_breakpoint [gdb_get_line_number "first-constructs-done"]
+gdb_continue_to_breakpoint "end of first constructors"
+
# One.
-gdb_test "break 50" "Breakpoint \[0-9\]*.*line 50\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:50\r\n.*" "continue to 50"
# simple object, const bool
gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, const bool"
gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
# Two.
-gdb_test "break 51" "Breakpoint \[0-9\]*.*line 51\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:51\r\n.*" "continue to 51"
# derived template object, base const bool
gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base const bool"
gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
# Three.
-gdb_test "break 52" "Breakpoint \[0-9\]*.*line 52\\."
-gdb_test "continue" "Continuing\\.\r\n\r\nBreakpoint.*at.*m-data\\.cc:52\r\n.*" "continue to 52"
# template object, derived template data member's base const bool
gdb_test "print test3.data.test" "\\$\[0-9\]* = true" "template object, const bool"
# template object, derived template data member's enum
gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum"
+# Now some tests for shadowing (see PR gdb/804):
+
+gdb_breakpoint "C::marker"
+gdb_continue_to_breakpoint "continue to shadow breakpoint"
+
+gdb_test "print shadow" "\\$\[0-9]\* = 1" "shadowing member"
+gdb_test "print ::shadow" "\\$\[0-9]\* = 0" "shadowed global variable"
+
gdb_exit
return 0