[Ada] Cache all static structures and reset cache during resolution
Currently, ada-lang.c:template_to_static_fixed_type (working on
structure types only) caches its result into the unused TYPE_TARGET_TYPE
field. This introduces inconsistencies when the input type is
specialized, for instance during type resolution: the cached static
fixed type is copied along with the original type, but it's no longer
adapted to the copy once the copy is modified:
template_to_static_fixed_type has to compute another static fixed type
for it.
This change first introduces a cache reset during type resolution for
structure types so that this inconsistency does not happen anymore. It
also makes template_to_static_fixed_type smarter with respect to types
that do not need static fixed copies so that less computations is done
in general.
This inconsistency was spotted thanks to code reading, not because of
any sort of failure and we did not manage to exhibit a failure yet, so
no testcase for this.
gdb/ChangeLog:
* ada-lang.c (template_to_static_fixed_type): Return input type
when it is already fixed. Cache the input type itself when not
creating a static fixed copy. Make it explicit that we never
molestate the input type.
* gdbtypes.c (resolve_dynamic_struct): Reset the
TYPE_TARGET_TYPE field for resolved copies.