public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-598] [Ada] Spurious error with component of unchecked_union type
@ 2021-05-07  9:39 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-07  9:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:476ed6bf66ab20e22ae4b3da0fd7fd94753f2334

commit r12-598-g476ed6bf66ab20e22ae4b3da0fd7fd94753f2334
Author: Ed Schonberg <schonberg@adacore.com>
Date:   Tue Feb 2 10:13:52 2021 -0500

    [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.

Diff:
---
 gcc/ada/exp_ch4.adb | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 6dc6aee8e37..cbc5aaf8091 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;
 
          -----------------------------------------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-07  9:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07  9:39 [gcc r12-598] [Ada] Spurious error with component of unchecked_union type Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).