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: 1969383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=XqNwI4AJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WdS5y2fWcz1yYD for ; Tue, 6 Aug 2024 19:03:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CEACB385DDF0 for ; Tue, 6 Aug 2024 09:03:46 +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~incoming=patchwork.ozlabs.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.