ada: Fix bogus error on predicated limited record declared in protected type
commitea5a7a774a2d5d2759f45c77efa17a91182e614f
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 17 Feb 2023 17:01:52 +0000 (17 18:01 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 23 May 2023 07:59:04 +0000 (23 09:59 +0200)
tree3b76635b0b314c5c3afc8a08164137b1674a8a90
parentdb338ee106ab912c2a318b74fe7534071a0e6729
ada: Fix bogus error on predicated limited record declared in protected type

This happens when the limited record is initialized with a function call
because of a couple of issues: incorrect tree sharing when building the
predicate check and too late freezing for a compiler-generated subtype.

It turns out that building the predicate check manually is redundant here,
since predicate checks are automatically generated during the expansion of
assignment statements, and the late freezing can be easily fixed.

gcc/ada/

* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
manually generate a predicate check.  Call Unqualify before doing
pattern matching on the expression.
* sem_ch3.adb (Analyze_Object_Declaration): Also freeze the actual
subtype when it is built in the definite case.
gcc/ada/exp_ch3.adb
gcc/ada/sem_ch3.adb