From a23b6e6a0ad4098759968bf2c666357d5dd08c22 Mon Sep 17 00:00:00 2001 From: David Carlton Date: Wed, 11 Dec 2002 18:45:29 +0000 Subject: [PATCH] 2002-12-11 David Carlton * gdb.c++/m-data.exp: Add test for members that shadow global variables: see PR gdb/804. * gdb.c++/m-data.cc: Ditto. --- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.c++/m-data.cc | 17 ++++++++++++++++- 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 6ae589d3660..f324892dba1 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2002-12-11 David Carlton + + * 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 * 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 d9950274d7a..5a39abded53 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 test2(roman); gnu_obj_3 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 ac6825870da..85adb5e5200 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 -- 2.30.2