Ada: Use correct scope when unnesting a subprogram.
The Ada compiler fixes a bug where incorrect scope was used when unnesting a subprogram, preventing a potential assertion failure.
The Ada compiler fixes an issue during unnesting of subprograms where the Current_Scope was being incorrectly used, potentially leading to a failed assertion. The fix involves pushing and popping the current subprogram entity as the scope around the Analyze call in exp_unst.adb.
In Details
The commit addresses an issue in exp_unst.adb within the Unnest_Subprogram function. When analyzing a subprogram, the compiler may create new entities (e.g., IType). These entities should use the subprogram's scope, but were incorrectly using Current_Scope, leading to a potential assertion failure. The fix ensures the correct scope by pushing and popping the subprogram's entity around the call to Analyze.
For Context
When processing code, compilers must keep track of the scope of variables and functions to ensure that names are used correctly. This involves managing a stack of scopes as the compiler enters and exits different parts of the code. This commit fixes an error in the Ada compiler where the wrong scope was being used during a process called "unnesting" of subprograms, which can lead to subtle errors.