From patchwork Wed Oct 9 21:42:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1995110 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=A5xs8UxG; 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 4XP5zP1Zcrz1xsv for ; Thu, 10 Oct 2024 08:45:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB206385DDC4 for ; Wed, 9 Oct 2024 21:45:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 65A44385332C for ; Wed, 9 Oct 2024 21:44:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 65A44385332C 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 65A44385332C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728510284; cv=none; b=C9rB9sH0jrLNfFuXSh683VhdeW+51PwjgzypYz6ZD8GMRabI8g81gLEXpx9m5vYzByOhGD/C1+H5ztKyUwfzCPFvifKzzbnE0JxR6EToZg9wKYZMDyBzg7Aqh5L6zKrlPNW58Yzm3zgqaRpDf93MQHVOoeqCEiqdrrOiCNF/UUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728510284; c=relaxed/simple; bh=d7gqy7tk9kzQ4mJQKWZyu6MCme7ZiEkdJcUDzcx+kV8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WfnIoTF+6E1NSo1piDnfsq7wvmg+1SKHdh4b9lFdh4+2MthsdspHYQBI6Cy0eQ4g9ploogTlW8aJvN4UiRfAWq0Tz30HyHtLFS4hXBo/qZBm6VLZ5l41RtiovhVMsSH0sd4yIT5tZKy5U9gVwxJBZvZhYdPPAtm9TwkeqqxjPEc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2fac9eaeafcso2478391fa.3 for ; Wed, 09 Oct 2024 14:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1728510279; x=1729115079; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=fQacXrmST+bGuhM60F8a6Lsh6v8wKoQUQChRQ9sR8m8=; b=A5xs8UxGMx1dnA4TSmMVD/hWKNENEV1dRtu4GdjYeuNWY6WepgOXGHuG7SfpARYxyw eyr6n8vYbxNCdvP2AHuaIAvyJlu7blFa4CRb0hSw6pL8/9o6H52IXpBvOe5EumepVLpC HdEypCz+9XfE2CunBX3u/JDmr4U+yqi8+ntMHhx0CKUhVz1xSEXwFI9/J85c2W8+5g6L x/jUX4ynkz2DCL8Hn55JSV7qRLTXRV2Hxjf3EzJnTYzvdLufuYz1YMRwTijAvTEXf+WZ fU0e5fNxcEGWAKjPCYBtMPqT/PS/cQPByt2l0uvVNb28qVk+wXyvq+jMon4qwbw+WOaa L8MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728510279; x=1729115079; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fQacXrmST+bGuhM60F8a6Lsh6v8wKoQUQChRQ9sR8m8=; b=oBKoj7pa0Yxn0W4ulin29aTjLTylw+PlxyCkuW0Cb0ZwbU3lnWZ/VuDuj6aZwz3jba VRIle4e2Yp9f/1CarsZLCTxae3wswRkBgOFupb+dWcU4AS8HXZJGl1VI1ZGGfcKf4WfE 9EvTb/go/F1avklpvlUd4PmPqMToxfZYazGCZuNQEPYbohpE52JAdsyviuHV5tnnBAuE jrdJhs04SYDQUcTs79ef81t4618wuBBWTunaehHbhHin/Ex83BMNjEZIsnU0zuwNtr1y X1Ad5GwzaRYljfY3xUEpqyXli60AV0Ghv+MZGSk1gDGfXKlWCNnjT3t0TEs04EtofTry HHUQ== X-Gm-Message-State: AOJu0Ywe5Mgj6VkEsDVNkpLgvHc3cmthyRkzvNK4pDrm6UcRAosBNhY0 EK5b/dOJNfstJISlKsUT6Haaw1dWUP/qG/22yOVoQ0sI9GH1des70Z28OZ9JliJxDpL5ETosQyc = X-Google-Smtp-Source: AGHT+IH2PuMsh3TpbzkU1knvpq9akIKTwg208Qp78689kbIlDzlSNjhtNgONSaPQhibXh+jk1VPHHg== X-Received: by 2002:a05:651c:154a:b0:2fa:cf82:a1b2 with SMTP id 38308e7fff4ca-2fb187ac586mr27756861fa.31.1728510278581; Wed, 09 Oct 2024 14:44:38 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1690f77dsm11367773f8f.2.2024.10.09.14.44.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 14:44:38 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] PR ada/117038 Date: Wed, 09 Oct 2024 23:42:53 +0200 Message-ID: <1945702.7Z3S40VBb9@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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 This is the LTO bootstrap failure with -Werror=lto-type-mismatch introduced by the patch implementing the new aspect External_Initialization. In GNAT's implementation model, using convention C (or C_Pass_By_Copy) has no effect on the internal representation of types since the representation is identical to that of C by default. It's even counter-productive given the implementation advice listed in B.3(63-71) so the interface between the front-end and gigi does not use it and instead uses structurally identical types on both sides for the sake of LTO. Tested on x86-64/Linux, applied on the mainline. 2024-10-09 Eric Botcazou PR ada/117038 * fe.h (struct c_array): Add 'const' to declaration of pointer. (C_Source_Buffer): Use consistent formatting. * par-ch3.adb (P_Component_Items): Properly set Aliased_Present on access definition. * sinput.ads: Remove clause for Interfaces.C. (C_Array): Change type of Length to Integer and make both components aliased. Remove Convention aspect. (C_Source_Buffer): Remove all aspects. * sinput.adb (C_Source_Buffer): Adjust to above change. diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h index 36f5e9bfe9e..e3e65fe18bd 100644 --- a/gcc/ada/fe.h +++ b/gcc/ada/fe.h @@ -348,17 +348,17 @@ extern void Set_Present_Expr (Node_Id, Uint); /* sinput: */ struct c_array { - char *pointer; + const char *pointer; int length; }; -#define C_Source_Buffer sinput__c_source_buffer +#define C_Source_Buffer sinput__c_source_buffer #define Debug_Source_Name sinput__debug_source_name #define Get_Column_Number sinput__get_column_number #define Get_Logical_Line_Number sinput__get_logical_line_number #define Get_Source_File_Index sinput__get_source_file_index -extern struct c_array C_Source_Buffer (Source_File_Index); +extern struct c_array C_Source_Buffer (Source_File_Index); extern File_Name_Type Debug_Source_Name (Source_File_Index); extern Column_Number_Type Get_Column_Number (Source_Ptr); extern Line_Number_Type Get_Logical_Line_Number (Source_Ptr); diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb index a5f4319debf..04246dc04eb 100644 --- a/gcc/ada/par-ch3.adb +++ b/gcc/ada/par-ch3.adb @@ -3841,7 +3841,7 @@ package body Ch3 is -- end if; Set_Subtype_Indication (CompDef_Node, Empty); - Set_Aliased_Present (CompDef_Node, False); + Set_Aliased_Present (CompDef_Node, Aliased_Present); Set_Access_Definition (CompDef_Node, P_Access_Definition (Not_Null_Present)); else diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index f2e6dda1c99..2b7439f1036 100644 --- a/gcc/ada/sinput.adb +++ b/gcc/ada/sinput.adb @@ -281,10 +281,8 @@ package body Sinput is --------------------- function C_Source_Buffer (S : SFI) return C_Array is - use type Interfaces.C.int; - - Length : constant Interfaces.C.int := - Interfaces.C.int (Source_Last (S) - Source_First (S)); + Length : constant Integer := + Integer (Source_Last (S) - Source_First (S)); Text : constant Source_Buffer_Ptr := Source_Text (S); diff --git a/gcc/ada/sinput.ads b/gcc/ada/sinput.ads index ce47fef76db..d33c4708352 100644 --- a/gcc/ada/sinput.ads +++ b/gcc/ada/sinput.ads @@ -56,7 +56,6 @@ with Alloc; with Casing; use Casing; -with Interfaces.C; with Namet; use Namet; with System; with Table; @@ -708,12 +707,13 @@ package Sinput is -- to avoid memory leaks. type C_Array is record - Pointer : access constant Character; - Length : Interfaces.C.int range 0 .. Interfaces.C.int'Last; - end record with Convention => C_Pass_By_Copy; + Pointer : aliased access constant Character; + Length : aliased Integer; + end record; + -- WARNING: There is a matching C declaration of this type in fe.h - function C_Source_Buffer (S : SFI) return C_Array with - Export, Convention => C, External_Name => "sinput__c_source_buffer"; + function C_Source_Buffer (S : SFI) return C_Array; + -- WARNING: There is a matching C declaration of this subprogram in fe.h private pragma Inline (File_Name);