diff options
author | David Carlton <carlton@bactrian.org> | 2002-12-11 18:45:29 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2002-12-11 18:45:29 +0000 |
commit | a23b6e6a0ad4098759968bf2c666357d5dd08c22 (patch) | |
tree | b8a212c759bdef9298f6af5dd2230b1db179c4e8 /gdb | |
parent | 5a4d6ff490d0cefe87855d7758ba4e44a7859505 (diff) | |
download | gdb-a23b6e6a0ad4098759968bf2c666357d5dd08c22.zip gdb-a23b6e6a0ad4098759968bf2c666357d5dd08c22.tar.gz gdb-a23b6e6a0ad4098759968bf2c666357d5dd08c22.tar.bz2 |
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.c++/m-data.cc | 17 | ||||
-rw-r--r-- | gdb/testsuite/gdb.c++/m-data.exp | 19 |
3 files changed, 35 insertions, 7 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6ae589d..f324892 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -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. diff --git a/gdb/testsuite/gdb.c++/m-data.cc b/gdb/testsuite/gdb.c++/m-data.cc index d995027..5a39abd 100644 --- a/gdb/testsuite/gdb.c++/m-data.cc +++ b/gdb/testsuite/gdb.c++/m-data.cc @@ -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; } diff --git a/gdb/testsuite/gdb.c++/m-data.exp b/gdb/testsuite/gdb.c++/m-data.exp index ac68258..85adb5e 100644 --- a/gdb/testsuite/gdb.c++/m-data.exp +++ b/gdb/testsuite/gdb.c++/m-data.exp @@ -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 |