Avoid transient scope creation under GNATProve in more cases.
The Ada compiler avoids creating transient scopes under GNATProve mode even when only checking syntax and semantics.
A regression was introduced where a transient scope was being created under GNATProve mode even when only performing syntax and semantic checks. This commit prevents the creation of transient scopes in sem_res.adb (Resolve_Declare_Expression) when expansion is disabled, addressing the issue across more scenarios. This ensures consistent behavior when compiling with GNATProve.
In Details
This commit modifies sem_res.adb (Resolve_Declare_Expression) to avoid creating a transient scope when expansion is disabled. This fixes a regression that occurred even when compiling under check syntax and semantic only mode (-gnatc). The transient scope creation was unnecessary in this mode.
For Context
GNATProve is a formal verification tool for Ada that can prove the absence of certain runtime errors in your code. Scopes define the visibility and lifetime of variables and other entities in a program. This commit fixes a regression where the compiler was creating unnecessary scopes when using GNATProve, leading to inconsistencies.