From patchwork Mon May 6 09:18:01 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: 1931846 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=Yw5a88Nn; 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 4VXwrd3wpyz1xnT for ; Mon, 6 May 2024 19:21:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3359385EC09 for ; Mon, 6 May 2024 09:21:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 4596A384AB50 for ; Mon, 6 May 2024 09:18:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4596A384AB50 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 4596A384AB50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714987086; cv=none; b=gmSaFduE4Ui2wNFdTec1XnY7g80Ov/Asz3VRlsMwdh9jhFBZNBj+bi4peQi/de/M/AzWKvzkmZup3b9otznQJ3cqxdAwgN44irPRa5uQknwryIv0FNqgV5skS2+jPwDK8CvAV9qkA5bebl/85seZIDN8EO6UqHkXni7y7gY1IoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714987086; c=relaxed/simple; bh=7dcGORKYPooEXt2qnxivN3qN+WSqrGCZAPVWahPGvnk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=amY9TMC3P1wrWKysYAzZO3MgPGO4ERg1rV6iRyuOoM+hjdDaAJqGiof820NfgiDzdSto/XYPladvchD3W9RTbbmGk7e9J8cvDKv12BFFvIqTSiXkgmZWPAjTYLxCUb2kOKHq5/eLbwN20kbu7IrkDCwo/MZIvWsTQaSN7tToeQs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-349545c3eb8so1153544f8f.2 for ; Mon, 06 May 2024 02:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1714987083; x=1715591883; 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=6E8O+GYh41GOLtcgkFkc4LZvrKfoAdHOzpFmDHXKRf0=; b=Yw5a88NnmQbZB5wnYe/ioSyVJXehJfAfIk3DVaHwF1XENi9DsVhN/Hw3jG+Wfs9R8v IwoU/4PUV4wEbmGZsLrVwbn5ZymUtLjSOXdD0kLiFy/LVKRvN3tRwZ7LrZz8pFTOWBwt VTCa1WWWJOpf2c47mNIRVa3ASMNtQMn4yc1HzHvrSYTX0Ni7QRpioxOAHNXkLimrXaYA BMVo9snq7kf5jpj+PMYCPqr1KfNYfckh8TSf7jGwb2ce0m5NA2KlgJ0c+kTvTxeonSjH IFXHB+7zRHRXV7cUVuY7AT1MHldWY+/qDhKUka4QSaYyHNfjPiCuGEtfOE9p3mojFdnQ F91g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714987083; x=1715591883; 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=6E8O+GYh41GOLtcgkFkc4LZvrKfoAdHOzpFmDHXKRf0=; b=AI5WCwUitMBX7caZwT3R38dtO7Z2UBo8V4fd8pMY9O1Oqy9sIUhutzgPNjlc97zh6D JW6lhrJnP6MC4qmQHxNRb7wQil+rxmugMJaZYkzIY9ZDDZidzT2YZOYigmCZoj+hbIhJ 0Mu3n8508sq98axmURDhxVx2Cvz5ZUtKfU4bS3TVY0b5MQBMBoZ2fDHaAbRxgu8PKM4S saIlM8Lhq9xaHa7NcyWwBj9rQM04EQVrsLy8rWlq+niW7rYgIfYLQr/f8gUPSzn7TWsJ gKBGUp7mAaeX2+HjG/wHPdkKKyuhDmqTkhNwwDePBqt3V3QFx2i555PPmxJZVRBdvGap XfSg== X-Gm-Message-State: AOJu0YxKEBKVaDQe5n+bkgJRIDlcLhIJAN/fxULmvZjKxa5FyOE2VJnk cwLTmt/PrRQtnQhOL8y9uZAW5zAc763HIdRCU+F7xztB49xeL5SFV2s2GzxGhcI8Sa06Mj9JvPE = X-Google-Smtp-Source: AGHT+IHwaTwISt8LcJVxpNlhdz8gvx7m8sadFdXqDOrMiJozTgEWC5HSG5ii8XqcOg2ubVqkgPhu1w== X-Received: by 2002:adf:f6ca:0:b0:34d:aadb:31dd with SMTP id y10-20020adff6ca000000b0034daadb31ddmr6893215wrp.13.1714987083131; Mon, 06 May 2024 02:18:03 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:9ea2:39d7:df74:396d]) by smtp.gmail.com with ESMTPSA id h1-20020a056000000100b0034e0b56a62bsm10176493wrx.44.2024.05.06.02.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 02:18:02 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Richard Kenner Subject: [COMMITTED] ada: Don't propagate convention to internal subprograms Date: Mon, 6 May 2024 11:18:01 +0200 Message-ID: <20240506091801.1585222-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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: Richard Kenner AI95-117 requires that all new primitives of a tagged type must inherit the convention of the full view of the type. However, we need not do this for primitives that are internally-generated, such as for finalization. There are issues with GNAT LLVM when primitives have convention C since the UC from that subprogram type to the type used in the dispatch table will generate a warning. We're not doing anything here about the case where the convention C is explicit or there are user-specified primitives on a type with convention C, but let's not make the problem worse by putting convention C on internal subprograms. gcc/ada/ * freeze.adb (Freeze_Entity): When changing the convention of primitive to match that of the type, only do this for user-specified primitives. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index d032b75f1f2..4cb5979b016 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7327,17 +7327,21 @@ package body Freeze is if Is_Composite_Type (E) then - -- AI95-117 requires that all new primitives of a tagged type must - -- inherit the convention of the full view of the type. Inherited - -- and overriding operations are defined to inherit the convention - -- of their parent or overridden subprogram (also specified in - -- AI-117), which will have occurred earlier (in Derive_Subprogram - -- and New_Overloaded_Entity). Here we set the convention of + -- AI95-117 requires that all new primitives of a tagged type + -- must inherit the convention of the full view of the + -- type. Inherited and overriding operations are defined to + -- inherit the convention of their parent or overridden + -- subprogram (also specified in AI-117), which will have + -- occurred earlier (in Derive_Subprogram and + -- New_Overloaded_Entity). Here we set the convention of -- primitives that are still convention Ada, which will ensure - -- that any new primitives inherit the type's convention. Class- - -- wide types can have a foreign convention inherited from their - -- specific type, but are excluded from this since they don't have - -- any associated primitives. + -- that any new primitives inherit the type's convention. We + -- don't do this for primitives that are internal to avoid + -- potential problems in the case of nested subprograms and + -- convention C. In addition, class-wide types can have a + -- foreign convention inherited from their specific type, but + -- are excluded from this since they don't have any associated + -- primitives. if Is_Tagged_Type (E) and then not Is_Class_Wide_Type (E) @@ -7350,7 +7354,9 @@ package body Freeze is begin Prim := First_Elmt (Prim_List); while Present (Prim) loop - if Convention (Node (Prim)) = Convention_Ada then + if Convention (Node (Prim)) = Convention_Ada + and then Comes_From_Source (Node (Prim)) + then Set_Convention (Node (Prim), Convention (E)); end if;