]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix assertion failure on aggregate with controlled component
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 8 Jul 2025 09:05:19 +0000 (11:05 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 22 Jul 2025 08:35:15 +0000 (10:35 +0200)
commit06728901a03376bdeafc3ff48115113a0ffe169e
tree0c14e1959f3f258faf1b78d85767b205e55c37a4
parent15cd3770ac14562d31d057cd5b65df6b9163521c
ada: Fix assertion failure on aggregate with controlled component

The assertion is:

      pragma Assert (Side_Effect_Free (L));

in Make_Tag_Ctrl_Assignment and demonstrates that the sequence:

  Remove_Side_Effects (L);
  pragma Assert (Side_Effect_Free (L));

does not hold in this case.

What happens is that Remove_Side_Effects uses a renaming to remove the side
effects of L but, at the end, the renamed object is substituted back for the
renamed object in the node by Expand_Renaming, which is invoked because the
Is_Renaming_Of_Object flag is set on the renaming after Evaluate_Name has
been invoked on its Name.

This is a general discrepancy between Evaluate_Name and Side_Effect_Free of
Exp_Util, coming from the call to Safe_Unchecked_Type_Conversion present in
Side_Effect_Free in this case.  The long term goal is probably to remove the
call but, in the meantime, this change is sufficient to fix the failure.

gcc/ada/ChangeLog:

* exp_util.adb (Safe_Unchecked_Type_Conversion): Always return True
if the expression is the prefix of an N_Selected_Component.
gcc/ada/exp_util.adb