> On Aug 23, 2023, at 10:24, Richard Wai <rich...@annexi-strayline.com> wrote: > > Somehow an error worked its way into the original diff (the diff itself), > making the previous patch fail to apply. > > Fixed version attached. > > Richard Wai > ANNEXI-STRAYLINE > > From: Richard Wai <rich...@annexi-strayline.com > <mailto:rich...@annexi-strayline.com>> > Sent: Thursday, August 10, 2023 1:27 AM > To: 'gcc-patches@gcc.gnu.org <mailto:gcc-patches@gcc.gnu.org>' > <gcc-patches@gcc.gnu.org <mailto:gcc-patches@gcc.gnu.org>> > Cc: 'Eric Botcazou' <ebotca...@adacore.com <mailto:ebotca...@adacore.com>>; > 'Arnaud Charlet' <char...@adacore.com <mailto:char...@adacore.com>>; 'Stephen > Baird' <ba...@adacore.com <mailto:ba...@adacore.com>> > Subject: [PATCH 2/2] Ada: Finalization of constrained subtypes of > unconstrained synchronized private extensions > > When generating TSS address finalization bodies for a tagged class-wide > subtype, GNAT climbs the parent chain looking for the first “non-constrained” > type. That type’s underlying type’s class-wide type is used as a “designated” > type for a dispatching TSS deep finalize call to the designated class-wide > type. In the case of a constrained subtype of an unconstrained synchronized > private extension, this ends up designating the underlying type of that > private extension. This means it targets the class-wide type of the actual > underlying concurrent type rather than the corresponding record. Ultimately > it ends up generating a call to the corresponding record’s deep finalizer, > but with incompatible types (concurrent_type’Class -> > concurrent_typeV’Class). This causes compilation to fail. > > This patch adds extra logic to exp_ch7(Make_Finalize_Address_Stmts) to > identify such cases and ensure that the designated type is the corresponding > record type’s class-wide type in that situation. > > Patch file is attached. > > -- Begin change log entry – > > ada: TSS finalize address subprogram generation for constrained subtypes of > unconstrained synchronized private extensions should take care to designate > the corresponding record of the underlying concurrent type. > > When generating TSS finalize address subprograms for class-wide types of > constrained root types, it follows the parent chain looking for the first > “non-constrained” type. It is possible that such a type is a private > extension with the “synchronized” keyword, in which case the underlying type > is a concurrent type. When that happens, the designated type of the finalize > address subprogram should be the corresponding record’s class-wide-type. > > Gcc/ada/ > * exp_ch3(Expand_Freeze_Class_Wide_Type): Expanded comments > explaining why TSS Finalize_Address is not generated for concurrent > class-wide types. > * exp_ch7(Make_Finalize_Address_Stmts): Handle cases where > the underlying non-constrained parent type is a concurrent type, and adjust > the designated type to be the corresponding record’s class-wide type. > > -- End change log entry – > > This patch was bootstrapped on x86_64-*-freebsd13.2. One new test cases was > added. Note that 4 gnat test cases fail currently on master and are unrelated > to this patch. > > Check-ada output of this patch: > > === acats tests === > Running chapter a ... > Running chapter c2 ... > Running chapter c3 ... > Running chapter c4 ... > Running chapter c5 ... > Running chapter c6 ... > Running chapter c7 ... > Running chapter c8 ... > Running chapter c9 ... > Running chapter ca ... > Running chapter cb ... > Running chapter cc ... > Running chapter cd ... > Running chapter ce ... > Running chapter cxa ... > Running chapter cxb ... > Running chapter cxf ... > Running chapter cxg ... > Running chapter cxh ... > Running chapter cz ... > Running chapter d ... > Running chapter e ... > Running chapter l ... > === acats Summary === > # of expected passes 2328 > # of unexpected failures 0 > > Native configuration is x86_64-unknown-freebsd13.2 > > === gnat tests === > > Schedule of variations: > unix > > Running target unix > FAIL: gnat.dg/specs/alignment2.ads (test for warnings, line 14) > FAIL: gnat.dg/specs/alignment2.ads (test for warnings, line 20) > FAIL: gnat.dg/specs/alignment2.ads (test for warnings, line 38) > FAIL: gnat.dg/specs/alignment2.ads (test for warnings, line 42) > > === gnat Summary === > > # of expected passes 3401 > # of unexpected failures 4 > # of expected failures 23 > # of unsupported tests 10 > gnatmake version 14.0.0 20230809 (experimental) > > > Richard Wai > ANNEXI-STRAYLINE