]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Implement proper upcasting in more cases
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 24 Sep 2025 17:02:34 +0000 (19:02 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 6 Oct 2025 12:27:10 +0000 (14:27 +0200)
commit022f2ed33cc4ec1353dd5b60a961d7529521bc31
tree0574f1a89afb5d992c593723c31e2232338f078b
parent17e59eebf9ce02665a37cbeb51d9b4c2cf80d2ae
ada: Implement proper upcasting in more cases

Upcasting (conversion from a tagged type extension to one of its parents)
is represented as a simple N_Type_Conversion node in the expanded code,
but translating it into a VIEW_CONVERT_EXPR is a bit problematic because
source and target types of the GCC node are supposed to have the same size
(at least in "non-pathological" cases).

That's why Gigi attempts to build an explicit chain of references to the
appropriate _Parent (sub)component instead, but it currently does that
only for simple (i.e. non-discriminated) tagged types.  This can be easily
extended to discriminated tagged types in not-too-dynamic cases (an example
is the ACATS c391002 test).

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (convert): Also extract the _Parent field
to implement upcasting in the case where only the sizes match.
gcc/ada/gcc-interface/utils.cc