diff options
author | Ed Schonberg <schonberg@adacore.com> | 2021-02-02 10:13:52 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-07 05:29:05 -0400 |
commit | 476ed6bf66ab20e22ae4b3da0fd7fd94753f2334 (patch) | |
tree | 0101c05f64ae76d5393a6f7ab3188fd3896c6f8d /gcc | |
parent | a3e2584e85d91d0ab076c3f603bc0179921dbd82 (diff) | |
download | gcc-476ed6bf66ab20e22ae4b3da0fd7fd94753f2334.zip gcc-476ed6bf66ab20e22ae4b3da0fd7fd94753f2334.tar.gz gcc-476ed6bf66ab20e22ae4b3da0fd7fd94753f2334.tar.bz2 |
[Ada] Spurious error with component of unchecked_union type
gcc/ada/
* exp_ch4.adb (Unconstrained_UU_In_Component_Declaration): A
component declaration whose subtype indication is an entity name
without an explicit constraint is an Unchecked_Union type only
if the entity has an unconstrained nominal subtype (record type
or private type) whose parent type is an Unchecked_Union.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_ch4.adb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 6dc6aee..cbc5aaf 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -8143,11 +8143,16 @@ package body Exp_Ch4 is Sindic : constant Node_Id := Subtype_Indication (Component_Definition (N)); begin - -- Unconstrained nominal type. In the case of a constraint - -- present, the node kind would have been N_Subtype_Indication. + -- If the component declaration includes a subtype indication + -- it is not an unchecked_union. Otherwise verify that it carries + -- the Unchecked_Union flag and is either a record or a private + -- type. A Record_Subtype declared elsewhere does not qualify, + -- even if its parent type carries the flag. return Nkind (Sindic) in N_Expanded_Name | N_Identifier - and then Is_Unchecked_Union (Base_Type (Etype (Sindic))); + and then Is_Unchecked_Union (Base_Type (Etype (Sindic))) + and then (Ekind (Entity (Sindic)) in + E_Private_Type | E_Record_Type); end Unconstrained_UU_In_Component_Declaration; ----------------------------------------- |