From patchwork Tue May 16 08:41:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 94544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp276793vqo; Tue, 16 May 2023 01:58:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZjVkq58cGofPs07iu7zFG3lS0C9aqrGLD1//hjUgQL/cKXoEJ17ApiS1B4fnDTRn4blqi X-Received: by 2002:a17:907:3e27:b0:965:b517:89a4 with SMTP id hp39-20020a1709073e2700b00965b51789a4mr32760333ejc.56.1684227527760; Tue, 16 May 2023 01:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684227527; cv=none; d=google.com; s=arc-20160816; b=raTeVQAAaAd6JMhIgxlD8JMLj1KRh2WIqQCdFByxDBfpJtcKprMLekeW53KUjS+KcL S+aYZJ+0sj2Z+Sls0/XW9DLm+kUscbL0It83uHnR+YShzUL6dXh4vpiODaoAEuBh5Z11 fkxC0rbxmfaHaMfo/RTcEi5qD9gZSSVwf+zSi96+3rVnuDPcPXg7nsE/kYE4O4kL+lSF F+MoCJtsDHpbMLvg3spOByqlbrMw3weOnNeKz0RHlIaCq8792H3GKtFUsNQ5oOWcqbwn sjNEujPYzb4rAH3kgJ1QNGJJuXq5/k20SO8vUly08uj+Bw8aJBiQrKgmhxtDwx1akDwe lW1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=y4ufL05PQqHL559ccR6RanzPBAsEgQU+QWIpEVlP6ks=; b=HFNNmL7YbTazyBlSkr+TXebWakxlngUziP5Tol605vPvj4vuYeNyspjILl1Jfx8kiV tqfCtKDtf7hvwb7OxXqd25rK2chtYAzS/bjvSH1Ku6Z6GiADEFdwJ3VAzHiU7BkHknW7 Vp1YiUWd3Kbl15yoHPT9D50hwo0QQDSqCqMPBOMMzt89qirYKMZXKG1q/Pqq/H77CJ24 Up6Nsvf8t1I5jiAr4oVjIIcu0BQOjOne7RprftHg9qF+3BoFfHrDTU8flgsFaT+mQypL VRf5yN7NEkjMpFfRyxzn0vYbmgob3PvQ4iGLhIoCkIk9skKlsDZroioVyZIbs5kIbf5g DM8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=l14Cqewv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y12-20020a17090629cc00b00965bdbe6dc0si9200768eje.61.2023.05.16.01.58.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=l14Cqewv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A69953945C25 for ; Tue, 16 May 2023 08:51:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A69953945C25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684227062; bh=y4ufL05PQqHL559ccR6RanzPBAsEgQU+QWIpEVlP6ks=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=l14CqewvWIJwvKTU2yRHr+1LT4hxlVdWSOIi+oGUV460yNVis6ghVRo6jWHwTsIS6 lWehZAih2OTKutJ49lFnZQRPQHjBiou9k5zYFjuIT5T20rritvRLHCzr2xmvtfXfw0 spmd6d4oSaj5HgaRy25kC201IPySlS7dBxJDdDaA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 5C820386D610 for ; Tue, 16 May 2023 08:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C820386D610 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f42c865535so80128725e9.1 for ; Tue, 16 May 2023 01:41:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684226491; x=1686818491; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y4ufL05PQqHL559ccR6RanzPBAsEgQU+QWIpEVlP6ks=; b=XYubB9L1yUPbM2LM4mbUrF38gXsZyPsDauZxAxY/VtRFZ/qh5Osa54lR+pQP5NUNij llyU49mI5W6MnhJmoXwNikwgIs5e/YiTE0l0Cav0ze8HH8ZiA8DyymTJ6yutkU6n2tkk AjRV6Y/Vb7+9fRjaPXnyhcITZeWIN7FHc8A/IBjtzm8ZOMFMgGgm+dv4iS3kXWD7UYo6 6cmVv6HxzLqIY4rywQi+Q5mZJS2ey7U9h8HmclZ7nC+g7ynnKWlEH9o33x69x5zq3hLq CUG87WrRATz3ITejeWdLJePBBjLG5rp1twwuX+UG1tN+9DQaVtbtqc0T6Hb0vvAc1kHY UuSA== X-Gm-Message-State: AC+VfDytVwEsJUkpbYVtWCGgTbsaFai5Gg88tBqC+etRA73jHP3TBKyt 7LqQFJo3JuGl4b2pljpZ+DQqgmsyLTVp+1PukTeTCw== X-Received: by 2002:a05:600c:ac6:b0:3f4:2770:f7e9 with SMTP id c6-20020a05600c0ac600b003f42770f7e9mr18286930wmr.17.1684226491242; Tue, 16 May 2023 01:41:31 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id f10-20020a7bcd0a000000b003f4f1b884b3sm1513482wmj.20.2023.05.16.01.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:41:30 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on 'Image applied to array component Date: Tue, 16 May 2023 10:41:29 +0200 Message-Id: <20230516084129.1502331-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766040564122400952?= X-GMAIL-MSGID: =?utf-8?q?1766040564122400952?= From: Eric Botcazou This happens because the array component depends on a discriminant. gcc/ada/ * exp_imgv.adb (Rewrite_Object_Image): If the prefix is a component that depends on a discriminant, create an actual subtype for it. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_imgv.adb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb index 93fdb70306f..257f65badd0 100644 --- a/gcc/ada/exp_imgv.adb +++ b/gcc/ada/exp_imgv.adb @@ -2498,12 +2498,31 @@ package body Exp_Imgv is Attr_Name : Name_Id; Str_Typ : Entity_Id) is + Ptyp : Entity_Id; + begin + Ptyp := Etype (Pref); + + -- If the prefix is a component that depends on a discriminant, then + -- create an actual subtype for it. + + if Nkind (Pref) = N_Selected_Component then + declare + Decl : constant Node_Id := + Build_Actual_Subtype_Of_Component (Ptyp, Pref); + begin + if Present (Decl) then + Insert_Action (N, Decl); + Ptyp := Defining_Identifier (Decl); + end if; + end; + end if; + Rewrite (N, Make_Attribute_Reference (Sloc (N), - Prefix => New_Occurrence_Of (Etype (Pref), Sloc (N)), + Prefix => New_Occurrence_Of (Ptyp, Sloc (N)), Attribute_Name => Attr_Name, - Expressions => New_List (Relocate_Node (Pref)))); + Expressions => New_List (Unchecked_Convert_To (Ptyp, Pref)))); Analyze_And_Resolve (N, Str_Typ); end Rewrite_Object_Image;