From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 2A0C43858281; Tue, 20 Jun 2023 07:46:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A0C43858281 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687247207; bh=rJrU9yNcCYyVU6lxRuPcudGIHRFJ+MmjzK+t45xi09w=; h=From:To:Subject:Date:From; b=JjJeF7AJVbWNsl2ZovIfff9k6rqwBzS83K0lVI7gqFzevP/Cj7+tpuyL8OXjxlDGC KWhnsisYF1+Wv/RKy5Ma27CZd5jXytsvnBe570senVJlUhYdx7sz8cSAsn+cMfIMlL Gmu0KJjKUUVTTA99rdS4qQBIH9IjzKOfHpcmEW20= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1972] ada: Fix bug in predicate checks with address clauses X-Act-Checkin: gcc X-Git-Author: Bob Duff X-Git-Refname: refs/heads/master X-Git-Oldrev: d39664b659f2442a456be865ee6adcfe1a4a5aed X-Git-Newrev: 970ee828e75fb3f67a7dc8dd8108e9a2f23b997b Message-Id: <20230620074647.2A0C43858281@sourceware.org> Date: Tue, 20 Jun 2023 07:46:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:970ee828e75fb3f67a7dc8dd8108e9a2f23b997b commit r14-1972-g970ee828e75fb3f67a7dc8dd8108e9a2f23b997b Author: Bob Duff Date: Wed May 31 09:21:44 2023 -0400 ada: Fix bug in predicate checks with address clauses This patch fixes a compiler bug triggered by having a type with some defaulted components, and a predicate, and an object of that type with an address clause. In this case, the compiler was crashing. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Remove predicate-check generation if there is an address clause. These are unnecessary, and cause gigi to crash. * exp_util.ads (Following_Address_Clause): Remove obsolete "???" comments. The suggested changes were done long ago. Diff: --- gcc/ada/exp_util.ads | 7 ------- gcc/ada/sem_ch3.adb | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 24065b6f7b6..02324d23db0 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -647,13 +647,6 @@ package Exp_Util is -- current declarative part to look for an address clause for the object -- being declared, and returns the clause if one is found, returns -- Empty otherwise. - -- - -- Note: this function can be costly and must be invoked with special care. - -- Possibly we could introduce a flag at parse time indicating the presence - -- of an address clause to speed this up??? - -- - -- Note: currently this function does not scan the private part, that seems - -- like a potential bug ??? type Force_Evaluation_Mode is (Relaxed, Strict); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index fb63690803b..85019dfffa5 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4690,6 +4690,16 @@ package body Sem_Ch3 is elsif No (E) and then Is_Null_Record_Type (T) then null; + -- If there is an address clause for this object, do not generate a + -- predicate check here. It will be generated later, at the freezng + -- point. It would be wrong to generate references to the object + -- here, before the address has been determined. + + elsif Has_Aspect (Id, Aspect_Address) + or else Present (Following_Address_Clause (N)) + then + null; + -- Do not generate a predicate check if the initialization expression -- is a type conversion whose target subtype statically matches the -- object's subtype because the conversion has been subjected to the @@ -4709,7 +4719,6 @@ package body Sem_Ch3 is declare Check : constant Node_Id := Make_Predicate_Check (T, New_Occurrence_Of (Id, Loc)); - begin if No (Next_Decl) then Append_To (List_Containing (N), Check);