diff options
author | Tom Tromey <tromey@redhat.com> | 2010-03-13 00:27:12 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2010-03-13 00:27:12 +0000 |
commit | 1c809c688364f87ba62a4c590b53d1efe0cff64e (patch) | |
tree | 6be478308b2c32a2c2bba5ca5b28dbd14b16f6fc /gdb/dwarf2read.c | |
parent | e0ce539c578586fd2f9c54b703335fa064e42a22 (diff) | |
download | gdb-1c809c688364f87ba62a4c590b53d1efe0cff64e.zip gdb-1c809c688364f87ba62a4c590b53d1efe0cff64e.tar.gz gdb-1c809c688364f87ba62a4c590b53d1efe0cff64e.tar.bz2 |
gdb
PR c++/9708:
* dwarf2read.c (die_needs_namespace) <DW_TAG_variable>: A variable
in a lexical block does not need a namespace.
(new_symbol) <DW_TAG_variable>: Put extern variables on
list_in_scope in all cases.
gdb/testsuite
PR c++/9708:
* gdb.cp/m-static.exp: Add regression test.
* gdb.cp/m-static.cc (method): New method.
(main): Call it.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 53e2e1e..2d21edb 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -3204,6 +3204,8 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) static int die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu) { + struct attribute *attr; + switch (die->tag) { case DW_TAG_namespace: @@ -3231,11 +3233,17 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu) spec_cu); } - if (dwarf2_attr (die, DW_AT_external, cu) - || die->parent->tag == DW_TAG_namespace) - return 1; - - return 0; + attr = dwarf2_attr (die, DW_AT_external, cu); + if (attr == NULL && die->parent->tag != DW_TAG_namespace) + return 0; + /* A variable in a lexical block of some kind does not need a + namespace, even though in C++ such variables may be external + and have a mangled name. */ + if (die->parent->tag == DW_TAG_lexical_block + || die->parent->tag == DW_TAG_try_block + || die->parent->tag == DW_TAG_catch_block) + return 0; + return 1; default: return 0; @@ -8413,7 +8421,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu) var_decode_location (attr, sym, cu); attr2 = dwarf2_attr (die, DW_AT_external, cu); if (attr2 && (DW_UNSND (attr2) != 0)) - add_symbol_to_list (sym, &global_symbols); + { + struct pending **list_to_add; + + /* A variable with DW_AT_external is never static, + but it may be block-scoped. */ + list_to_add = (cu->list_in_scope == &file_symbols + ? &global_symbols : cu->list_in_scope); + add_symbol_to_list (sym, list_to_add); + } else add_symbol_to_list (sym, cu->list_in_scope); } |