From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 3A5AB383E820 for ; Thu, 19 May 2022 14:16:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A5AB383E820 Received: by mail-wr1-x436.google.com with SMTP id u27so6553743wru.8 for ; Thu, 19 May 2022 07:16:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=9D2RX+NI78GAZSlZ/41NThQJW1JWG5fMKbOM3pnU9N8=; b=audLAmkwHU7ycIUErys2gBx1FL7wTMgdxFLRN39H4uCmRnhg2u3F6CFxRL11P1PqO1 qNqPbp6zJSnGstLiRu/iFRS71fPVHN2JQkWGyPGPMiVszoGyR1PknWJqR4W+jLbUq4n0 E5PFnkcDfJXd8OxyzLRSvG73WnQSzTJW5Qpw3AGApMM+JfxZ+yWJCzO2Vn9ZkID0j8R0 UqBaYL59gBYHbzQsgCM3XVSmRHZW1N+QgwLxxj6roKQVcDEgTXsWatKpsY87Zf5PcNK2 0PUcz9iWLvpUzPmpd8orbzARJ9cce2jrexn9Bgo/vlM/oLtpIl28COnwyUOg9TXN9Po4 tvhw== X-Gm-Message-State: AOAM531Pgt809ojfNELBYux0Z5iz6I/Uwkj48ae8s0BsFECcQLpKLYJo /0W8PeCdHdIfi5HcrLdS9c6YNI8Y9g4PUg== X-Google-Smtp-Source: ABdhPJxac5Yv4TWfKnHMxDVxffBJhzw86PkGlTEFFMXAZp+Muf7q0SwOCx1BYurZmeYXNnAvI2bOog== X-Received: by 2002:a5d:59a7:0:b0:20c:58f8:f50e with SMTP id p7-20020a5d59a7000000b0020c58f8f50emr4460122wrr.189.1652969784798; Thu, 19 May 2022 07:16:24 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o17-20020adfca11000000b0020c5253d926sm5159430wrh.114.2022.05.19.07.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 07:16:22 -0700 (PDT) Date: Thu, 19 May 2022 14:16:21 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix for internal error on semi-circular record aggregate Message-ID: <20220519141621.GA3723495@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2fHTh5uZTiUOsy+g" Content-Disposition: inline X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2022 14:16:26 -0000 --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This creates a couple of record subtypes pointing to each other through access subtypes, and we break the circularity at the latter subtypes. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : If it is a special subtype designated by an access subtype, then defer the completion of incomplete types. --2fHTh5uZTiUOsy+g Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -2134,6 +2134,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) suppress expanding incomplete types. */ gnu_type = make_node (UNCONSTRAINED_ARRAY_TYPE); + /* The component may refer to this type, so defer completion of any + incomplete types. */ if (!definition) { defer_incomplete_level++; @@ -3066,7 +3068,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) process_attributes (&gnu_type, &attr_list, true, gnat_entity); - /* If we are not defining it, suppress expanding incomplete types. */ + /* Some component may refer to this type, so defer completion of any + incomplete types. */ if (!definition) { defer_incomplete_level++; @@ -3439,7 +3442,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) { Entity_Id gnat_base_type = Implementation_Base_Type (gnat_entity); - if (!definition) + /* Some component may refer to this type, so defer completion of any + incomplete types. We also need to do it for the special subtypes + designated by access subtypes in case they are recursive, see the + E_Access_Subtype case below. */ + if (!definition + || (Is_Itype (gnat_entity) + && Is_Frozen (gnat_entity) + && No (Freeze_Node (gnat_entity)))) { defer_incomplete_level++; this_deferred = true; --2fHTh5uZTiUOsy+g--