d: Fix record layout of compiler-generated TypeInfo_Class [PR115249]

In r14-8766, the layout of TypeInfo_Class changed in the runtime
library, but didn't get reflected in the compiler-generated data,
causing a corruption of runtime type introspection on BigEndian targets.

This adjusts the size of the `ClassFlags' field from uint to ushort, and
adds a new ushort `depth' field in the space where ClassFlags used to
occupy.

	PR d/115249

gcc/d/ChangeLog:

	* typeinfo.cc (create_tinfo_types): Update internal Typenfo
	representation.
	(TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Likewise.
This commit is contained in:
Iain Buclaw 2025-01-17 00:23:45 +01:00
parent 15a7544e09
commit d740694ff8

View file

@ -258,10 +258,10 @@ create_tinfo_types (Module *mod)
Identifier::idPool ("TypeInfo_Class"),
array_type_node, array_type_node, array_type_node,
array_type_node, ptr_type_node, ptr_type_node,
ptr_type_node, d_uint_type, ptr_type_node,
array_type_node, ptr_type_node, ptr_type_node,
d_uint_type, d_uint_type, d_uint_type, d_uint_type,
NULL);
ptr_type_node, d_ushort_type, d_ushort_type,
ptr_type_node, array_type_node, ptr_type_node,
ptr_type_node, d_uint_type, d_uint_type, d_uint_type,
d_uint_type, NULL);
object_module = mod;
}
@ -813,6 +813,7 @@ public:
void *destructor;
void function(Object) classInvariant;
ClassFlags m_flags;
ushort depth;
void *deallocator;
OffsetTypeInfo[] m_offTi;
void function(Object) defaultConstructor;
@ -918,7 +919,10 @@ public:
flags |= ClassFlags::noPointers;
Lhaspointers:
this->layout_field (build_integer_cst (flags, d_uint_type));
this->layout_field (build_integer_cst (flags, d_ushort_type));
/* ushort depth; (not implemented) */
this->layout_field (build_zero_cst (d_ushort_type));
/* void *deallocator; */
this->layout_field (null_pointer_node);
@ -979,7 +983,10 @@ public:
if (cd->isCOMinterface ())
flags |= ClassFlags::isCOMclass;
this->layout_field (build_integer_cst (flags, d_uint_type));
this->layout_field (build_integer_cst (flags, d_ushort_type));
/* ushort depth; (not implemented) */
this->layout_field (build_zero_cst (d_ushort_type));
/* void *deallocator;
OffsetTypeInfo[] m_offTi; (not implemented)