aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2010-06-29 16:53:10 +0000
committerDoug Evans <dje@google.com>2010-06-29 16:53:10 +0000
commit254e6b9ed4abf109cb8399aa3f8f387f7eb2465c (patch)
tree2bc97c84786aa776590c3ff3c28dedb572e1d449 /gdb/testsuite/gdb.cp
parent6e70227d64c310278ef73303b2137a9997cb4c0f (diff)
downloadgdb-254e6b9ed4abf109cb8399aa3f8f387f7eb2465c.zip
gdb-254e6b9ed4abf109cb8399aa3f8f387f7eb2465c.tar.gz
gdb-254e6b9ed4abf109cb8399aa3f8f387f7eb2465c.tar.bz2
PR c++/11702
* NEWS: Add entry. * dwarf2read.c (dwarf2_add_field): If DW_AT_const_value is present, create a symbol for the field and record the value. (new_symbol): Handle DW_TAG_member. * gdbtypes.c (field_is_static): Remove FIXME. * symtab.c (search_symbols): When searching for VARIABLES_DOMAIN, only ignore LOC_CONST symbols that are enums. testsuite/ Test PR c++/11702. * gdb.cp/m-static.exp: Add testcase. * gdb.cp/m-static.h (gnu_obj_4): Add initialized static const member.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/m-static.exp14
-rw-r--r--gdb/testsuite/gdb.cp/m-static.h4
2 files changed, 15 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index dda8d84..6b457d2 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -56,12 +56,14 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
+get_debug_format
+set non_dwarf [expr ! [test_debug_format "DWARF 2"]]
+
# First, run to after we've constructed all the objects:
gdb_breakpoint [gdb_get_line_number "constructs-done"]
@@ -125,6 +127,16 @@ gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initiali
# static const int that nobody initializes. From PR gdb/635.
gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimized out" "static const int initialized nowhere"
+# static const initialized in the class definition, PR gdb/11702.
+if { $non_dwarf } { setup_xfail *-*-* }
+gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition"
+if { $non_dwarf } { setup_xfail *-*-* }
+gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition"
+
+# Also make sure static const members can be found via "info var".
+if { $non_dwarf } { setup_xfail *-*-* }
+gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere"
+
# Perhaps at some point test4 should also include a test for a static
# const int that was initialized in the header file. But I'm not sure
# that GDB's current behavior in such situations is either consistent
diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h
index 012cd77..bcedfff 100644
--- a/gdb/testsuite/gdb.cp/m-static.h
+++ b/gdb/testsuite/gdb.cp/m-static.h
@@ -5,8 +5,8 @@ class gnu_obj_4
public:
static const int elsewhere;
static const int nowhere;
- // At some point, perhaps:
- // static const int everywhere = 317;
+ static const int everywhere = 317;
+ static const float somewhere = 3.14159;
// try to ensure test4 is actually allocated
int dummy;