From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id A4E983884579 for ; Wed, 11 May 2022 08:54:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4E983884579 Received: by mail-wm1-x335.google.com with SMTP id r188-20020a1c44c5000000b003946c466c17so129319wma.4 for ; Wed, 11 May 2022 01:54:42 -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=Z4BpsdTRw7hy+JoZGBJT2TI9sIkr3iTZbKB58y3u2gE=; b=Ju7TIr+/yyQk4bzenJ3cUQArIdjPHht/I1B4nEk7zj6u6tZbAUUInMILYiKZGNZ0ki vyS3nUcbMNhlMOf8MHcOhosesnH+tncTNQSAml5m5M6xYUPXtr7X3Z2cbG/ccFnwTd3m SFKE+B3iCMHocxeEGZqVrCg9VT6lUb276bsr4vpzY/tYjAR20FdR3uOhHkhHbdLwGnAP zsuFU6tkTpJOSvi5bcUmExXMMs71I7iJe27ISFMGIq/f7ZYeDNyyfbvmW2X37caUfbg0 LKWACAP5N4+X1q0Va93v70HcJW4FTOeu4mMMg9faZfqcpqYYAiiphhHoXPL4+y0bCVWW xmAA== X-Gm-Message-State: AOAM532jqkN5nwuwtrVtVeT9b/eQhRK8+PxOp3VZyogAUkbyB9bRbgyS RxClNnLq2lG7H464lCiSwM0LQtfmS1aEWQ== X-Google-Smtp-Source: ABdhPJzrJ5X97ngJZF7YwqliBmNq+KXqAbdJ1uYtb3xlU2SUxMXsvkBOwX0c84QNIfC+u77gVKcFJQ== X-Received: by 2002:a7b:ce0a:0:b0:394:41e:2517 with SMTP id m10-20020a7bce0a000000b00394041e2517mr3717421wmc.135.1652259281449; Wed, 11 May 2022 01:54:41 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id d13-20020a5d4f8d000000b0020c5253d911sm1042891wru.93.2022.05.11.01.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 01:54:40 -0700 (PDT) Date: Wed, 11 May 2022 08:54:40 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Etienne Servais Subject: [Ada] Do not create useless itype in Constrain_Access Message-ID: <20220511085440.GA2167385@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline X-Spam-Status: No, score=-13.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Wed, 11 May 2022 08:54:44 -0000 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In the case of a constrained access definition for a record component we are calling create_itype twice the former not being updated. This leads to a malformed node that crashes -gnatG when predicates are activated. Instead of creating a default Itype for Desig_Subtype, create it with the correct scope in each case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch3.adb (Constrain_Access): Call Desig_Subtype in each if branch to avoid calling it twice. --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13345,11 +13345,12 @@ package body Sem_Ch3 is is T : constant Entity_Id := Entity (Subtype_Mark (S)); Desig_Type : constant Entity_Id := Designated_Type (T); - Desig_Subtype : Entity_Id := Create_Itype (E_Void, Related_Nod); + Desig_Subtype : Entity_Id; Constraint_OK : Boolean := True; begin if Is_Array_Type (Desig_Type) then + Desig_Subtype := Create_Itype (E_Void, Related_Nod); Constrain_Array (Desig_Subtype, S, Related_Nod, Def_Id, 'P'); elsif (Is_Record_Type (Desig_Type) @@ -13445,12 +13446,14 @@ package body Sem_Ch3 is end; end if; + Desig_Subtype := Create_Itype (E_Void, Related_Nod); Constrain_Discriminated_Type (Desig_Subtype, S, Related_Nod, For_Access => True); elsif Is_Concurrent_Type (Desig_Type) and then not Is_Constrained (Desig_Type) then + Desig_Subtype := Create_Itype (E_Void, Related_Nod); Constrain_Concurrent (Desig_Subtype, S, Related_Nod, Desig_Type, ' '); else --2oS5YaxWCcQjTEyO--