gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Tue, 8 Mar 2011 17:54:44 +0000 (17:54 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Tue, 8 Mar 2011 17:54:44 +0000 (17:54 +0000)
Fix DWARF-3+ DW_AT_accessibility default assumption.
* dwarf2read.c (dwarf2_add_field): Fix new_field->accessibility for
cu->header.version >= 3.

gdb/ChangeLog
gdb/dwarf2read.c

index 05d8314fac73367bef3721f4775b729634960736..930fb9424ecca879156272d34cd1f36339bb9247 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Fix DWARF-3+ DW_AT_accessibility default assumption.
+       * dwarf2read.c (dwarf2_add_field): Fix new_field->accessibility for
+       cu->header.version >= 3.
+
 2011-03-08  Pedro Alves  <pedro@codesourcery.com>
 
        * remote.c (remote_check_symbols): Skip if the target has no
index 2a47c7d19b08fc62a9ee2a5253cf8e635fed001c..ba5680f91ce89ba2a68a6737703856a1d4f3d691 100644 (file)
@@ -6238,13 +6238,25 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
     }
   fip->nfields++;
 
-  /* Handle accessibility and virtuality of field.
-     The default accessibility for members is public, the default
-     accessibility for inheritance is private.  */
-  if (die->tag != DW_TAG_inheritance)
-    new_field->accessibility = DW_ACCESS_public;
+  if (cu->header.version < 3)
+    {
+      /* The default DWARF 2 accessibility for members is public, the default
+        accessibility for inheritance is private.  */
+
+      if (die->tag != DW_TAG_inheritance)
+       new_field->accessibility = DW_ACCESS_public;
+      else
+       new_field->accessibility = DW_ACCESS_private;
+    }
   else
-    new_field->accessibility = DW_ACCESS_private;
+    {
+      /* DWARF 3 specifies the default accessibility explicitly.  */
+
+      if (die->parent->tag == DW_TAG_class_type)
+       new_field->accessibility = DW_ACCESS_private;
+      else
+       new_field->accessibility = DW_ACCESS_public;
+    }
   new_field->virtuality = DW_VIRTUALITY_none;
 
   attr = dwarf2_attr (die, DW_AT_accessibility, cu);