From patchwork Tue Aug 6 09:02:33 2024 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: 95358 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8573E385E83A for ; Tue, 6 Aug 2024 09:04:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 874423857C4F for ; Tue, 6 Aug 2024 09:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 874423857C4F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 874423857C4F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; cv=none; b=k+KVp2CZ9V7JhMq67cNu3tV7nFCxR7Y+HQz6sLFQ1++wtMSyP3hhjeejjwOv6X0DxjI1o+mmRak5+E/n0trlWfNedRPVchf9WwLW6b36dITjoJwp0iYgwi38Q32vdu4BaSZN+/80f1ZMWoUgcqKovTbn1xyQPUJa9tGSssM8wwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; c=relaxed/simple; bh=hCcMHNaI91NXaYmjXjrxirExM/m/WcqokO5odQlfnEs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IF93rtj1gBrPxqGSnBQ0PSizeNBKb8PAipjWL6CKa21qHm8CT22Kk9B89VXyVTv2uQB0Om4nWgt7zD5obnAAYw+7xXOCNDvngswnGyvivEbqq0yMHP3q7i/KIpYvf/lJP3DkZSdpQw8u9TXCXv9a9zTVEsq/xFDL9y7JYf9tjPg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso2250455e9.1 for ; Tue, 06 Aug 2024 02:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934974; x=1723539774; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XRRgdmjMThLJGvEBrYWsNbRwG3TjmIP5wnzPD8u0TRg=; b=XqNwI4AJkZ5RU4en4OuSpjypOxzkqdvCsMQkKCuYUjSa75nDM/yo+opemK4FccDNj0 zhUOgvR7FREEuqpZY+HjBe2faChWLGwlMeBBdZn+/ISd5RWWyCkY5qDUop4ZgEFi+hOl R3nzAroFC9L5NJUQs+Q7Z9bcDq958HqQ40uq0jvARJf7bedVjjOy40gTPuLxajfKZYWn 3vsdUmtQNLafLjsiBK6NB3wWKj5IcV4YRisf4PWXa+DF0xjVpMlzGGmEbTaOfHh/O798 Cdnmi7pqc2rpEGPBvv0os+XoIOhgjnbkOmrqzbWCwCWwTBaAee/Q/DiImoK1017GsWfD kz/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934974; x=1723539774; 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=XRRgdmjMThLJGvEBrYWsNbRwG3TjmIP5wnzPD8u0TRg=; b=fiHSi8Y8ZhPzSuyBH6Pjx1VuiErTnn19DF4EEc1193BIHEwJGXsR3XnzP8gfxzOe4l fQywuuW+8+P01A11GgJz1LxtI0zJNy9Vfzlmmvr7Sop4AqyQobcmIKFwS2fH5qn56AGE FL2NAdU3gyXsgCXTwVPN1BIGGcbb6syyk+eP1fRBVf/gqi5uhKGWc3XZGzKNMfcYHvNL sPbsF9ebqaSiFpfK6oQPLnfWczmxVSJ+lUb4FNgt1WlJMVckN4qcfWIoPchbC5ltHLpA 19NPjKp8+68771aStZMCPpkIWRN3Ru76Ng+Z5dLcX3k8uCvWAcvFejbj79It6odV3Ary qgqA== X-Gm-Message-State: AOJu0YzoGGbkHVh8810GTDEiSkP/IqxRknJvsuBUXYsLaTn1lrIK/EB/ I3us5Xyj8cRaLLuNo2euQV5U7jZb31rR9h17UA5IwDpssgzSTlW1PrARu//jWs29p/dVBFZRQLQ Dxw== X-Google-Smtp-Source: AGHT+IHap/csvi/ntFO3kEa5jpJCmj2EC2UOHwRqqP4zjkpf/vvg09sDaZzkU89qpZCXATWBd+w2mg== X-Received: by 2002:a05:600c:310e:b0:426:68dd:bc92 with SMTP id 5b1f17b1804b1-428e6aecaffmr86083345e9.5.1722934973868; Tue, 06 Aug 2024 02:02:53 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:53 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 1/9] ada: Reject use-clause conflicts in the run-time library Date: Tue, 6 Aug 2024 11:02:33 +0200 Message-ID: <20240806090241.576862-1-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Bob Duff This patch fixes a bug where GNAT would fail to detect certain errors when compiling the run-time library. In particular, if two overloaded homographs are both directly visible, it would pick one, rather than complaining about the ambiguity. The problem was that some special-purpose code in Sem_Ch8 was trying to make a user name take precedence over some run-time library declaration that (incorrectly) appears to be visible because of rtsfind. The solution is to disable that code while compiling the run-time library itself. In addition, we fix the newly-found errors in the run-time library. gcc/ada/ * sem_ch8.adb (Find_Direct_Name): Disable the special-purpose code when we are actually compiling the run-time library itself. * libgnarl/a-exetim__posix.adb: Fix newly-found use-clause conflicts. * libgnat/a-direct.adb: Likewise. * libgnat/a-nbnbin.adb: Likewise. * libgnat/a-timoio__128.adb: Likewise. * libgnat/a-timoio.adb: Likewise. * libgnat/a-wtmoio__128.adb: Likewise. * libgnat/a-wtmoio.adb: Likewise. * libgnat/a-ztmoio__128.adb: Likewise. * libgnat/a-ztmoio.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnarl/a-exetim__posix.adb | 4 ++-- gcc/ada/libgnat/a-direct.adb | 4 ++-- gcc/ada/libgnat/a-nbnbin.adb | 3 ++- gcc/ada/libgnat/a-timoio.adb | 5 +++++ gcc/ada/libgnat/a-timoio__128.adb | 8 ++++++++ gcc/ada/libgnat/a-wtmoio.adb | 5 +++++ gcc/ada/libgnat/a-wtmoio__128.adb | 8 ++++++++ gcc/ada/libgnat/a-ztmoio.adb | 5 +++++ gcc/ada/libgnat/a-ztmoio__128.adb | 8 ++++++++ gcc/ada/sem_ch8.adb | 4 +++- 10 files changed, 48 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnarl/a-exetim__posix.adb b/gcc/ada/libgnarl/a-exetim__posix.adb index 05c55c567fa..6f3eecb2fe6 100644 --- a/gcc/ada/libgnarl/a-exetim__posix.adb +++ b/gcc/ada/libgnarl/a-exetim__posix.adb @@ -113,14 +113,14 @@ package body Ada.Execution_Time is function clock_gettime (clock_id : Interfaces.C.int; tp : access timespec) - return int; + return Interfaces.C.int; pragma Import (C, clock_gettime, "clock_gettime"); -- Function from the POSIX.1b Realtime Extensions library function pthread_getcpuclockid (tid : Thread_Id; clock_id : access Interfaces.C.int) - return int; + return Interfaces.C.int; pragma Import (C, pthread_getcpuclockid, "pthread_getcpuclockid"); -- Function from the Thread CPU-Time Clocks option diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb index adff12277e8..fbf249cd35e 100644 --- a/gcc/ada/libgnat/a-direct.adb +++ b/gcc/ada/libgnat/a-direct.adb @@ -1292,7 +1292,7 @@ package body Ada.Directories is Dir_Pointer : Dir_Type_Value; File_Name_Addr : Address; File_Name_Len : aliased Integer; - Pattern_Regex : Regexp; + Pattern_Regex : System.Regexp.Regexp; Call_Result : Integer; pragma Warnings (Off, Call_Result); @@ -1377,7 +1377,7 @@ package body Ada.Directories is Compose (Directory, File_Name) & ASCII.NUL; Path : String renames Path_C (Path_C'First .. Path_C'Last - 1); - Attr : aliased File_Attributes; + Attr : aliased System.File_Attributes.File_Attributes; Exists : Integer; Error : Integer; diff --git a/gcc/ada/libgnat/a-nbnbin.adb b/gcc/ada/libgnat/a-nbnbin.adb index 91074cfbc5c..2d140a49e53 100644 --- a/gcc/ada/libgnat/a-nbnbin.adb +++ b/gcc/ada/libgnat/a-nbnbin.adb @@ -69,7 +69,8 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is package Bignums is new System.Generic_Bignums (Bignum, Allocate_Bignum, Free_Bignum, To_Bignum); - use Bignums, System; + use System, Bignums; + subtype Bignum is Bignums.Bignum; function Get_Bignum (Arg : Big_Integer) return Bignum is (if Arg.Value.C = System.Null_Address diff --git a/gcc/ada/libgnat/a-timoio.adb b/gcc/ada/libgnat/a-timoio.adb index 65222c1ea0d..eec92e3959a 100644 --- a/gcc/ada/libgnat/a-timoio.adb +++ b/gcc/ada/libgnat/a-timoio.adb @@ -36,11 +36,14 @@ with System.Img_LLB; use System.Img_LLB; with System.Img_LLU; use System.Img_LLU; with System.Img_LLW; use System.Img_LLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; package body Ada.Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Text_IO.Integer_Aux (Unsigned, @@ -49,6 +52,8 @@ package body Ada.Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Text_IO.Integer_Aux (Long_Long_Unsigned, diff --git a/gcc/ada/libgnat/a-timoio__128.adb b/gcc/ada/libgnat/a-timoio__128.adb index fbf31cf8035..d85fb059ce6 100644 --- a/gcc/ada/libgnat/a-timoio__128.adb +++ b/gcc/ada/libgnat/a-timoio__128.adb @@ -39,12 +39,15 @@ with System.Img_LLLB; use System.Img_LLLB; with System.Img_LLLU; use System.Img_LLLU; with System.Img_LLLW; use System.Img_LLLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; with System.Val_LLLU; use System.Val_LLLU; package body Ada.Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Text_IO.Integer_Aux (Unsigned, @@ -53,6 +56,8 @@ package body Ada.Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Text_IO.Integer_Aux (Long_Long_Unsigned, @@ -61,6 +66,9 @@ package body Ada.Text_IO.Modular_IO is Set_Image_Width_Long_Long_Unsigned, Set_Image_Based_Long_Long_Unsigned); + subtype Long_Long_Long_Unsigned is + System.Unsigned_Types.Long_Long_Long_Unsigned; + package Aux_LLLU is new Ada.Text_IO.Integer_Aux (Long_Long_Long_Unsigned, diff --git a/gcc/ada/libgnat/a-wtmoio.adb b/gcc/ada/libgnat/a-wtmoio.adb index 6f50bf590b0..f83bb700773 100644 --- a/gcc/ada/libgnat/a-wtmoio.adb +++ b/gcc/ada/libgnat/a-wtmoio.adb @@ -36,6 +36,7 @@ with System.Img_LLB; use System.Img_LLB; with System.Img_LLU; use System.Img_LLU; with System.Img_LLW; use System.Img_LLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; with System.WCh_Con; use System.WCh_Con; @@ -43,6 +44,8 @@ with System.WCh_WtS; use System.WCh_WtS; package body Ada.Wide_Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Wide_Text_IO.Integer_Aux (Unsigned, @@ -51,6 +54,8 @@ package body Ada.Wide_Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Wide_Text_IO.Integer_Aux (Long_Long_Unsigned, diff --git a/gcc/ada/libgnat/a-wtmoio__128.adb b/gcc/ada/libgnat/a-wtmoio__128.adb index 1a11aeea615..83ab19d2965 100644 --- a/gcc/ada/libgnat/a-wtmoio__128.adb +++ b/gcc/ada/libgnat/a-wtmoio__128.adb @@ -39,6 +39,7 @@ with System.Img_LLLB; use System.Img_LLLB; with System.Img_LLLU; use System.Img_LLLU; with System.Img_LLLW; use System.Img_LLLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; with System.Val_LLLU; use System.Val_LLLU; @@ -47,6 +48,8 @@ with System.WCh_WtS; use System.WCh_WtS; package body Ada.Wide_Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Wide_Text_IO.Integer_Aux (Unsigned, @@ -55,6 +58,8 @@ package body Ada.Wide_Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Wide_Text_IO.Integer_Aux (Long_Long_Unsigned, @@ -63,6 +68,9 @@ package body Ada.Wide_Text_IO.Modular_IO is Set_Image_Width_Long_Long_Unsigned, Set_Image_Based_Long_Long_Unsigned); + subtype Long_Long_Long_Unsigned is + System.Unsigned_Types.Long_Long_Long_Unsigned; + package Aux_LLLU is new Ada.Wide_Text_IO.Integer_Aux (Long_Long_Long_Unsigned, diff --git a/gcc/ada/libgnat/a-ztmoio.adb b/gcc/ada/libgnat/a-ztmoio.adb index 512cd803f13..6f39e533167 100644 --- a/gcc/ada/libgnat/a-ztmoio.adb +++ b/gcc/ada/libgnat/a-ztmoio.adb @@ -36,6 +36,7 @@ with System.Img_LLB; use System.Img_LLB; with System.Img_LLU; use System.Img_LLU; with System.Img_LLW; use System.Img_LLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; with System.WCh_Con; use System.WCh_Con; @@ -43,6 +44,8 @@ with System.WCh_WtS; use System.WCh_WtS; package body Ada.Wide_Wide_Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Wide_Wide_Text_IO.Integer_Aux (Unsigned, @@ -51,6 +54,8 @@ package body Ada.Wide_Wide_Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Wide_Wide_Text_IO.Integer_Aux (Long_Long_Unsigned, diff --git a/gcc/ada/libgnat/a-ztmoio__128.adb b/gcc/ada/libgnat/a-ztmoio__128.adb index b62a41dccc7..3410513aded 100644 --- a/gcc/ada/libgnat/a-ztmoio__128.adb +++ b/gcc/ada/libgnat/a-ztmoio__128.adb @@ -39,6 +39,7 @@ with System.Img_LLLB; use System.Img_LLLB; with System.Img_LLLU; use System.Img_LLLU; with System.Img_LLLW; use System.Img_LLLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; with System.Val_LLLU; use System.Val_LLLU; @@ -47,6 +48,8 @@ with System.WCh_WtS; use System.WCh_WtS; package body Ada.Wide_Wide_Text_IO.Modular_IO is + subtype Unsigned is System.Unsigned_Types.Unsigned; + package Aux_Uns is new Ada.Wide_Wide_Text_IO.Integer_Aux (Unsigned, @@ -55,6 +58,8 @@ package body Ada.Wide_Wide_Text_IO.Modular_IO is Set_Image_Width_Unsigned, Set_Image_Based_Unsigned); + subtype Long_Long_Unsigned is System.Unsigned_Types.Long_Long_Unsigned; + package Aux_LLU is new Ada.Wide_Wide_Text_IO.Integer_Aux (Long_Long_Unsigned, @@ -63,6 +68,9 @@ package body Ada.Wide_Wide_Text_IO.Modular_IO is Set_Image_Width_Long_Long_Unsigned, Set_Image_Based_Long_Long_Unsigned); + subtype Long_Long_Long_Unsigned is + System.Unsigned_Types.Long_Long_Long_Unsigned; + package Aux_LLLU is new Ada.Wide_Wide_Text_IO.Integer_Aux (Long_Long_Long_Unsigned, diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index c77a69e5118..99060061471 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -6323,7 +6323,9 @@ package body Sem_Ch8 is Nvis_Messages; goto Done; - elsif Is_Predefined_Unit (Current_Sem_Unit) then + elsif Is_Predefined_Unit (Current_Sem_Unit) + and then not Is_Predefined_Unit (Main_Unit) + then -- A use clause in the body of a system file creates conflict -- with some entity in a user scope, while rtsfind is active. -- Keep only the entity coming from another predefined unit. From patchwork Tue Aug 6 09:02:34 2024 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: 95356 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9398E385DDDF for ; Tue, 6 Aug 2024 09:03:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 90FF6385840F for ; Tue, 6 Aug 2024 09:02:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90FF6385840F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 90FF6385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; cv=none; b=YPuMqBcWafZy6nnzll9/iY40aNm1pzGIfV5uElPOJGKy0JV9IkhGxzaOVAX8BljjeDTOLpvpMKh2rA4vxYkAnLcSVOQ8U5KCcALL6QW75hQOI6ZMJdMPO92UMYM9H0BtrP24rpl0jifJQn5mb9oyYIGzBeUsqY2nSjGxjlDag44= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; c=relaxed/simple; bh=K18v/G5Lwa39mD6S//npZY2zzv6kXLfkJVYzHxTxRvI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BuxkuXdgrG41yCNo1JA5HxH6GfHt9OD7lqFvU6O8KqOa3OP1QZPs2otSmH4QQbIqPFkPWlbwgmb/1uITtjp/NPbKTqnJbD/zs++NW++54E0T9pbR/J81sjDkldms6DtUkV7lsqUp0vjEpuqZR6lqKGAXBGc0wVlmzN+Y9/lLy9M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2f1798eaee6so4341781fa.0 for ; Tue, 06 Aug 2024 02:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934975; x=1723539775; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OXio9CW75ywa+CDqLxk6ccbqZN2VruGVqCndNNe1ZR0=; b=A7+N+130iw4Skh/Y6VndasydoeaIim/bUvbHJ4QBJS594VJTeFp7pXodQAr/C4x2Tw JxoJxYoAmV70ygQT41nBGhYiu36ETgaOPlDx2n2lFax+4IFvQfWQPPfX8/t1OfcEfplc p0KhiwpwHe73vwZkhtuyvpYpv0FKEmpMJ5Ny5IH/cRlZl9nwtIdOa9fzfLYALu2ZFjUo ILeQnsks6ljhhC0LeLUK7CsrEbu9eOaHq0XilYIhFRGMVXrdyfGH3/FOTlaQKn9sZLwD vDquprMWE8MXAvMZQexaBQIhqqilYlHZwE4Qtc7pNmM++rmfVDcxZjToEbUDU9sXvdAm T1/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934975; x=1723539775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OXio9CW75ywa+CDqLxk6ccbqZN2VruGVqCndNNe1ZR0=; b=TUH4xHo0P9bN13l99DrgyzGjKFFAHU2YXOLoCycHN/8TaAiL7yzAiNlpLHyp30S5Fp r6qu7iF/7VJoFCfUCKgWNBycS9QPpn2twObY//5g+ltJubsIRkJRXT2JlgO3zaMyWF5v Ui1f7zdReMvF5PbP8sRDOKpZgcq27UjEA0BlUd6pcWeJcTZxkE4Q3juU0sF7QAZmcNvo Q0OefE0+e17eFwOQkK6oIUuN1Kmtc3T6214v/kG7vWzYAQPpgSgd5B0rze1VtdSDc62B EHopDpP/2aMC5WgH5s25suMr+YytDeqeFesYcRxKkm/i8BddiYBFgJy2Yecde7Q+JXdK iWvg== X-Gm-Message-State: AOJu0YxWqaXETdvndu1AWG916s2v+j78Ddjf/W1gkepRvTVEoCCW1Y/B T5b2Nw+FnQID9JXl+J0EHLGaWaTv2L5D0khWGhiLN/+Pg36Im31OnhVlH8DxGw7hJ+pp/NuCK5V Ihw== X-Google-Smtp-Source: AGHT+IFJq/pJaYsEmO5McsLVNhrW/WF9VGfKdj9+FXg+qGh3nDX8Fv8gKkYK0y6UFxCqaUuqXoKgvw== X-Received: by 2002:a2e:9689:0:b0:2ef:2d3a:e70a with SMTP id 38308e7fff4ca-2f15aa93150mr90117501fa.18.1722934974626; Tue, 06 Aug 2024 02:02:54 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:54 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED 2/9] ada: Fix propagation of SPARK_Mode for renaming-as-body Date: Tue, 6 Aug 2024 11:02:34 +0200 Message-ID: <20240806090241.576862-2-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Yannick Moy The value of SPARK_Mode associated with a renaming-as-body might not be the correct one, when the private part of the package containing the declaration has SPARK_Mode Off while the public part has SPARK_Mode On. This may lead to analysis of code by GNATprove that should not be analyzed. gcc/ada/ * freeze.adb (Build_Renamed_Body): Propagate SPARK_Pragma to body build from renaming, so that locally relevant value is taken into account. * sem_ch6.adb (Analyze_Expression_Function): Propagate SPARK_Pragma to body built from expression function, so that locally relevant value is taken into account. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 7 +++++++ gcc/ada/sem_ch6.adb | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index c8d20d020c7..a947018052c 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -586,6 +586,13 @@ package body Freeze is Next (Param_Spec); end loop; + -- Copy SPARK pragma from renaming declaration + + Set_SPARK_Pragma + (Defining_Unit_Name (Spec), SPARK_Pragma (New_S)); + Set_SPARK_Pragma_Inherited + (Defining_Unit_Name (Spec), SPARK_Pragma_Inherited (New_S)); + -- In GNATprove, prefer to generate an expression function whenever -- possible, to benefit from the more precise analysis in that case -- (as if an implicit postcondition had been generated). diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 0988fad97e8..d3912ffc9d5 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -333,6 +333,15 @@ package body Sem_Ch6 is New_Spec := Copy_Subprogram_Spec (Spec); Prev := Current_Entity_In_Scope (Defining_Entity (Spec)); + -- Copy SPARK pragma from expression function + + Set_SPARK_Pragma + (Defining_Unit_Name (New_Spec), + SPARK_Pragma (Defining_Unit_Name (Spec))); + Set_SPARK_Pragma_Inherited + (Defining_Unit_Name (New_Spec), + SPARK_Pragma_Inherited (Defining_Unit_Name (Spec))); + -- If there are previous overloadable entities with the same name, -- check whether any of them is completed by the expression function. -- In a generic context a formal subprogram has no completion. From patchwork Tue Aug 6 09:02:35 2024 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: 95357 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7284385DDF3 for ; Tue, 6 Aug 2024 09:03:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 1A8ED385841C for ; Tue, 6 Aug 2024 09:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A8ED385841C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A8ED385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; cv=none; b=Pye/ZvRcRmjgDOzM+hi19XklepnZNvfuUibrK5Bb7WJs7TSZ/aN1C+ZnIzccukA45VmxgS2bf8JKWkMKsQn2bLtPQcOTWxb8r9XH38fGpo++PsrY/U4hSggTupcu00pX3PUQFz8zTVze5l0Tp6fN0Xtl/1gcKSKlvNEc02UfKKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; c=relaxed/simple; bh=eU0n6GV+UwSfcoSTuEwvHDuqasS/p9pX/7eSO2gAjZI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=L6gypo0Cu+3CFUNf9AGhEwmZ4KUEsBGD08+L69KIhU2gqWmdZDZGgoosW5p32D6hfmseKh8FmcVAy3mlMvxElF9a9pWMMH95O260jAiufVVquncXO/rMaskPzOeZry3kSnkH8XRnmHsGf23LD8Oz80736lzXx+F46eTkM1J9GH4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ef2c56da6cso3439151fa.1 for ; Tue, 06 Aug 2024 02:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934975; x=1723539775; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ndq8PN1PmCKhCne+XOiZRdJedHfwFtUEzyLgItmrHk8=; b=EsQrvaVTHnFltck9Zt74NgYjIBY1OZVDpw4Wd/S0pxhEnVFi5vFpzDOYUIpSo4W1OE EAYddoY9uidusag1y5DLUyClOqWL0XAKVFE1X/rjEjz9TzfB//hW8hAA/s2tHASjCh7p 07/sjQ+YLhhd56DI/p0PSfMglN5Xk6su1atxOaGGKm7O7Ly+OqXBqm9zkOd9bT0hwKqb 8p+trYEFDDl4/P0hGkknsuT/TJj+zTRUFWVhrBpXFBQGFTN240ZwREvWPBhgVBla6Zho JVCVWNrm483cBFSiOx85Re8lnga/1tKZDjlZIzZWcl0DdEAlVY1p14FxuA1C9LOsAcZZ lKSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934975; x=1723539775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ndq8PN1PmCKhCne+XOiZRdJedHfwFtUEzyLgItmrHk8=; b=Mx0qqic8nOR00yJ8izNY4WuC8qnQj6DSG4p3ki+6n8NvOdcqVpVLQO9PFU3rKD9n8/ umVdgPqTwzrD6hworCLq2GQwMGkqx33d4JctnmN050LcIVwbnbbbVlIaVcQN/8AMpHYv rnqGvdi02w1R0cjHVUD67ZVnUxqn0oZdNA6SeG2I3168Of6/vOCnpUVVNw1BYkXrDHBz KoMrO1uFJA/jJSlZFtJTwCjq5eX3DddmO+I/oomzrjmaSEFLidgrPOqERlL0bXxH0tn/ N6P61Ra32HiQX9X6PM2dEYIHxK9+VqtBqWsZIOgKyYLvc5g8WOZgirSGSBzk+G9pSUih 8I5A== X-Gm-Message-State: AOJu0YxMvhad2HPDmwJbIeM3XkAFRNw40FWu8hriErmpNcmD93Ffz61J QbhBy251UFxjsgI1J1rbNv4KhQMfbVmJcCXOYnIAWUtABRJS9PDlWEKvvHafAC4PFMrvNTd7lyi I7w== X-Google-Smtp-Source: AGHT+IHvuuoYa2wtW8kdoTA5ZkkQkk+2/8SDFigUkligwWt4F4w39VPdnv52wnA5dMyzuB22dcYvMA== X-Received: by 2002:a2e:be94:0:b0:2f1:6cd4:a820 with SMTP id 38308e7fff4ca-2f16cd4a8eemr84308871fa.31.1722934975358; Tue, 06 Aug 2024 02:02:55 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:54 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 3/9] ada: Use fully qualified in the runtime library Date: Tue, 6 Aug 2024 11:02:35 +0200 Message-ID: <20240806090241.576862-3-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Viljar Indus gcc/ada/ * libgnarl/s-taprop__mingw.adb: Use fully qualified names to avoid ambiguity. * libgnarl/s-taprop__posix.adb: Likewise. * libgnarl/s-taprop__qnx.adb: Likewise. * libgnarl/s-taprop__rtems.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnarl/s-taprop__mingw.adb | 2 +- gcc/ada/libgnarl/s-taprop__posix.adb | 2 +- gcc/ada/libgnarl/s-taprop__qnx.adb | 16 ++++++++-------- gcc/ada/libgnarl/s-taprop__rtems.adb | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/ada/libgnarl/s-taprop__mingw.adb b/gcc/ada/libgnarl/s-taprop__mingw.adb index f77d71970b8..8c7f59f1c5d 100644 --- a/gcc/ada/libgnarl/s-taprop__mingw.adb +++ b/gcc/ada/libgnarl/s-taprop__mingw.adb @@ -1035,7 +1035,7 @@ package body System.Task_Primitives.Operations is ------------------- function RT_Resolution return Duration is - Ticks_Per_Second : aliased LARGE_INTEGER; + Ticks_Per_Second : aliased System.OS_Interface.LARGE_INTEGER; begin QueryPerformanceFrequency (Ticks_Per_Second'Access); return Duration (1.0 / Ticks_Per_Second); diff --git a/gcc/ada/libgnarl/s-taprop__posix.adb b/gcc/ada/libgnarl/s-taprop__posix.adb index fb70aaf4976..3d76679ad4a 100644 --- a/gcc/ada/libgnarl/s-taprop__posix.adb +++ b/gcc/ada/libgnarl/s-taprop__posix.adb @@ -209,7 +209,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); diff --git a/gcc/ada/libgnarl/s-taprop__qnx.adb b/gcc/ada/libgnarl/s-taprop__qnx.adb index f475c05c562..39e6983f438 100644 --- a/gcc/ada/libgnarl/s-taprop__qnx.adb +++ b/gcc/ada/libgnarl/s-taprop__qnx.adb @@ -119,7 +119,7 @@ package body System.Task_Primitives.Operations is function Initialize_Lock (L : not null access RTS_Lock; - Prio : Any_Priority) return int; + Prio : Any_Priority) return Interfaces.C.int; -- Initialize the lock L. If Ceiling_Support is True, then set the ceiling -- to Prio. Returns 0 for success, or ENOMEM for out-of-memory. @@ -220,7 +220,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); @@ -333,11 +333,11 @@ package body System.Task_Primitives.Operations is function Initialize_Lock (L : not null access RTS_Lock; - Prio : Any_Priority) return int + Prio : Any_Priority) return Interfaces.C.int is Attributes : aliased pthread_mutexattr_t; - Result : int; - Result_2 : aliased int; + Result : Interfaces.C.int; + Result_2 : aliased Interfaces.C.int; begin Result := pthread_mutexattr_init (Attributes'Access); @@ -425,9 +425,9 @@ package body System.Task_Primitives.Operations is (L : not null access Lock; Ceiling_Violation : out Boolean) is Self : constant pthread_t := pthread_self; - Result : int; - Policy : aliased int; - Ceiling : aliased int; + Result : Interfaces.C.int; + Policy : aliased Interfaces.C.int; + Ceiling : aliased Interfaces.C.int; Sched : aliased struct_sched_param; begin diff --git a/gcc/ada/libgnarl/s-taprop__rtems.adb b/gcc/ada/libgnarl/s-taprop__rtems.adb index ea8422cb454..0a33c194ec1 100644 --- a/gcc/ada/libgnarl/s-taprop__rtems.adb +++ b/gcc/ada/libgnarl/s-taprop__rtems.adb @@ -200,7 +200,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); @@ -304,7 +304,7 @@ package body System.Task_Primitives.Operations is Res := mprotect (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, - size_t (Page_Size), + Interfaces.C.size_t (Page_Size), prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if; From patchwork Tue Aug 6 09:02:36 2024 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: 95362 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12298385B508 for ; Tue, 6 Aug 2024 09:05:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id AD57E385842A for ; Tue, 6 Aug 2024 09:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD57E385842A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AD57E385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; cv=none; b=QYaBYbQdYNoEsPntEfzd7qdyFIdqIQoh6EIiwYeptiqbwbvjfRe5zs/MaKYRUHnXbJ+0jqy/ci06EG1hGsvzlpvEHkL4cJHSqfV03VHkH5m3rys5L0cQj/yNSEwqJtl6Y1EkIXSUFvRBIGYOWG+gQx7SeutJnWQg8YKVCW0W7NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934979; c=relaxed/simple; bh=BTeRZ4HixhJu4u17DRyLcdjZimqZw9/tzS3zaxCOkB8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=g5F4imnRZawmPj6M/39HeeupNz6e+i2EK58O+eUcu3Ef5HrT6V8YtkthIqzkfNmSZxf5uQx/wLZW6fklAEAMMmM1/9Cwb7wKwTFUM35RM5OqTNpNI0XJXoPmuy8nJocpRp98/nrfY7FZjbkooebagMaV955M1c/4/sgVOxODsMs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4280c55e488so3361005e9.0 for ; Tue, 06 Aug 2024 02:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934976; x=1723539776; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hDKxELwODCJUVPumFPV66hwuVCvtIc7h6SLjLBPCYm8=; b=Swcpq0isEcY8mEUsiHKprxgJmohbk1zcmZRuFM+m6GlyzNM65gwHczyBqbVIJfvY/T zzcZFHTbXLSSOuT4zCXeRlZKG/x9+rsazJsSvOQ3sNcO/KLGtEnIug2O00UR36FIJ8eh LikU1O+XlDAEKq9mD1En4UWjpY+tmM85LzvEo12pED9SB7PHqYRTksqoTI8vT1zVn/qk A/MwNJ6lpo+3/oG3Pfodl3RM3vcO5YB9JoFR+8P2NXI+rOUmdzTNyNsDJVvpj2FU1Zgv YyoOM5B4iIzBrYtN5lS0LOyGXGcOeGG0ANXZRhPlmFjSF7Ak4uFN+apN+GQ4kpSylIIn mkPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934976; x=1723539776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hDKxELwODCJUVPumFPV66hwuVCvtIc7h6SLjLBPCYm8=; b=H6rnICBLoiZsC2Usndndzxedg6Dr0Mr1X9m/T0RS4szWiud7jtHQ6tF+oZqS2+XKcb ohf1OSoY8yZ1p5P9UZ68l5PlOGR6FpcU48SJawpv8QDR36ggdei29plOZ+szS5pVborS WEINYR3WqhK4+h2jSBa0L0R3KaWaP74OCchc3uA4QT1RqCRhjmdalxv3K+176XgssrvW 8Vt+pq7TxV0ZuW47Onv5VTuwDJ4Y0knrvQqZ7vWcgb5xoB3aO5P7k79p/tvcfls5jITL wqkbvYrfwzgMtzspcCBIAZzgPKHSjoXmeGjjAUBL2hH1X3W7y6A3z8o/2RzYP5erHc1r xiAg== X-Gm-Message-State: AOJu0YzKXIhjXFnGU+ZWQhXuTa/gZ9zxERzvqChu+eVLQ/ozxqqadl0M 7wu+D0XMuNqZByJEnG5JNo8pbnsBk3CvcJ1qa943hQIa6hIIZeWVs0JnujzDzROEbOtKoe8KQ2M 6Uw== X-Google-Smtp-Source: AGHT+IG1fXyyMcqupJLHhLsRPT+bLbrWizpRCuIkJvRXKyZzrXuUYu/+lM4gl0gmwmy9G1IwMYabqA== X-Received: by 2002:a1c:7714:0:b0:428:f0fc:4e54 with SMTP id 5b1f17b1804b1-428f0fc538amr75561665e9.11.1722934976091; Tue, 06 Aug 2024 02:02:56 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:55 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 4/9] ada: Assert failure in repinfo Date: Tue, 6 Aug 2024 11:02:36 +0200 Message-ID: <20240806090241.576862-4-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Javier Miranda Using switch gnatR4, the frontend crashes when generating information for a private record type. gcc/ada/ * repinfo.adb (List_Record_Info): Handle private record types. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/repinfo.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 7dada5358f7..c08a232a3ab 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -521,7 +521,11 @@ package body Repinfo is elsif Is_Record_Type (E) then if List_Representation_Info >= 1 then - List_Record_Info (E, Bytes_Big_Endian); + if Is_Private_Type (E) then + List_Record_Info (Full_View (E), Bytes_Big_Endian); + else + List_Record_Info (E, Bytes_Big_Endian); + end if; -- Recurse into entities local to a record type From patchwork Tue Aug 6 09:02:37 2024 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: 95363 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F1B0385DDC0 for ; Tue, 6 Aug 2024 09:06:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 8FA8C385E44D for ; Tue, 6 Aug 2024 09:03:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FA8C385E44D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8FA8C385E44D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935011; cv=none; b=lFVtgu7ZRfJQmK40PfDezhC/xO3pV+1QaSUSz7Wv+U3d6OjNLSULcb8BcUVBZdVNn94u4oq/HaDqU15spFSZmgdT9lM5FP4baT3DqBVQxZs6+us1C+Es4uvjG+5zLADkqS5bJ42kk9pA1z0clRke5V0wKEJZJTzvXUFqxGWyJxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935011; c=relaxed/simple; bh=NeHFqN4/wxB+kRb1m3RGsjVaIPY7XQVolk5oT20+imM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EHLkjuJIo/LgQCFhVKZCIoiq1ckSRiwQSgYPSkaTmDdmDw0UojQ0Qs66Nt06YEY5JI0/jnyBaJi589bwAV1OU2omlF9QejEjtzc2dgphfTBNZDhky5O0VyimQCQi41OCF1OKksa5sB5iDlam3eQmEgAPmE2MoZuZItxzvLNAPrk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42816ca782dso3084715e9.2 for ; Tue, 06 Aug 2024 02:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722935007; x=1723539807; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2pkU0onNx3urbJSsZ4PgJiBrt37e5xxyfgyahfTU79A=; b=Z5I4RWySE1EhKb+H0HlfR4vgjh3vk1sJ5OV2ywZcA6Mpo2sDLj2lOTyS6PELJ5qsxe /N27V+Z7nYTZzf/g+xi5EkB965U0gzCU0y3eorQBT2lg03TOGgTuw2bm6Zb/XMXZgLnS ONRqQxTB/6xE4BZcn2aL/EcOqZLavQMZwZdD91fpo+mePhphHKGyJ1A8ELuetFBal+wa HfTYSW/18Gmr4Kg/YveHiZLn6atGldwzFom3D8XPJ4dDbrbzoEmOK1/SFVe3qyyr+nDH fuhtX2mxgDhaP/kQzCx8dn73BhTPgVjr1Kf/7UWL9aL4WCpj9X/hCwxYUFtX68Nzyxm1 cGCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722935007; x=1723539807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2pkU0onNx3urbJSsZ4PgJiBrt37e5xxyfgyahfTU79A=; b=qVpyd0/mI92980pQBgc0MHw6ni2D09zF/oacyOmBFCS6EyxqQ+tTE3k7uTc7FSl0IZ XLeXwXvw3bjoFYuQGIziStJtpfBPMsOxtLlkNz9oaZQx5eqWJ+zfKQCY0syty9sitUaI /6iQ5sULKVoo5/QvoApQQfy2fM15pFTV7gsvdnS7vQo4kvQ9Ca7r55YLPiZNHhMBqcD2 nGbKe9TJa+Sw7ITgBoxKbJndK0+dMhapsfaDHlp/yscLjYY6XeCXhocaVCCdWOyC6Lxx y4R4qgmoajD1zfDkE5rArLj51RB44MkzU042pfTjgaTRrzQdUw3FhRJHgc/ecNwoOpby koRQ== X-Gm-Message-State: AOJu0YwCZvZCD6L+xvYhM2yGs13vmwlc5PhgFhR/pq8CX1/aiMN55WDq 6/lQttUCgbvyt2B71x25nZN/ehIJckmNIyDJ1Xz98p5viUfRxyfs76MMb6BBQrT8qa+HYgKYX7b phg== X-Google-Smtp-Source: AGHT+IHZqkC9dm+/pcqLnZpykQHou9q/usBE4LuLuikjVCRMYk5cjB/F/n2HW4REw5ftaI+jcAzJsw== X-Received: by 2002:a05:600c:4507:b0:428:2433:1a07 with SMTP id 5b1f17b1804b1-428e6b93494mr94621115e9.34.1722934976842; Tue, 06 Aug 2024 02:02:56 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:56 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 5/9] ada: Use fully qualified in more library files Date: Tue, 6 Aug 2024 11:02:37 +0200 Message-ID: <20240806090241.576862-5-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Viljar Indus gcc/ada/ * libgnarl/s-interr__hwint.adb: Use fully qualified names to avoid ambiguity. * libgnarl/s-taprop__qnx.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnarl/s-interr__hwint.adb | 11 ++++++----- gcc/ada/libgnarl/s-taprop__qnx.adb | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnarl/s-interr__hwint.adb b/gcc/ada/libgnarl/s-interr__hwint.adb index 12dde452ff4..0cccf6fd294 100644 --- a/gcc/ada/libgnarl/s-interr__hwint.adb +++ b/gcc/ada/libgnarl/s-interr__hwint.adb @@ -482,9 +482,10 @@ package body System.Interrupts is Handler : System.OS_Interface.Interrupt_Handler) is Vec : constant Interrupt_Vector := - Interrupt_Number_To_Vector (int (Interrupt)); + Interrupt_Number_To_Vector + (Interfaces.C.int (Interrupt)); - Status : int; + Status : Interfaces.C.int; begin -- Only install umbrella handler when no Ada handler has already been @@ -613,7 +614,7 @@ package body System.Interrupts is procedure Notify_Interrupt (Param : System.Address) is Interrupt : constant Interrupt_ID := Interrupt_ID (Param); Id : constant Binary_Semaphore_Id := Semaphore_ID_Map (Interrupt); - Status : int; + Status : Interfaces.C.int; begin if Id /= 0 then Status := Binary_Semaphore_Release (Id); @@ -744,7 +745,7 @@ package body System.Interrupts is -------------------- procedure Unbind_Handler (Interrupt : Interrupt_ID) is - Status : int; + Status : Interfaces.C.int; begin -- Flush server task off semaphore, allowing it to terminate @@ -1024,7 +1025,7 @@ package body System.Interrupts is Tmp_Handler : Parameterless_Handler; Tmp_ID : Task_Id; Tmp_Entry_Index : Task_Entry_Index; - Status : int; + Status : Interfaces.C.int; begin Semaphore_ID_Map (Interrupt) := Int_Sema; diff --git a/gcc/ada/libgnarl/s-taprop__qnx.adb b/gcc/ada/libgnarl/s-taprop__qnx.adb index 39e6983f438..d6680b58dba 100644 --- a/gcc/ada/libgnarl/s-taprop__qnx.adb +++ b/gcc/ada/libgnarl/s-taprop__qnx.adb @@ -300,7 +300,7 @@ package body System.Task_Primitives.Operations is Res := mprotect (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, - size_t (Page_Size), + Interfaces.C.size_t (Page_Size), prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if; From patchwork Tue Aug 6 09:02:38 2024 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: 95360 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3684385DC1E for ; Tue, 6 Aug 2024 09:05:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id E301E385C6C6 for ; Tue, 6 Aug 2024 09:03:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E301E385C6C6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E301E385C6C6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935010; cv=none; b=noCh0sgBlNkVHgUiocvwOi8ASjL85zABy6hrq3idvSlQU5+m7VP2AtTmoUUFTaGup/EtaPgIuEbgXI4dnrNbtGpUbmWFKbccIDoyzw7T5hn7McuB+ftLNtMV+8dxH23w9otY3RD5XS6YEl1G0NqLVqxKQPARp35potzBuQxsnQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935010; c=relaxed/simple; bh=bkXD4OgGryqy58JcV1kAM6GXtNXLSHKRYIsrm1Mrfvo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=QUB/LEmcIKLMdjQ2biutRF+sGEmdS+u0sJ2qWZW2OCqbASla452tkJPILH5lr/jceDE0gG/tOLCAtoR6HLK1ZyxHuH1rVSYH62JFBNw20iJLX5i6MpZG+lBWU5B8bK+Jb1EhagQYuRDPAq+6gIZqAv+Eel7qZBTGJgm0+jW2NJo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4281faefea9so2042455e9.2 for ; Tue, 06 Aug 2024 02:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722935007; x=1723539807; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zCUlRVUyb37JjBzIrqp5J5a9VZxHGaXKw+JB8Ng6mx0=; b=VA1QyoB46aNtbixFw9YsP9NHbTTuOuMw3c1BQpvNFKoiHIHEBbg/elR9HO2EM6U78a jiNMnEmX/RUt1sFXT0I3692/aEGAtVkpNJjFqViDWrrPQLfK4RX1JCJHZSQCXGpFwWHd fH98IOX+evW5TPf0sQxm0hF4R2wIeoHfmZRWLCBQIoY4ESNSTJsnSxZkIOoXV2E9A3yT GpGYdTovtZeGu93b2wZ2jcKQBGuMN3jveJ2PJURrnNREk+j5z3/OwO0fuHgzlNWNNCXn g2boU+MIgNJxeRv4EJnhkxvDn8h2PXDvwTCNtlaNVqhh+N5Rwt4dV/YQqRPMBtF6WBT/ YDHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722935007; x=1723539807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zCUlRVUyb37JjBzIrqp5J5a9VZxHGaXKw+JB8Ng6mx0=; b=SQGazgm0QTdS95nmT3SshhEZhRhg3VTVWK9L2M2KUcJ0RdcU6D0ANtRmVthjtYe4DM X4RJuUFoO1lyQppR7DvZblxowyy2m6KG/azb9El/je2jZVGsA6RC/EKKcU6QHBe1o3jg yZFBDuoIiZhziCjYdRAqWEvIi6175TzYcdGtXK/WHS7mXyv4bBrL0so81xqh876PR/CH cyXMpo651Us0SCvLKhQay1i1evpvSoJquUejC+cJyjNVgodGztuS5RICWXP9lqmjLsTS JsC8CRiWYt+aD5vPbQD0ivx76pQg1OsaC0W+T3/0cH/DhqkxE2sZH3g8KiZs0mINs1zj UwZA== X-Gm-Message-State: AOJu0YxkMU0Z8Jv6PXVC1ZyyxOSx9gSRCi27eSfQKj7oxCGZ2Q7UftTg TeohRMvizr33afMyPNIhZgcbqpwUGyi3Vuk0VGgXv4/9bwCal216eRydZhDEh9+cdcWgvQ5SWUT 6Ww== X-Google-Smtp-Source: AGHT+IGCk0rsGqzYvuA7n3dvdZU2VNDxHp5MD0jVa28xMGXgOEmleYDo8cOdutAbQeBuQ/osFAFRLw== X-Received: by 2002:a05:600c:4f92:b0:426:6e8b:3dc5 with SMTP id 5b1f17b1804b1-428e6b92636mr114329335e9.32.1722934977720; Tue, 06 Aug 2024 02:02:57 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:57 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 6/9] ada: Spurious error on the default value of a derived scalar type Date: Tue, 6 Aug 2024 11:02:38 +0200 Message-ID: <20240806090241.576862-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Javier Miranda When the aspect Default_Value is inherited by a derived scalar type, and both the parent type T and the derived type DT are declared in the same scope, a spurious error may be reported. This occurs if a subprogram declared in the same scope has a parameter of type DT with a default value, leading the compiler to incorrectly flag the default value specified in the aspect of type T as having the wrong type. gcc/ada/ * freeze.adb (Freeze_Entity): For scalar derived types that inherit the aspect Default_Value, do not analyze and resolve the inherited aspect, as the type of the aspect remains the parent type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index a947018052c..7d5be6b6744 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7820,7 +7820,24 @@ package body Freeze is -- type itself, and we treat Default_Component_Value similarly for -- the sake of uniformity). - if Is_First_Subtype (E) and then Has_Default_Aspect (E) then + -- But for an inherited Default_Value aspect specification, the type + -- of the aspect remains the parent type. RM 3.3.1(11.1), a dynamic + -- semantics rule, says "The implicit initial value for a scalar + -- subtype that has the Default_Value aspect specified is the value + -- of that aspect converted to the nominal subtype". For an inherited + -- Default_Value aspect specification, no conversion is evaluated at + -- the point of the derived type declaration. + + if Is_First_Subtype (E) + and then Has_Default_Aspect (E) + and then + (not Is_Scalar_Type (E) + or else + not Is_Derived_Type (E) + or else + Default_Aspect_Value (E) + /= Default_Aspect_Value (Etype (Base_Type (E)))) + then declare Nam : Name_Id; Exp : Node_Id; From patchwork Tue Aug 6 09:02:39 2024 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: 95359 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0544F385C6D1 for ; Tue, 6 Aug 2024 09:04:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 13990385841D for ; Tue, 6 Aug 2024 09:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13990385841D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 13990385841D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934984; cv=none; b=QNjhQbMfayZMsxhrvwLJIsXAuEBidfEBmoXaN65LCBMnyyjQFFp/KcjDM3InH9Hz5BYah84lGVOKZxlUbIO12uCHAoqLgM1LebXP0ge9rGF6ByyG1DcHVx08BA/eE/BXoURl7MsfXKzAE+hqOJAju4+EkLAJQRSzh7hQWy8tmaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934984; c=relaxed/simple; bh=NZeJOh4XYgY7z7/phQqVwzxRE05E5GkHRV0bW+HCEWg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uAQH+vhoSR/ZfuhyJUPg2Glt7rOW4EJB0WldHjCOmp95GwQxdjXZbDZWlQ1gvJVbae+79mgJAa9MudpwiF5Hgc1HURdzH1HbYp7+VwG2HFM+f+W4e587Rgi8kcpBdFH/VZqvHSGXi14tcOkvuooNIC2bvLS7D5IvbWdb4eyIYsQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4280ee5f1e3so2191905e9.0 for ; Tue, 06 Aug 2024 02:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934979; x=1723539779; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BW8WMO2a1XbJaElGXVLMvRAkNjHuwTSFsqsbgR+cmR0=; b=OrIVn29YhHaAwjA15gccBJplBqs+uAtUKTQ91EZ1FIGUd6mROGZgQA5rAKQ4zrvX1R Vy9zftjHDK1WpvWnhVmoCxd5yux8EeHCuQEMLxzIUcFFhD8UZDW6+zDQaJCU5jfPql4a C3eGgNDWbKaOt5Cu2KBlzj/Mp8dhseJE1qNRNlEf5GqCaJDzoe2kdX7b6F1QtH2fLXfj TrcgFY7SYuZ5LH3yaY2ZmA4dM/uCPUS/2iO4rN39EQfiksU4R7DvXAY0nlVS7zo9wvZq 23OhsZmnU8JyUMgGjI5rSok0Y885D6ZZguNkBmwZP3+EI4HH+7AJ76xRkUvrVQFYeSx1 HNnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934979; x=1723539779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BW8WMO2a1XbJaElGXVLMvRAkNjHuwTSFsqsbgR+cmR0=; b=kBqUsj35pPD9/roUsJUT7KtdKTBAsKSWOLtnxMjVIEztrxxpsd55xgGQPWtRBhMIsQ WvpMuRthUTAcc9552pHwUqU7YcdGTFb4hMqPwtmsDxEYKKda99xQnd8LZxpl0FxDn3z8 CcmIinn0FkdYjc0sy9CJNFHhw0n1ej13VMZG/c3w9Z7shA9BFPxP5/pzie/db38ButxG t2pPuaY/0SAYYowwBU3n/nsleFtyEo8FuZt++DD5g/TYP95bfSI42WY0ee/e14lTr5Ld wgn7U4XxNg4gIKkLhm8jaG+AjC+5sOY+cA5aPCA5UCcBgz2pIwO/0y1ldXOi52mYM49Q HUwA== X-Gm-Message-State: AOJu0Yy9JKnjI+yWrMb/pqb75DGfTtXnsasI6Vm/e2mAceZRM744Pn5v w0EiZ8vES+i5DnTfqy7DH/mfL2HmRok7CptvwUKSE6pTtZE8nRzH4JUxwaS/lvain7FyvMwnhGF i1w== X-Google-Smtp-Source: AGHT+IGxgJ2TGJj+CLfk9s9UScroAzeurTr1Td98oqJEUifmhf14QckryikOQKO2/3yJcj4V9HG86Q== X-Received: by 2002:a05:600c:4f4b:b0:426:614b:1a72 with SMTP id 5b1f17b1804b1-428e6b07ea1mr104196315e9.17.1722934978537; Tue, 06 Aug 2024 02:02:58 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:58 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 7/9] ada: GNAT-LLVM compiler crash on container aggregates with iterators Date: Tue, 6 Aug 2024 11:02:39 +0200 Message-ID: <20240806090241.576862-7-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Gary Dismukes Recent fixes for container aggregates with iterated element associations exposed a latent bug with loops that are wrapped in blocks, where the loop entity's scope was not adjusted to reflect the new enclosing block scope. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Statement.Wrap_Loop_Statement): Remove the loop Entity_Id from its old scope and insert it in the new block scope that wraps it. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index d44a12d1dd1..30fee6e6500 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3800,8 +3800,9 @@ package body Sem_Ch5 is procedure Wrap_Loop_Statement (Manage_Sec_Stack : Boolean) is Loc : constant Source_Ptr := Sloc (N); - Blk : Node_Id; - Blk_Id : Entity_Id; + Blk : Node_Id; + Blk_Id : Entity_Id; + Loop_Id : constant Entity_Id := Entity (Identifier (N)); begin Blk := @@ -3816,6 +3817,12 @@ package body Sem_Ch5 is Rewrite (N, Blk); Analyze (N); + + -- Transfer the loop entity from its old scope to the new block + -- scope. + + Remove_Entity (Loop_Id); + Append_Entity (Loop_Id, Blk_Id); end Wrap_Loop_Statement; -- Local variables From patchwork Tue Aug 6 09:02:40 2024 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: 95364 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C933E385E459 for ; Tue, 6 Aug 2024 09:06:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 24D91385E45C for ; Tue, 6 Aug 2024 09:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24D91385E45C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 24D91385E45C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935018; cv=none; b=bD5Xu9iv1ZJhO5ImeovbWQk+0DY7mpR8YNDeZiApJil7HGVhgRBufxfkRSDlEnJZ9+jo1QkRaf9TzllfoLMmy3pZswjyNmZYflOG9x7Rhe60laIjj30NcpVMaJ9wZGf8E51BugNzrDzyeB90+Tiwe3IZa2QEi17kWenin4jQOkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722935018; c=relaxed/simple; bh=OF/WQfuDEtgH0s4tJz/U3XVxltdtuXn/hm7kwz7XldQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aCq8nhgeiPzJd/+0Fe72xR6SnUBU6F9wBSSyeNesPKMkBwzxuq09imL57jjkr7dckMbea/SD8AoSLMaOuqOFuhfUni8VyVf+rO+uV8wz9PbLiJZyvUteQrbGOHdu5+OtQD1JOqVmpxL5Y/bH40JxMsa22DQn0REjwGJdkTa+A0M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428243f928cso2703075e9.3 for ; Tue, 06 Aug 2024 02:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722935009; x=1723539809; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LQmB+iNWHrX//zBkdaa6MbffxNHRh4IwqXv6V6yjbGg=; b=fRvpwig1/wyoeYGSnWFFAJkr1LF3N+8MB96NDWAYwOvuUEBGwAEUaSsLr9WHg6MZpL E7aTpeiwY/2uLdYrt0SA68V7ALQkSMWoXCcMZzkBrUNcpDb9X9P87WKIebGVlAoB245q AFZ20wupYh+E+bpCyvuZBNAQoewA54aeGsMuLBdVQOPLQzkjamdBKrmkb/vbfoOh5h6Q lefwU22Kg8YNzceJt98OwHhexOU2YRiyKKrJAM/O1lDX5Zg3Hs4VkoY1bTOoQ29lhBh2 SLggHd8KBBYu+b8jBa31allI7xN8sWQ1rHFkRES9X7tYWPKwUMgEDG0/vGJ2OxG11fW9 UgrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722935009; x=1723539809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LQmB+iNWHrX//zBkdaa6MbffxNHRh4IwqXv6V6yjbGg=; b=aJqNRJUhwwepzwT/bP/lQTJWv546swO5C0/HexPNFFt3bQSxUqbdAFYfso0PXQuJ/F sDzzSETBHYuKrzWpeCC+BDKkc4mT5xhS1e2nNLnfhenGNUwC3oZexavEefdwxSgRlgvK sVrk6c7ZaVLUfPbax6STUcVii3dhsdf+goWrU53L9erxlk9mCDv729CxMjuOMfnB+piC jiFGF486/V6R7CPMrmcKUMsHF2jJAG9GMzWONO0JC5aDQANQ+7uWTg0GXmmeZulpGu30 8MRDzsNyinWmRCWi2F2Z7kIFyZ9D1s5+xAe+OLpaL3r2VpSRh79vwDEvMSkDMTZTZpZA nrXw== X-Gm-Message-State: AOJu0Yx5t+mXGsn0D2FKqi3jcEK9hyrPBRfpnFkYk16ZMoaRKczT18tw 2+1uMjXzgI60h5nzfePufE/vFFE70Bd2O3jYXK4ATlmjBwgWUoPzT7iMM8kxGZ2dzbHoImtY5/j O5Q== X-Google-Smtp-Source: AGHT+IGnxv2dFSc8L4SWWUOMqFkSKsTgsBiT4V60GnBanhg1VMmW4s32jvKlK78Ogt6jfDajsEaEjA== X-Received: by 2002:a05:600c:3112:b0:426:59fc:cdec with SMTP id 5b1f17b1804b1-428e6b30300mr95491135e9.21.1722934979412; Tue, 06 Aug 2024 02:02:59 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:58 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 8/9] ada: Implement type inference for generic parameters Date: Tue, 6 Aug 2024 11:02:40 +0200 Message-ID: <20240806090241.576862-8-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 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, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Bob Duff ...based on previous work that added Gen_Assocs_Rec. Minor cleanup of that previous work. gcc/ada/ * sem_ch12.adb: Implement type inference for generic parameters. (Maybe_Infer_One): Forbid inference of anonymous subtypes and types. (Inference_Reason): Fix comment. * debug.adb: Document -gnatd_I switch. * errout.ads: Document that Empty is not allowed for "&". * errout.adb (Set_Msg_Insertion_Node): Minor: Do not allow Error_Msg_Node_1 = Empty for "&". Use "in" instead of multiple "=". Improve comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/debug.adb | 5 +- gcc/ada/errout.adb | 23 +-- gcc/ada/errout.ads | 11 +- gcc/ada/sem_ch12.adb | 482 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 485 insertions(+), 36 deletions(-) diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index d2546bec1b5..fcd04dfb93b 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -173,7 +173,7 @@ package body Debug is -- d_F Encode full invocation paths in ALI files -- d_G -- d_H - -- d_I + -- d_I Note generic formal type inference -- d_J -- d_K (Reserved) Enable reporting a warning on known-problem issues -- d_L Output trace information on elaboration checking @@ -1029,6 +1029,9 @@ package body Debug is -- an external target, offering additional information to GNATBIND for -- purposes of error diagnostics. + -- d_I Generic formal type inference: print a "note:" message for each + -- actual type that is inferred, or could be inferred. + -- d_K (Reserved) Enable reporting a warning on known-problem issues of -- previous releases. No action performed in the wavefront. diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index c6534fe2a76..c8d87f0f9bb 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -3866,18 +3866,13 @@ package body Errout is ---------------------------- procedure Set_Msg_Insertion_Node is + pragma Assert (Present (Error_Msg_Node_1)); K : Node_Kind; begin - Suppress_Message := - Error_Msg_Node_1 = Error - or else Error_Msg_Node_1 = Any_Type; + Suppress_Message := Error_Msg_Node_1 in Error | Any_Type; - if Error_Msg_Node_1 = Empty then - Set_Msg_Blank_Conditional; - Set_Msg_Str (""); - - elsif Error_Msg_Node_1 = Error then + if Error_Msg_Node_1 = Error then Set_Msg_Blank; Set_Msg_Str (""); @@ -3898,15 +3893,11 @@ package body Errout is K := Nkind (Error_Msg_Node_1); - -- If we have operator case, skip quotes since name of operator - -- itself will supply the required quotations. An operator can be an - -- applied use in an expression or an explicit operator symbol, or an - -- identifier whose name indicates it is an operator. + -- Skip quotes in the operator case, because the operator will supply + -- the required quotes. - if K in N_Op - or else K = N_Operator_Symbol - or else K = N_Defining_Operator_Symbol - or else ((K = N_Identifier or else K = N_Defining_Identifier) + if K in N_Op | N_Operator_Symbol | N_Defining_Operator_Symbol + or else (K in N_Identifier | N_Defining_Identifier and then Is_Operator_Name (Chars (Error_Msg_Node_1))) then Set_Msg_Node (Error_Msg_Node_1); diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index f0e3f5d0b7c..2b0410ae690 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -173,12 +173,11 @@ package Errout is -- obtained from the Sloc field of the given node or nodes. If no Sloc -- is available (happens e.g. for nodes in package Standard), then the -- default case (see Scans spec) is used. The nodes to be used are - -- stored in Error_Msg_Node_1, Error_Msg_Node_2. No insertion occurs - -- for the Empty node, and the Error node results in the insertion of - -- the characters . In addition, if the special global variable - -- Error_Msg_Qual_Level is non-zero, then the reference will include - -- up to the given number of levels of qualification, using the scope - -- chain. + -- stored in Error_Msg_Node_1, Error_Msg_Node_2, which must not be + -- Empty. The Error node results in the insertion of "". In + -- addition, if the special global variable Error_Msg_Qual_Level is + -- non-zero, then the reference will include up to the given number of + -- levels of qualification, using the scope chain. -- -- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed -- to insert the string xxx'Class into the message. diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 25821cb7695..0f8792c3a82 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -26,6 +26,7 @@ with Aspects; use Aspects; with Atree; use Atree; with Contracts; use Contracts; +with Debug; use Debug; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; @@ -830,7 +831,7 @@ package body Sem_Ch12 is -- formal derived types, to determine whether the parent type is another -- formal derived type in the same generic unit. -- Note that the call site appends the result of this function onto - -- the same list. + -- the same list it is passing to Actual_Decls. function Instantiate_Formal_Subprogram (Formal : Node_Id; @@ -1167,9 +1168,26 @@ package body Sem_Ch12 is end record; type Actual_Origin_Enum is - (None, From_Explicit_Actual, From_Default, From_Others_Box); + (None, From_Explicit_Actual, From_Default, From_Inference, + From_Others_Box); -- Indication of where the Actual came from -- explicitly in the - -- instantiation, or defaulted. + -- instantiation, inferred from some other type, or defaulted. + + type Inference_Reason is + -- Reason an actual type corresponding to a formal type was (or could + -- be) inferred from the actual type corresponding to another formal + -- type. + (Designated_Type, -- designated type from formal access + Index_Type, -- index type from formal array + Component_Type, -- component type from formal array + Discriminant_Type); -- discriminant type from formal discriminated + + function Image (Reason : Inference_Reason) return String is + (case Reason is + when Designated_Type => "designated type", + when Index_Type => "index type", + when Component_Type => "component type", + when Discriminant_Type => "discriminant type"); type Assoc_Index is new Pos; subtype Assoc_Count is Assoc_Index'Base range 0 .. Assoc_Index'Last; @@ -1196,7 +1214,22 @@ package body Sem_Ch12 is Actual_Origin : Actual_Origin_Enum; -- Reason why Actual was set; where it came from - end record; + + Info_Inferred_Actual : Opt_Type_Kind_Id; + -- An inferred actual is always a type entity, not a box, and not + -- something like T'Base. This is used only for messages and + -- assertions. It contains the type that was, or could have been, + -- inferred. + + Inferred_From : Assoc_Index; + -- Index of a later Assoc_Rec in the same Gen_Assocs_Rec from which + -- this one was inferred, or could be inferred. + -- Valid only if Info_Inferred_Actual is present. + + Reason : Inference_Reason; + -- Reason the type was inferred, or could have been inferred. + -- Valid only if Info_Inferred_Actual is present. + end record; -- Assoc_Rec type Assoc_Array is array (Assoc_Index range <>) of Assoc_Rec; -- One element for each formal and (if legal) for each corresponding @@ -1206,9 +1239,13 @@ package body Sem_Ch12 is -- Representation of formal/actual matching. Num_Assocs -- is the number of formals and (if legal) the number -- of actuals. + Gen_Unit : Entity_Id; + -- the generic unit being instantiated Others_Present : Boolean; -- True if "others => <>" (only for formal packages) Assocs : Assoc_Array (1 .. Num_Assocs); + -- One for each formal/actual pair; defaulted and inferred actuals + -- are included. end record; function Match_Assocs @@ -1220,6 +1257,11 @@ package body Sem_Ch12 is -- actuals filled in. Check legality rules related to formal/actual -- matching. + procedure Note_Potential_Inference + (I_Node : Node_Id; Gen_Assocs : Gen_Assocs_Rec); + -- If -gnatd_I, print "info:" messages about type inference that could + -- have been done. + end Associations; procedure Analyze_One_Association @@ -1298,6 +1340,52 @@ package body Sem_Ch12 is -- and we set Assoc.Actual. We also set the Selector_Name to denote -- the matched formal, and set Found to True. + procedure Inference_Msg + (Gen_Unit : Entity_Id; + Inferred_To, Inferred_From : Assoc_Rec; + Was_Inferred : Boolean); + -- If Was_Inferred is True, this prints out an "info:" message + -- showing the inference. + -- If Was_Inferred is False, the message says that it could have + -- been inferred. + + function Find_Assoc + (Gen_Assocs : Gen_Assocs_Rec; F : Entity_Id) return Assoc_Index; + -- Return the index of F in Gen_Assocs.Assocs, which must be + -- present. + + procedure Maybe_Infer_One + (Gen_Assocs : in out Gen_Assocs_Rec; + FF, AA : N_Entity_Id; Inferred_From : Assoc_Index; + Reason : Inference_Reason); + -- If it makes sense to infer that formal FF is associated with + -- actual AA, then do so. + + procedure Infer_From_Access + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id); + -- Try to infer the designated type + + procedure Infer_From_Array + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id); + -- Try to infer the index and component types + + procedure Infer_From_Discriminated + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id); + -- Try to infer the types of discriminants + + procedure Infer_Actuals (Gen_Assocs : in out Gen_Assocs_Rec); + -- Called by Match_Assocs after processing explicit and defaulted + -- parameters to infer any that are still missing. + ----------------- -- Formal_Iter -- ----------------- @@ -1380,6 +1468,8 @@ package body Sem_Ch12 is Action (F, Index); Index := Index + 1; + -- Skip full type of derived type + if Nkind (F) = N_Full_Type_Declaration and then Nkind (Type_Definition (F)) = N_Derived_Type_Definition @@ -1388,7 +1478,7 @@ package body Sem_Ch12 is and then Chars (Defining_Identifier (F)) = Chars (Defining_Identifier (Next (F))) then - Next (F); -- Skip full type of derived type + Next (F); end if; end if; @@ -1399,22 +1489,28 @@ package body Sem_Ch12 is (not Is_Internal_Name (Chars (Defining_Entity (F)))); Action (F, Index); Index := Index + 1; + elsif Nkind (Original_Node (F)) in N_Full_Type_Declaration then null; else -- subtype of a formal object + pragma Assert (Nkind (Next (F)) = N_Formal_Object_Declaration); end if; + when N_Pragma => null; + when N_Formal_Package_Declaration => -- If there were no errors, this would have been transformed - -- into N_Package_Declaration. + -- into an N_Package_Declaration. + Check_Error_Detected; pragma Assert (Error_Posted (F)); Abandon_Instantiation (Instantiation_Node); + when others => raise Program_Error; end case; @@ -1509,6 +1605,7 @@ package body Sem_Ch12 is end if; when N_Formal_Package_Declaration => null; + when others => raise Program_Error; end case; pragma Assert @@ -1640,12 +1737,16 @@ package body Sem_Ch12 is return Result : Gen_Assocs_Rec (Num_Assocs => Num_Formals (Formals)) do + Result.Gen_Unit := Gen_Unit; Result.Others_Present := False; -- Loop through the unanalyzed formals: declare procedure Set_Formal (F : Node_Id; Index : Assoc_Index); + -- Initialize one Assoc_Rec so the formal is set. + -- Use a dummy assoc for use clauses. + procedure Set_Formal (F : Node_Id; Index : Assoc_Index) is Assoc : Assoc_Rec renames Result.Assocs (Index); begin @@ -1655,14 +1756,20 @@ package body Sem_Ch12 is An_Formal => Empty, Explicit_Assoc => Empty, Actual => (Kind => None_Use_Clause), - Actual_Origin => None); + Actual_Origin => None, + Info_Inferred_Actual => Empty, + Inferred_From => <>, + Reason => <>); else Assoc := (Un_Formal => F, An_Formal => Empty, Explicit_Assoc => Empty, Actual => <>, - Actual_Origin => None); + Actual_Origin => None, + Info_Inferred_Actual => Empty, + Inferred_From => <>, + Reason => <>); end if; end Set_Formal; procedure Iter is new Formal_Iter (Set_Formal); @@ -1812,6 +1919,7 @@ package body Sem_Ch12 is -- if there is "others => <>", set the actual to "F => <>". -- Otherwise, if the formal has a default, set the actual to -- "F => default". Otherwise leave it Empty. + -- (If Empty, it could be inferred, or it could be an error). for Index in Result.Assocs'Range loop declare @@ -1832,6 +1940,10 @@ package body Sem_Ch12 is end; end loop; + if Nkind (I_Node) /= N_Formal_Package_Declaration then + Infer_Actuals (Gen_Assocs => Result); + end if; + -- Check for missing actuals for Index in Result.Assocs'Range loop @@ -1850,6 +1962,331 @@ package body Sem_Ch12 is end return; end Match_Assocs; + ------------------- + -- Inference_Msg -- + ------------------- + + procedure Inference_Msg + (Gen_Unit : Entity_Id; + Inferred_To, Inferred_From : Assoc_Rec; + Was_Inferred : Boolean) + is + pragma Assert (Debug_Flag_Underscore_II); -- This is only for -gnatd_I + + Was : constant String := (if Was_Inferred then "" else "could have "); + + -- "if True" below to leave out some verbosity for now: + Inst : constant String := + (if True then "" + else " gen: " & Get_Name_String (Chars (Gen_Unit))); + Decl : constant String := (if True then "" else " declared # "); + + R : constant String := " (" & Image (Inferred_To.Reason) & ")"; + + Mess : constant String := + "info: " & Was & "inferred `% ='> &`" & Decl & Inst & R; + Mess_2 : constant String := + "info: `% ='> ...`"; + begin + Error_Msg_Name_1 := Chars (Defining_Entity (Inferred_To.An_Formal)); + Error_Msg_Sloc := Sloc (Inferred_To.Info_Inferred_Actual); + if not In_Instance then + if Debug_Flag_Underscore_II then + Error_Msg_NE + (Mess, Inferred_From.Actual.Name_Exp, + Inferred_To.Info_Inferred_Actual); + Error_Msg_Name_1 := + Chars (Defining_Identifier (Inferred_From.An_Formal)); + Error_Msg_N (Mess_2, Inferred_From.Actual.Name_Exp); + end if; + end if; + end Inference_Msg; + + ------------------------------ + -- Note_Potential_Inference -- + ------------------------------ + + procedure Note_Potential_Inference + (I_Node : Node_Id; Gen_Assocs : Gen_Assocs_Rec) + is + begin + if not Debug_Flag_Underscore_II or else Serious_Errors_Detected > 0 + then + return; + end if; + + for Index in Gen_Assocs.Assocs'Range loop + declare + Assoc : Assoc_Rec renames Gen_Assocs.Assocs (Index); + begin + if Assoc.Actual_Origin = From_Explicit_Actual + and then Present (Assoc.Info_Inferred_Actual) + and then In_Extended_Main_Source_Unit (I_Node) + and then not In_Internal_Unit (I_Node) + then + Inference_Msg + (Gen_Assocs.Gen_Unit, + Inferred_To => Assoc, + Inferred_From => Gen_Assocs.Assocs (Assoc.Inferred_From), + Was_Inferred => False); + end if; + end; + end loop; + end Note_Potential_Inference; + + -------------- + -- Find_Assoc -- + -------------- + + function Find_Assoc + (Gen_Assocs : Gen_Assocs_Rec; F : Entity_Id) return Assoc_Index + is + begin + for Index in Gen_Assocs.Assocs'Range loop + if Defining_Entity (Gen_Assocs.Assocs (Index).An_Formal) = F then + return Index; + end if; + end loop; + + raise Program_Error; -- it must be present + end Find_Assoc; + + --------------------- + -- Maybe_Infer_One -- + --------------------- + + procedure Maybe_Infer_One + (Gen_Assocs : in out Gen_Assocs_Rec; + FF, AA : N_Entity_Id; Inferred_From : Assoc_Index; + Reason : Inference_Reason) + is + begin + if not (Is_Generic_Type (FF) + and then Scope (FF) = Gen_Assocs.Gen_Unit) + then + return; -- no inference if not a formal type of this generic + end if; + + if Is_Internal_Name (Chars (FF)) or else Is_Itype (AA) then + return; -- no inference if internally generated + end if; + + declare + Index : constant Assoc_Index := Find_Assoc (Gen_Assocs, FF); + Assoc : Assoc_Rec renames Gen_Assocs.Assocs (Index); + pragma Assert (Defining_Entity (Assoc.An_Formal) = FF); + + From_Actual : constant Node_Id := + Gen_Assocs.Assocs (Inferred_From).Actual.Name_Exp; + + begin + Assoc.Info_Inferred_Actual := AA; + Assoc.Inferred_From := Inferred_From; + Assoc.Reason := Reason; + + if Assoc.Actual.Kind = None then + Assoc.Actual := + (Name_Exp, New_Occurrence_Of (AA, Sloc (From_Actual))); + Assoc.Actual_Origin := From_Inference; + + Error_Msg_GNAT_Extension + ("type inference of generic parameters", + Sloc (From_Actual)); + + if Debug_Flag_Underscore_II then + Inference_Msg + (Gen_Assocs.Gen_Unit, + Inferred_To => Assoc, + Inferred_From => Gen_Assocs.Assocs (Assoc.Inferred_From), + Was_Inferred => True); + end if; + end if; + end; + end Maybe_Infer_One; + + ------------------- + -- Infer_Actuals -- + ------------------- + + procedure Infer_From_Access + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id) + is + begin + if Ekind (A_Full) in Access_Kind then + declare + FF : constant Entity_Id := + Designated_Type (Defining_Entity (F)); + AA : constant Entity_Id := Designated_Type (A_Full); + begin + Maybe_Infer_One + (Gen_Assocs, + FF, + AA, + Inferred_From => Index, + Reason => Designated_Type); + end; + end if; + end Infer_From_Access; + + procedure Infer_From_Array + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id) + is + begin + if Ekind (A_Full) in Array_Kind then + declare + F_Index_Type : Opt_N_Is_Index_Id := + First_Index (Defining_Entity (F)); + A_Index_Type : Opt_N_Is_Index_Id := + First_Index (A_Full); + begin + while Present (F_Index_Type) and then Present (A_Index_Type) + loop + Maybe_Infer_One + (Gen_Assocs, + Etype (F_Index_Type), + Etype (A_Index_Type), + Inferred_From => Index, + Reason => Index_Type); + + Next_Index (F_Index_Type); + Next_Index (A_Index_Type); + end loop; + end; + + declare + F_Comp_Type : constant Type_Kind_Id := + Component_Type (Defining_Entity (F)); + A_Comp_Type : constant Type_Kind_Id := + Component_Type (A_Full); + begin + Maybe_Infer_One + (Gen_Assocs, + F_Comp_Type, + A_Comp_Type, + Inferred_From => Index, + Reason => Component_Type); + end; + end if; + end Infer_From_Array; + + procedure Infer_From_Discriminated + (Gen_Assocs : in out Gen_Assocs_Rec; + Index : Assoc_Index; + F : Node_Id; + A_Full : Entity_Id) + is + begin + if Has_Discriminants (Defining_Entity (F)) + and then Present (A_Full) + and then Has_Discriminants (A_Full) + and then Number_Discriminants (A_Full) = + Number_Discriminants (Defining_Entity (F)) + then + declare + F_Discrim : Node_Id := First_Discriminant (Defining_Entity (F)); + A_Discrim : Node_Id := First_Discriminant (A_Full); + begin + while Present (F_Discrim) loop + Maybe_Infer_One + (Gen_Assocs, + Etype (F_Discrim), + Etype (A_Discrim), + Inferred_From => Index, + Reason => Discriminant_Type); + + Next_Discriminant (F_Discrim); + Next_Discriminant (A_Discrim); + end loop; + pragma Assert (No (A_Discrim)); -- same number as F_Discrim + end; + end if; + end Infer_From_Discriminated; + + procedure Infer_Actuals (Gen_Assocs : in out Gen_Assocs_Rec) is + -- Note that we can infer FROM defaults, but we cannot infer TO a + -- parameter that has a default. We can also infer from inferred + -- types. + + -- We don't need to check that multiple inferences get the same + -- answer; the second one will get a type mismatch or nonstatically + -- matching error. + + -- This code needs to be robust, in the sense of tolerating illegal + -- code, because we have not yet checked all legality rules. For + -- example, if a formal type F has a discriminant whose type is + -- another formal type, then we want to infer the type of the + -- discriminant from the actual for F. That actual must have + -- discriminants, but we have not checked that rule yet, so we + -- need to tolerate an actual for F that has no discriminants. + + begin + -- For each parameter, check whether we can infer FROM that one TO + -- other ones. + + -- Process the parameters in reverse order, because the inferred type + -- always comes before the parameter it is inferred from. This + -- ensures that we can do the inference in one pass, including in + -- cases where an inferred type leads to another inferred type. + -- For example, an array type that allows us to infer the component + -- type, which is an access type that allows us to infer the + -- designated type. The reverse loop implies that we will see the + -- array type, then the access type, then the designated type. + + for Index in reverse Gen_Assocs.Assocs'Range loop -- NB: "reverse" + if Gen_Assocs.Assocs (Index).Actual.Kind = Name_Exp then + declare + F : constant Node_Id := Gen_Assocs.Assocs (Index).An_Formal; + A_E : constant Node_Id := + Gen_Assocs.Assocs (Index).Actual.Name_Exp; + A_Full : Entity_Id := Empty; + begin + if Nkind (A_E) in N_Has_Entity then + A_Full := Entity (A_E); + + if Present (A_Full) + and then Ekind (A_Full) in Incomplete_Kind + and then Present (Full_View (A_Full)) + then + A_Full := Full_View (A_Full); + end if; + end if; + + if Nkind (F) = N_Formal_Type_Declaration + and then Present (A_Full) + then + case Ekind (Defining_Entity (F)) is + when E_Access_Type | E_General_Access_Type => + Infer_From_Access (Gen_Assocs, Index, F, A_Full); + + when E_Access_Subtype + | E_Access_Attribute_Type + | E_Allocator_Type + | E_Anonymous_Access_Type => + raise Program_Error; + + when E_Array_Type | E_Array_Subtype => + Infer_From_Array (Gen_Assocs, Index, F, A_Full); + + when E_String_Literal_Subtype => + raise Program_Error; + + when others => + null; + end case; + + Infer_From_Discriminated (Gen_Assocs, Index, F, A_Full); + end if; + end; + end if; + end loop; + end Infer_Actuals; + end Associations; --------------------------- @@ -1902,8 +2339,7 @@ package body Sem_Ch12 is and then Error_Posted (Assoc.An_Formal) then -- Restrict this to N_Formal_Package_Declaration, - -- because otherwise many test diffs (and maybe - -- many missing errors). + -- because otherwise we miss errors. Abandon_Instantiation (Instantiation_Node); end if; @@ -1957,6 +2393,8 @@ package body Sem_Ch12 is end; end if; + Note_Potential_Inference (I_Node, Gen_Assocs); + Check_Fixed_Point_Warning (Gen_Assocs, Result_Renamings); return Result_Renamings; @@ -2007,6 +2445,8 @@ package body Sem_Ch12 is -- Start of processing for Analyze_One_Association begin + pragma Assert (Assoc.Actual_Origin /= None); + if Assoc.Actual_Origin = From_Explicit_Actual and then Assoc.Actual.Kind = Name_Exp then @@ -2066,6 +2506,8 @@ package body Sem_Ch12 is Process_Box_Actual (Assoc.Un_Formal); elsif No (Match) then + -- No explicit actual; try default + if Present (Default_Subtype_Mark (Assoc.Un_Formal)) then Match := New_Copy (Default_Subtype_Mark (Assoc.Un_Formal)); Append_List @@ -2074,6 +2516,21 @@ package body Sem_Ch12 is Result_Renamings), Result_Renamings); Append_Elmt (Entity (Match), Actuals_To_Freeze); + + -- No explicit actual and no default; must be inference + + else + pragma Assert (Assoc.Actual_Origin = From_Inference); + + Match := Assoc.Actual.Name_Exp; + Append_List + (Instantiate_Type + (Assoc.Un_Formal, + Match, + Assoc.An_Formal, + Result_Renamings), + Result_Renamings); + Append_Elmt (Entity (Match), Actuals_To_Freeze); end if; else @@ -16627,11 +17084,10 @@ package body Sem_Ch12 is -- Note that we are creating an N_Generic_Association with -- neither Explicit_Generic_Actual_Parameter nor Box_Present. - elsif Present (Next (Act2)) and True then + elsif Present (Next (Act2)) then Ndec := Make_Generic_Association (Loc, - Selector_Name => - New_Occurrence_Of (Subp, Loc), + Selector_Name => New_Occurrence_Of (Subp, Loc), Explicit_Generic_Actual_Parameter => Empty); Append (Ndec, Assoc1); From patchwork Tue Aug 6 09:02:41 2024 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: 95361 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63616385DDDC for ; Tue, 6 Aug 2024 09:05:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id 244C43858435 for ; Tue, 6 Aug 2024 09:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 244C43858435 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 244C43858435 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934984; cv=none; b=goSHNu745IFk7Bx6WlAVlXIjwleOnk9nsh11CNycZmBt8kieQ9FB2JPIniYHqnuQkDEE9rFUGsJWXq2jjWPkMm5vLuFHET09/Vw2uyvnl980C/yB1jPoIbyjgZfe2AJDJtxyN7WEqvolFY2qZKZCrA+gbHKFmkiRWwnsn+9lqc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722934984; c=relaxed/simple; bh=NRpthLQjtmUdFGqXkgH9SCQk2oWsev09rQKuM2QbSTs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WiZTOs2Cqdv2m/xzNLouapW1MLwXdnosuKnOybtitkFmye7UAAMCPHbFtwpHli/+0gl7Mp/mUfzI7+KDOliIylfsZ4OMi6m/0fzZu8SOnSKIKNobFSAvViWH4KwRFYsAZw0KXxeOuPF2ZzWHu/PcOCTpshNT30gEB+T6U5IvoCE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ef27bfd15bso3342901fa.2 for ; Tue, 06 Aug 2024 02:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722934980; x=1723539780; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4y7qTLj+ymSIQAGLGH+2E93mN/sUexZ3/V0XOyr8dt0=; b=jPU806eFCulRjyyUDts7CQYQlQ5IOYGay/fdnoVsB+/vs8S7BPFBEbiTfH7eOFUxnU mpjyR3Q8ElkWtWnEl8Pi+4bhipxAwg1rGm/cUpZtz7hCOArpGCeP3oP4vgpeQ4cp2b++ xgIu3Bm2YxoYv2WfKIzHe4q6cLfiShcSIg76K+RJs27g3Rzg4ZHFFrNa9DGDH/U3CsbD 9LynKAuVunf7V+Dbaw+q+23Bh6f4L260oyfxo7TpFtBwtglk3jtIkIYZki49M7mQRkeH zXPNLIUp12WH3wbz/Ww7sYLkvOjE/XL0cxqcDSzxLrpYnUiFEGD1TZ+aZ52w91HNF5n6 pMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722934980; x=1723539780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4y7qTLj+ymSIQAGLGH+2E93mN/sUexZ3/V0XOyr8dt0=; b=qh/rQJxGF1twXusBzzTwOTqay1yWXzrBTW92LqCu1bFguFjq5mvCrlIzstkIP0GMaj bCe5DoK9cWCwQ/I4Kxym4sYnussijFo0eBdFiTyRbcxy1U1AloevPXfl3yWRtANskuE3 /cbep0SPbv3KvVzFEEFwXyr5DSwrnRbZxWUkd0GGsP8WMOSZSLSibz59w9wTsYY4eeON oFg05CW8tVnUR1Nf28HZT+rkUzBywg7eNUNxOdvpm/HN+HDEyTaO5bOjT78MEit1Lybn nzGzjHo9eTQK87N/+3rA2Xc9DXmTS8I7SRj2FhstVjEWNcJ7Q2+txCuKKHMa9InndpQe YfZA== X-Gm-Message-State: AOJu0Yy32prGt+WdgiBn71/zlV+iYxibvOMZPdboXoPJFQmg7jMFqDoi iIY+9X7XGGEs/HkoKpFuEAWZyGQMK8DVjksqFw3Z6B15hGtTMMv9Q+Uch8JQkFvDv0n4pKL9vkN AmQ== X-Google-Smtp-Source: AGHT+IF+iMC2cuX9B6Ir9JPH8FpQuk3ovFBu364nli+XjTOP8AECdmQ15MftiqFgJLteV+xlezG/Ig== X-Received: by 2002:a2e:9956:0:b0:2ef:23a2:7efa with SMTP id 38308e7fff4ca-2f15aab2849mr92140771fa.27.1722934980299; Tue, 06 Aug 2024 02:03:00 -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 5b1f17b1804b1-428e6e03c4csm173461085e9.13.2024.08.06.02.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 02:02:59 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED 9/9] ada: Fix error in GNATprove inlining with array concatenation Date: Tue, 6 Aug 2024 11:02:41 +0200 Message-ID: <20240806090241.576862-9-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806090241.576862-1-poulhies@adacore.com> References: <20240806090241.576862-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Yannick Moy Wrong interpretation of the type of the concatenation can lead to a spurious error in GNATprove when inlining code. Now fixed. gcc/ada/ * sem_ch4.adb (Analyze_Concatenation_Rest): Do not add a wrong interpretation of the concatenation, using the type of the operand already recognized as of the element type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index fc3a2a43c3c..9b77a81e43e 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1995,6 +1995,7 @@ package body Sem_Ch4 is (Root_Type (LT) = Standard_String or else Scope (LT) /= Standard_Standard) and then Etype (R) = Any_String + and then not Is_Component_Left_Opnd (N) then Add_One_Interp (N, Op_Id, LT); @@ -2002,6 +2003,7 @@ package body Sem_Ch4 is (Root_Type (RT) = Standard_String or else Scope (RT) /= Standard_Standard) and then Etype (L) = Any_String + and then not Is_Component_Right_Opnd (N) then Add_One_Interp (N, Op_Id, RT);