Ada: Fix crash on Unchecked_Union component with -gnateV.
Fixes a crash in the Ada compiler when using Unchecked_Union components with the -gnateV flag.
This patch resolves a crash in the Ada compiler related to Unchecked_Union components when the -gnateV flag is used. The issue stems from incorrect validation of fields within an Unchecked_Union type. The fix involves modifying the Validate_Field procedure in exp_attr.adb to do nothing if the field belongs to an Unchecked_Union type, preventing the crash. A new test case is added to cover this scenario.
In Details
The Ada binder's attribute validation (exp_attr.adb, Build_Record_VS_Func.Validate_Field) incorrectly processed fields of Unchecked_Union types, leading to a crash when -gnateV (which enables runtime checks for variant parts) was used. This commit adds a guard to Validate_Field to skip processing such fields, aligning with the behavior for other union types and addressing PR ada/126553.
- Unchecked_Union
- A type of tagged union in Ada that allows accessing any component of the union without runtime checks, potentially leading to undefined behavior if the wrong component is accessed.
- -gnateV
- An Ada compiler flag that enables runtime checks for variant parts of unions and discriminants, enhancing safety.
- Ada binder
- Part of the Ada compiler responsible for semantic analysis, type checking, and other high-level operations.