]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/gdbtypes.c
[gdb/exp] Fix assert when adding ptr to imaginary unit
[thirdparty/binutils-gdb.git] / gdb / gdbtypes.c
index 4dd1a6a64ec27590fefd49bd0f1a80fd2b9548d3..c736dff2ca82f9dd588ef1e30227308798bf6b07 100644 (file)
@@ -3413,6 +3413,15 @@ init_decfloat_type (struct objfile *objfile, int bit, const char *name)
   return t;
 }
 
+/* Return true if init_complex_type can be called with TARGET_TYPE.  */
+
+bool
+can_create_complex_type (struct type *target_type)
+{
+  return (target_type->code () == TYPE_CODE_INT
+         || target_type->code () == TYPE_CODE_FLT);
+}
+
 /* Allocate a TYPE_CODE_COMPLEX type structure.  NAME is the type
    name.  TARGET_TYPE is the component type.  */
 
@@ -3421,8 +3430,7 @@ init_complex_type (const char *name, struct type *target_type)
 {
   struct type *t;
 
-  gdb_assert (target_type->code () == TYPE_CODE_INT
-             || target_type->code () == TYPE_CODE_FLT);
+  gdb_assert (can_create_complex_type (target_type));
 
   if (TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type == nullptr)
     {