Ada: Fix bounds check for nonstatic array and string literal assignments
Ensures Ada string literals assigned to nonstatic arrays respect index type bounds.
This change fixes an issue in Ada where the bounds of a string literal assigned to a nonstatic array were not correctly checked against the index type’s bounds. It ensures that the computed high bound of the literal is validated, preventing potential out-of-bounds issues and maintaining type safety.
In Details
This commit corrects a semantic checking bug in the Ada compiler (sem_res.adb and exp_ch6.adb) related to string literal assignments to nonstatic arrays. Previously, the high bound of the actual string literal might exceed the high bound of the target array's index type. The fix ensures that String_Literal_Low_Bound is set first, and then the actual high bound is checked against the index type's bounds before assignment, guaranteeing correctness.
- Ada
- A structured, statically typed, and imperative programming language designed for large, long-lived applications where reliability and efficiency are critical.
- String Literal
- A sequence of characters enclosed in double quotes, representing a string value in Ada.
- Nonstatic Array
- In Ada, an array whose size is determined at runtime, as opposed to a static array whose size is fixed at compile time.
- Index Type
- The type that defines the valid range of indices for an array in Ada.