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.
This commit is contained in:
David Carlton 2002-12-11 18:45:29 +00:00
parent 5a4d6ff490
commit a23b6e6a0a
3 changed files with 35 additions and 7 deletions

View File

@ -1,3 +1,9 @@
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.

View File

@ -41,7 +41,18 @@ namespace __gnu_test
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()
{
@ -49,5 +60,9 @@ 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;
}

View File

@ -54,9 +54,12 @@ if ![runto_main] then {
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"
@ -71,8 +74,6 @@ gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
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"
@ -90,8 +91,6 @@ gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object,
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"
@ -108,5 +107,13 @@ gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, bas
# 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