]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fixup one more pattern of broken scope information
authorMarc Poulhiès <poulhies@adacore.com>
Tue, 13 Feb 2024 11:20:19 +0000 (12:20 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 16 May 2024 08:49:30 +0000 (10:49 +0200)
commit513f6b889ab5c9fa88e82506cce7534f0400b1c6
treeb0d9d84f1b4208aaba94176d39f10b3d36eb5f6b
parentbc35098efbfb14cf17f0f79f5dfcb44fdf0975de
ada: Fixup one more pattern of broken scope information

When an array's initialization contains a `others =>` clause with an
expression that involves finalization, the resulting scope information
is incorrect and can cause crashes with backend (i.e. gnat-llvm) that
also use unnesting. The observable symptom is a nested object
declaration (created by the compiler) within a loop wrapped in a
procedure created by the unnester that has incoherent scope information:
its Scope field points to the scope of the procedure (1 level too high)
and is contained in the entity chain of some entity nested in the
procedure (correct).

The correct solution would be to fix the scope information when it is
created, but this revealed too large of a task with many interaction
with existing code.

This change adds another pattern to the Fixup_Inner_Scopes procedure to
detect the problematic case and fix the scope, "after the facts".

gcc/ada/

* exp_ch7.adb (Unnest_Loop::Fixup_Inner_Scopes): detect a new
problematic pattern and fixup the scope accordingly.
gcc/ada/exp_ch7.adb