Skip to content
Snippets Groups Projects
Commit 93eb5676 authored by Bob Duff's avatar Bob Duff Committed by Marc Poulhiès
Browse files

ada: Use inheritance in Gen_IL

In Gen_IL, detect cases where fields could be inherited from
an abstract type instead of being defined in each of two or more
descendants of that type. Raise Illegal when that is the case,
except in specific cases called out as exceptions to this rule.

For every such case, either update the types declared in
Gen_Nodes and Gen_Entities to use inheritance, or add the case
to the list of exceptions where we do not want to use inheritance.

gcc/ada/ChangeLog:

	* gen_il-internals.ads: Split Fields field into two fields
	Imm_Fields and Fields.
	* gen_il-gen.adb: Modify the field-inheritance
	algorithm to inherit at each level of the type hierarchy,
	rather than just inheriting into concrete types.
	For example, if C is a concrete type derived from B,
	which is in turn derived from A, we now set the Fields
	of B to include those of A. (We had always set the Fields
	of C to include those of A and B, and we still do that.)
	(Compute_Fields_For_One_Type): Detect cases where a given
	field is declared for all descendants of a given abstract
	type, in which case we should consider declaring it in
	the abstract type, and inheriting it in those descendants.
	(Exception_To_Inheritance_Rule): These are the cases where
	we could inherit, but we don't want to.
	* gen_il-gen-gen_nodes.adb: Move fields up the type hierarchy,
	so they are inherited instead of being defined separately.
	* gen_il-gen-gen_entities.adb: Likewise.
parent 950df609
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment