]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix handling of const or volatile void pointers in CodeView
authorMark Harmstone <mark@harmstone.com>
Sun, 4 Aug 2024 22:26:53 +0000 (23:26 +0100)
committerMark Harmstone <mark@harmstone.com>
Mon, 5 Aug 2024 17:24:26 +0000 (18:24 +0100)
DWARF represents voids in DW_TAG_const_type and DW_TAG_volatile_type
DIEs by the absence of a DW_AT_type attribute, which we weren't handling
correctly.

gcc/
* dwarf2codeview.cc (get_type_num_const_type): Handle missing
DW_AT_type attribute.
(get_type_num_volatile_type): Likewise.

gcc/dwarf2codeview.cc

index 470cbae711037a04df44d093c2f5676a1395722e..f7107021bc71a070d2b97745575c63ad052927d2 100644 (file)
@@ -2344,23 +2344,26 @@ get_type_num_const_type (dw_die_ref type, bool in_struct)
   bool is_volatile = false;
 
   base_type = get_AT_ref (type, DW_AT_type);
-  if (!base_type)
-    return 0;
 
   /* Handle case when this is a const volatile type - we only need one
      LF_MODIFIER for this.  */
-  if (dw_get_die_tag (base_type) == DW_TAG_volatile_type)
+  if (base_type && dw_get_die_tag (base_type) == DW_TAG_volatile_type)
     {
       is_volatile = true;
 
       base_type = get_AT_ref (base_type, DW_AT_type);
-      if (!base_type)
-       return 0;
     }
 
-  base_type_num = get_type_num (base_type, in_struct, false);
-  if (base_type_num == 0)
-    return 0;
+  if (!base_type)
+    {
+      base_type_num = T_VOID;
+    }
+  else
+    {
+      base_type_num = get_type_num (base_type, in_struct, false);
+      if (base_type_num == 0)
+       return 0;
+    }
 
   ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));
 
@@ -2383,13 +2386,22 @@ get_type_num_const_type (dw_die_ref type, bool in_struct)
 static uint32_t
 get_type_num_volatile_type (dw_die_ref type, bool in_struct)
 {
+  dw_die_ref base_type;
   uint32_t base_type_num;
   codeview_custom_type *ct;
 
-  base_type_num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct,
-                               false);
-  if (base_type_num == 0)
-    return 0;
+  base_type = get_AT_ref (type, DW_AT_type);
+
+  if (base_type)
+    {
+      base_type_num = get_type_num (base_type, in_struct, false);
+      if (base_type_num == 0)
+       return 0;
+    }
+  else
+    {
+      base_type_num = T_VOID;
+    }
 
   ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));