diff mbox series

Fix handling of const or volatile void pointers in CodeView

Message ID 20240804224212.19192-1-mark@harmstone.com
State New
Headers show
Series Fix handling of const or volatile void pointers in CodeView | expand

Commit Message

Mark Harmstone Aug. 4, 2024, 10:42 p.m. UTC
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 | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

Comments

Jeff Law Aug. 5, 2024, 12:37 a.m. UTC | #1
On 8/4/24 4:42 PM, Mark Harmstone wrote:
> 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.
OK
jeff
diff mbox series

Patch

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index 470cbae7110..f7107021bc7 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -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));