[4/4] ir: Handle ptr to fn type member with empty void return type

Message ID 20240817120026.459568-4-dodji@redhat.com
State New
Headers
Series [1/4] ir: Improve legibility of set_member_function_is_virtual |

Commit Message

Dodji Seketeli Aug. 17, 2024, noon UTC
  If a pointer to member type points to a function type that has an
empty return type, sometimes that can lead to a crash.  This patch
considers that the empty return type is a void type.

	* src/abg-ir.cc (add_outer_ptr_to_mbr_type_expr): If the function
	type has no return type, consider it as void type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 873f3750..f189cb09 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -28903,6 +28903,7 @@  add_outer_ptr_to_mbr_type_expr(const ptr_to_mbr_type* p,
     return "";
 
   std::ostringstream left, right, inner;
+  type_base_sptr void_type = p->get_environment().get_void_type();
   string containing_type_name = get_type_name(p->get_containing_type(),
 					      qualified, internal);
   type_base_sptr mbr_type = p->get_member_type();
@@ -28913,6 +28914,8 @@  add_outer_ptr_to_mbr_type_expr(const ptr_to_mbr_type* p,
       stream_pretty_representation_of_fn_parms(*fn_type, right,
 					       qualified, internal);
       type_base_sptr return_type = fn_type->get_return_type();
+      if (!return_type)
+	return_type = void_type;
       if (is_npaf_type(return_type)
 	  || !(is_pointer_to_function_type(return_type)
 	       || is_pointer_to_array_type(return_type)