INOX allows casing on composite values. In some cases of bindings for subcomponents, the compiler introduced copying which led to compiler failures associated with finalizing those copies. In such cases a bound object now provides a constant view of the appropriate subcomponent of the selector object, not a copy thereof.
Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb (Check_Bindings): Provide a second strategy for implementing bindings and choose which strategy to use for a given binding. The previous approach was to introduce a new object and assign the bound value to the object. The new approach is to introduce a renaming of a dereference of an access value that references the appropriate subcomponent, so no copies are made. The original strategy is still used if the type of the object is elementary. When the renaming approach is used, the initialization of the access value is not generated until expansion. Until this missing initialization is added, the tree looks like a known-at-compile-time dereference of a null access value: Temp : Some_Access_Type; Obj : Designated_Type renames Temp.all; This leads to problems, so a bogus initial value is provided here and then later deleted during expansion. (Check_Composite_Case_Selector): Disallow a case selector expression that requires finalization. Note that it is ok if the selector's type requires finalization, as long as the expression itself doesn't have any "newly constructed" parts. * exp_ch5.adb (Pattern_Match): Detect the case where analysis of a general (i.e., composite selector type) case statement chose to implement a binding as a renaming rather than by making a copy. In that case, generate the assignments to initialize the access-valued object whose designated value is later renamed (and remove the bogus initial value for that object that was added during analysis). * sem_util.ads, sem_util.adb: Add new function Is_Newly_Constructed corresponding to RM 4.4 term.
patch.diff.gz
Description: application/gzip