From patchwork Thu Sep 11 09:18:33 2025 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: 120026 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 11D2D3858C30 for ; Thu, 11 Sep 2025 09:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11D2D3858C30 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=QItCTJhj X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 6CA1D3858406 for ; Thu, 11 Sep 2025 09:19:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CA1D3858406 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 6CA1D3858406 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582357; cv=none; b=XntMnZv68vOBXOyb198t7HG8McHJRmQPIfDwOl6u5LZNKeubY6fKDjCX1WMBmyh1GG72qI+WjrfrzlbdMsHy+oywmFXCZ8rdkbZHpIqGK8OQsjC4oCUxFzsGR7Z1WLR5XYKm2OEneRNsc8rwnAKmu7dsC6YiF2779F0U5bKCX1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582357; c=relaxed/simple; bh=owWdQersP8/VHySR5ew7ZLBq6oX4EuoWgDA4zqMp2fQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Go6oEoznIbAEItdfAsZZd9eyyquLAL/bsbNaidcLY0PHvfTJ7ECW7BKtnTmHSuwsSbVxijMEPOALptunYuHpkoIoisRWItoSwke12/OLLl+alSNs0sZfgUZBpdjlvaHQRkBs+CnsnSWp2M60EJf2t4UQAsRxQWEUieFVh4R6sC0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CA1D3858406 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3d44d734cabso429616f8f.3 for ; Thu, 11 Sep 2025 02:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582356; x=1758187156; 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=MDKSUoRZrjaIfnebxVw7smLLKRmsSSd6yfftd6tMQhQ=; b=QItCTJhjr6sywuRsqriFMI2Xthae2xYEFvAMXexH0hhmZ2eSiAKHgP42NloZ9JR544 k0aY79viYXTqe9pJkHLf89Zmbkxw8QvhQeSt0KRN65Gy3OtLshQX0o/zqJK/6u4kCBMK ann6kSJFWKdEN0OqwRP/3CAZGkbepc8SWyA6TfKbvy0iD6lI41aCQt7izRb/qrWFejXd y9gggP5WPSBOog9uVahBx7nirxGdCetVCOvZa/g5idXYaAextIQHvR6aM/9jpFbIrcQr b/WHzpx1uQUOAAsaWwCk+p2j63jif/f6eakN/CvhOVSUwm5fQM+eELpO8ETkNyV8GLNo GVcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582356; x=1758187156; 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=MDKSUoRZrjaIfnebxVw7smLLKRmsSSd6yfftd6tMQhQ=; b=aQmnhcoqVWCo/785rhdXHBhBguLSefzRys6SueVS8+Wb211GE6XVtZK6L4/7/zEzgf SrMQpy2iMqX0jWJokZsmvuJ6BBMzr+Hei7HPKmvEiUlEODSygOBQI8BUtUI4pxcnZ9R1 SA+SL0RIlLYfdOTsHmULmHpgjt+XVUWEIwY8qGwuNHl69yMMXfF1ZOn9YctKJf5NRxpH M3ICzlJSIIjvBKzhNMdP4BNDDR2D1NeOZzV1cWCbbMJBeXWrfiEYPdJ1X24niJWshWCV ETRNrmrX5qiEcrlgxZacbVEwm27evZvtiV+BgK2yzODQl2qZJ3UIihBLJkpWkh5kxPB/ emEQ== X-Gm-Message-State: AOJu0YymIIQCQpMR69kowL5hX2uG0tVFmI8uH5CgNMs94jYdKFsUtFKL dhxz7dkBWK9Y91YMS0qSjXW4UJ/ilZBwg5vrkaasunt6CJm5uWoXtyvfIzVOg6aJTK1MtLN94V3 XQB4= X-Gm-Gg: ASbGncvR1e2U/mBz/oUeSUK/qnEJo8wJ/sFVeOlelEwWWz62wKLVX3MLvh+1W1BIIUB 6Os4sLb8s3SPmePL1IRgKMw5iqAr9XlT2GoXqLGdEXtAY5YE4KN4fSv5/YYPbzyONbmQDZHHyd/ zMowwZF5DAp4BOzpYRI6z2pJKIIGehNxDYA5z3FkH3QIgsazoBJvLy4hjQ42DtPe5ulK3zLmiBS 1wMGgngOMCoohENwNzg5uFolpOaQ0Ye8tRzS5myn4yLGi6N/T4RaYD0DJoi7/fGUTzqfVOuKKpK 5FpnYKwubWBZY95x0bVYKPy90DAaGWAh6FRxdic8iretDL/0+iFH2X8d0y1icsoOtRWXqmDSwA6 lxFM2BiL9V88Yv7OLU2PJTcNZuhUcDIki/LYnciAQQkBbaQEzWZqzvmpbTTTIElcA6e0AIMU4uF BM52LEkjOn16o5suxVBprtkyvDmdRixoJ6C63f5IVeITbafOiI X-Google-Smtp-Source: AGHT+IF7QJKh//ykaOBHqh1JtGMy7Wnqpctq74mdyihkD/bCCQ1DDoxSyphuKcwgsfmfMGLZX3DPDQ== X-Received: by 2002:a05:6000:2209:b0:3e5:9ce:624d with SMTP id ffacd0b85a97d-3e64c693a58mr14707930f8f.52.1757582356018; Thu, 11 Sep 2025 02:19:16 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:15 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 01/31] ada: Disable new warning for composite equality ops that can raise Program_Error Date: Thu, 11 Sep 2025 11:18:33 +0200 Message-ID: <20250911091904.1505690-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 The new warning is spuriously flagged on membership tests in vss-xml-implementation-html_writer_data.adb, leading to the GNAT CB failing, so we disable it until that issue can be resolved. gcc/ada/ChangeLog: * exp_ch4.adb (Warn_On_Abstract_Equality_For_Component): Temporarily disable warning. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 9c987a6fc436..2ac5e797e512 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -8423,6 +8423,13 @@ package body Exp_Ch4 is is Eq : Entity_Id; begin + -- Temporarily disable warning, to prevent spurious warnings + -- occurring in vss-xml-implementation-html_writer_data.adb. ??? + + if True then + return; + end if; + if Is_Record_Type (Underlying_Type (Comp_Type)) then Eq := Get_User_Defined_Equality (Comp_Type); From patchwork Thu Sep 11 09:18:34 2025 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: 120029 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 8E2933858D35 for ; Thu, 11 Sep 2025 09:23:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E2933858D35 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=fA95mJsP X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 478D13858C53 for ; Thu, 11 Sep 2025 09:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 478D13858C53 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 478D13858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582358; cv=none; b=hDW4aZnEQNx2tT3Hc7LYqzpr7ZdLWkzwMnzTfM8XfUNaHtHs4PJKD73RvrEWHVmP+ITijZFBFQ9BjbvALMS7MMCflrkvkdnXOSbQu2eHcJI9pGRRh3uuEF/4k02nWuy6WU5ZQI5dyUBdsWrDecWto9xw2OOXRinBs4EX4fntYOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582358; c=relaxed/simple; bh=Ywu9oWLjgWPbOFvvv63wmJqwnOBI1a0MFKjijWNDFXs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UZ5C6jvN+Dh3MijL2DocCbaog7E7psSW8ucPuWFWOMQCKPBqvdx1rjsY6ZU0HFfs5AaeF2d7smu4grdvVWPmON1FY1+rnl6qKR01LH/YFS12N6b4zCZEIbz71d7IJBopaHG8Sk3Cf8duUmN78WIDivELab9F8j9U9OpXKqgCd2g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 478D13858C53 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3d44d734cabso429633f8f.3 for ; Thu, 11 Sep 2025 02:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582357; x=1758187157; 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=7fHn4T9BphL3p+QKzrMZWLQFjkVDrnaYQ+tCB+O5LWA=; b=fA95mJsPSnlXdJnIksjEO6sXp0pm5UPjRKC7oMk0Zz9FMtwltAJAp9iA7VjIgZVSbR C4asUmmaHXVqUwlj9/4taWfXBttU5x+3gaGsRyRveq3RNe422E9cMma/GC7fG3yMiOTz BaamcCHgHSpWJlK/mFoTVwCM8lvpAJQdQvFIh39JQbrDjteXYo9nPwt1z3xm7vJ/AOcw FXEB3Ym2UHfalvEqN4HvNrz8/0KC969n2yhW7tU30v++MILnWvYc/Ij8rric0/zzaWBM CG81NSjDW7VrE+sS2XQdwF3BULAxstNpDi+V8/TTF6sLxYPRM6CjXlKJieiaws88M0J6 E9BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582357; x=1758187157; 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=7fHn4T9BphL3p+QKzrMZWLQFjkVDrnaYQ+tCB+O5LWA=; b=vfDCQUMRNBBGayPspr5vZdu7YgI4DmS/QjzfPnb+zq49oRDnbymUnVTuH3q9FhOEet aMZUyukCWI9mL2/fvybFpGPjiHz2Nkw5AgMN3oCVWo8hnibc9k9Uo0qGmg6LcK+/MSez UltB+TqEEinzkTMNLgDQJ/Haq3FT2jkHSg/1VyTuxyOcT9y3OjlFc3W3SqHfLOBUjS4p nWz5WU33DxOZlJei7GexFKFOkMmDd0wZ8NHbQxoy6Mo4fkdTJJtOj08JbaD2R1PbChYC FoflXERoFB8s871COYm8QgJhntnmzraVbcNsNrS+hKcOtVpcd97PsbbH9C5PtqoIm3IS +fmg== X-Gm-Message-State: AOJu0YzZN7EPOLh9RdST1T7b+PilpMcoxmW/L0AOLDNG16OSnLpviOMA uQdomxUO+ZJFd0x9dk7fqoj2pwglTY3vUKPt3fEIK3AArbKaTJHvisqskKsstYRQ2kSaCHxeg+z QPKA= X-Gm-Gg: ASbGncuy9yiXl5SM//GvVpkYlRLws/UT/d8xlIE/MFAIQ27+jUuJPErqeACWMTLRREe Hb8VMLFo6dkGAbjmJ0F67F6PDC0/WvZlzoq85C8dBu7w4NexlG7gN5ZZvXafx2dk0aslgOGhBMI p5EENTm8KS/Ow3PqN/hWRyRI/2W04Pd8rXIVVzvtLAauh0tcWc2m6ysvNsqTeU1td8Bbx0j4PjT 1Jp8bkp+ZNertl1ufz3qIpSqW43RIqg8CRzQP0MvKC5gTGdUL/1OvmuBPva/sKK8I7PwQ4ok/Y0 GP+CjQCT/YyndgE0cQNUT90/oBWpG+IfDXe69bre9W4r+j/u+C/qb37amQ2WcY7otHIBj/PGxJq vyvVj66EjlKUVMTfU+vFbvW8ZsxUH0jA/dwKYNI3cPyeS8vQsHNNml5OKCuex9Zko9wsf0hPrqF nmIvS4RapuYfMqqVMgbnSF9oX8XhuJcN5Z8F1g7gt6Yf0icg8e X-Google-Smtp-Source: AGHT+IE/rFv24veBiRg2I/SEZrzKJvHSq3kgK9m/gL3/q6+4k9xd63JtwfQx8ZiZ+w59LtH0tKMFdA== X-Received: by 2002:a05:6000:2003:b0:3cd:590c:61e0 with SMTP id ffacd0b85a97d-3e64ca76d16mr16101039f8f.54.1757582356835; Thu, 11 Sep 2025 02:19:16 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:16 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 02/31] ada: Improve documentation comment of Find_Type_Name Date: Thu, 11 Sep 2025 11:18:34 +0200 Message-ID: <20250911091904.1505690-2-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Ronan Desplanques The meaning of the return value of Find_Type_Name depends greatly on whether the declaration it's passed is a completion. This patch adds a description of this to the documentation comment of Find_Type_Name. gcc/ada/ChangeLog: * sem_ch3.ads (Find_Type_Name): Improve documentation comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.ads | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_ch3.ads b/gcc/ada/sem_ch3.ads index 0880dac04212..0c2e66f293b3 100644 --- a/gcc/ada/sem_ch3.ads +++ b/gcc/ada/sem_ch3.ads @@ -165,12 +165,25 @@ package Sem_Ch3 is -- node or a plain N_Identifier), find the type of the subtype mark. function Find_Type_Name (N : Node_Id) return Entity_Id; - -- Enter the identifier in a type definition, or find the entity already - -- declared, in the case of the full declaration of an incomplete or - -- private type. If the previous declaration is tagged then the class-wide - -- entity is propagated to the identifier to prevent multiple incompatible - -- class-wide types that may be created for self-referential anonymous - -- access components. + -- N must be a type declaration. The declared view can be incomplete, + -- partial, or full. The behavior of this function depends on what + -- declaration, if there is one, N completes: + -- + -- - If N is not a completion, the function enters the entity of N in the + -- name table and returns that entity. + -- - If N completes an incomplete view, the function sets the entity of N + -- as the full view of the incomplete view and returns the incomplete + -- view. + -- - If N completes a partial view, the function "swaps" the partial view + -- and the full view (see Copy_And_Swap) and returns the Entity_Id that, + -- on exit, points to the full view. The value that + -- Defining_Identifier (N) had on entry points to the partial view on + -- exit. + -- + -- If the previous declaration is tagged then the class-wide entity is + -- propagated to the identifier to prevent multiple incompatible class-wide + -- types that may be created for self-referential anonymous access + -- components. function Get_Discriminant_Value (Discriminant : Entity_Id; From patchwork Thu Sep 11 09:18:35 2025 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: 120027 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 280D13858C60 for ; Thu, 11 Sep 2025 09:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 280D13858C60 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=eva2dn3y X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 19B923858D26 for ; Thu, 11 Sep 2025 09:19:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19B923858D26 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 19B923858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582359; cv=none; b=Ao/DtiEnYqbL3hZi2Ss2fiBJHdyk0CFaPefDNn8pn6Yolt+FcPI/GL3JZne6HDNvDWse7YavIWis87LYdj2/R6Sl5boH6ScsxJU5lfp6t5YTHxXEtl8q+azDCRaqc09NLV6QJdUGpAGK+pWMo/dhDSgrZQjeXKpEdozmc/0bXlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582359; c=relaxed/simple; bh=t7FeuJltw1FyHYygIAIBZV4bEp8Kbyx03rMDyFtsmmQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lSAyV98wmEWnb8AUwdpEaCorepe/+VQhSfH3Kjz/R0zy1NMiUAXP/u+1Dn1usH1jGG16RQmD+oZ2Q6GtTKBrf9CO7r5tOLpMC177uOdx/PLjD8ZaqsMG3kVAFivolbrgvMI9TOa5AtWKeYK5O397e18czAVEbY/aKyxqK5p4cjk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19B923858D26 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3c46686d1e6so339797f8f.3 for ; Thu, 11 Sep 2025 02:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582358; x=1758187158; 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=C3Q+hxJoy1VOka6Ifmd/RYyzbMzMXBOZ3uB3dLvIdpM=; b=eva2dn3y4FYvfeoP2NrBEwhT75WwHReXUZMtjLNyndsVqatuQPghSE0NUDgjYT4P3z HwQw5RsZhJESoYgBmXBTOehNeTddtE9kSsf/XUOzAPR9dXpqd4IjkNBZ+PTP4YzVimPY hfEZZwVye5RF/uYe5hAP1PCKPP1DDx3JZCWEtP7VbFaLFl/vICd0ctK83fJOMqhBMJTD cPIkx47rhda+IbNIU8L+16QdipB3PW8s3btbwYu+M+o4U7Yk6qq1vb+QcQfKdiCrwdUR Q4C/Kefo1kf94IEpDaZsIfTqjNIcm1+bFSxmi4HTukt0w4JnNdD/jITQ7zBvKhPkRdGT naiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582358; x=1758187158; 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=C3Q+hxJoy1VOka6Ifmd/RYyzbMzMXBOZ3uB3dLvIdpM=; b=INKpsL5XnMheQZCBnZUoHvBufULwJoxS2gjUH+Nsx2RkY8/x9w0C42X6kn6L7jtdye YWsiYcLn7nqpLRT4ubKzBJKFpYPE49NOi+5KrEglGKLW5befLcNznF8BXt+7cc8Ecf+n maR17UmBOmTxawmze5qPHhXwtIXOJrFDrRMH/iQd4BRE45GoDGdzaL1pyjmBhlwTSPn/ 2mcAxTVi2O4fbcaVXyHuO4RuiIK9BQR/2v4eYXX6mygGvoluqC8USFLHH9D3kvwH0g+h xPoBBWiHEVKHixWsW9J+N0hL59g4ffZpNMCAvxofVA73wJcXJehlYlJ5VcI11jfBHJWy dm6w== X-Gm-Message-State: AOJu0YxPoGdVWfGB0KYVEu6IWb9M9IU8CE8l8FCJvt2CucMVANrEL6ae /uZI/vqkY143Zh334zeOSmrw1FrhuBAeDB6hDgi6XZpEGnWR82evjM2wbEMlicoutltT1yUZp9k yYRs= X-Gm-Gg: ASbGncsHx5uHXeuqitnZDRlAZggWrEbO9059cypQGwlZxxuHD8wzzq+N7ZycKAbJDeW M44RKKwYlf8GJ3acJxl3VE4H+vDywvJBv1rpdJIthMJrmXYD2QCBwKYOciayZ9HvPxoVCRBLdfi DQ6L7A7cVASczvRZHm/cWPII5Vi9Nhh0uBYf1BEdhUWUnlooxayWQKlo4IrzLLAhodwuL+ufCub FfrfzxlrcjIkUQs3gBPMab8UaRmropGCbyKDp/MHMKEGa6iOfGAWHXbYQflMoc1fU4XsA7JQIYk /GegrLkeN6ERtuhP2yuZGtyHXiwzT8o675B83vDV0i5PwfObUaBe8SMgxtL2w/MqBKNaWkOpSoJ lwGWj0pkJrs/UFugE/dFrDkonrsrDQZxdGsDKSNeVzBVvk26S3XLZSI0tguzCDVR79FITcHrrC3 FydV8tAsdaSM3OUPgDUv6zR5aYCU0y6lqCUymEesicN2dheo9a X-Google-Smtp-Source: AGHT+IHuIU5yi1CRO+B/wkwe/ii+RvjBS51s1MRfXJGmy4Tqty/c6/kXXbjGClbF/08zNBJCjKPtcw== X-Received: by 2002:a05:6000:1449:b0:3e5:a68:bdd0 with SMTP id ffacd0b85a97d-3e643a245f3mr16161245f8f.52.1757582357710; Thu, 11 Sep 2025 02:19:17 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:17 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Tucker Taft Subject: [COMMITTED 03/31] ada: Set Related_Expression on compiler-generated Valid_Scalars functions Date: Thu, 11 Sep 2025 11:18:35 +0200 Message-ID: <20250911091904.1505690-3-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Tucker Taft When creating the local functions to implement the Valid_Scalars attribute for array and record types, set a Related_Expression that points to the original attribute reference (blah'Valid_Scalars). This allows the Inspector to give a more user-friendly name when these functions are called and they are known, for example, to always return True. gcc/ada/ChangeLog: * exp_attr.adb (Build_Array_VS_Func and Build_Record_VS_Func): Pass in the Attr as the Related_Node parametr when calling Make_Temporary for the Func_Id for the array and record Valid_Scalars local functions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_attr.adb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 4eb0a6720f7e..7fc104d173bc 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -479,7 +479,8 @@ package body Exp_Attr is -- Local variables - Func_Id : constant Entity_Id := Make_Temporary (Loc, 'V'); + Func_Id : constant Entity_Id := Make_Temporary (Loc, 'V', + Related_Node => Attr); Indexes : constant List_Id := New_List; Obj_Id : constant Entity_Id := Make_Temporary (Loc, 'A'); Stmts : List_Id; @@ -836,7 +837,8 @@ package body Exp_Attr is -- Local variables - Func_Id : constant Entity_Id := Make_Temporary (Loc, 'V'); + Func_Id : constant Entity_Id := Make_Temporary (Loc, 'V', + Related_Node => Attr); Obj_Id : constant Entity_Id := Make_Temporary (Loc, 'R'); Comps : Node_Id; Stmts : List_Id; From patchwork Thu Sep 11 09:18:36 2025 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: 120034 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 C1B5D3857C58 for ; Thu, 11 Sep 2025 09:28:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id D10DA3858C42 for ; Thu, 11 Sep 2025 09:19:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D10DA3858C42 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 D10DA3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; cv=none; b=qlIpwuT3axBW7zCwTr2mOSp4ySB5CVNBhuqm/dyuB3za2LQgPReXPB5ESJ5ihPJ9ejNqPvFprM6/rT6TFwL6xXqDWjebcBLVIhj4P1MAKKSMQ6UL3H6hQPb5YipziqKkiZgRW/0F4RoKQAQLsRCN9jgqoh23TJzACqKhMdU0KWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; c=relaxed/simple; bh=BRRI+BKEoL7I0jVHBMU3PtudfiNWV3H7/EoFbkrmiRg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WTMQewJnPTclvKqsCad59MLPf3jwAUl/SODYBMrrE71GVuOFCIg4dG+I0u6hl3lfGNu2CAV1Giz3KaFfu97FxG/bt8ptxT4y9kcxseiVQ7wrzN8jjpdl14zZ1Ff7vxiyWGLGGeiVOaCvICxLpW8e4vBrqfxFjuYMxjM5uVFKkhw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D10DA3858C42 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SMcCzJez Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3e5190bca95so379003f8f.0 for ; Thu, 11 Sep 2025 02:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582358; x=1758187158; 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=7SjsT4v6YDrcDOD3q0Ax4Edlr3NpCsYGbZK2hAiznio=; b=SMcCzJezEr0vfG7wRM8XukKrx3icbQTVQeOS4EjcF8N41RrfdTad0GdgMcPnQF0taj kPmMQg/oI+54OfHFPN82x5cJjjyVyCjxMFIYOPDJGjx8K/cF0NV4wysN7AU8H68LFO8s F6+1loPW7wjgeDZxLrtWrRyKi/PJ4vPPXRO1MO09Qs1Esw05IpHcnfcOYrMnd8syT3uk ZvVHl3ALekUdWSXQwKsCFmV6uz1eYdT6bMyt8QB25G8yMHiQGUeqMkl/iwNfKtPBsAvA wfyXO60sf3FPTZWPxi3oQN0wogp4QYJbds1UnbDiX1NI1rzoYp3REKBIzMitfBwSrNlh 72ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582358; x=1758187158; 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=7SjsT4v6YDrcDOD3q0Ax4Edlr3NpCsYGbZK2hAiznio=; b=ICINXjUF69xPImlDG2VQH724gQH8AXiVhhmhr1EgWTMAVzwEeO+5Z431pe9d/p4Oie RTelTmgccABUEfg9gAxscKk4rnt+kJ8jUxvrw9l8C1I9oyd+svjDWk3g7AWYBT1wZbO5 RDX/w7fErYejH24U/yZWxkfh/LkRv9IW3RTAoKNB0bYosfcMP91Ikw/tnp6vhdAlwRn2 pCuyfHZ2i86/nzs8CsjST9l9y3/1xhHSGOtWwRj8ImhjEH7eBRE15gJD/9TeXZonpVd/ icSCs7e9HCUoMU7FFH+jJBkpmf4Hz3Zuzo/rzzqXN4doiOXHki8Prh4b+6DUA+OzreM0 QsEQ== X-Gm-Message-State: AOJu0YyQBBDwug7NrvX3LrNSrbnRbgzvzttbwBmn/m9aQIEwQVgp/98O iQ8WVfIhWc2nzY1p7iYfy5rweRxEbPDd1kfKllpo22ZTDGyU9cqJVXoimEyB2WsRZuPT93wajrJ zdJU= X-Gm-Gg: ASbGncudeSOjONM4rZxwlILWNUOsggwETqb2NyP4i9cW388cYRC3z1A4YhWu8y5DxF0 E7TLRaM1cOUBQh5F3EKVZf0Te2QPFvBsYo4bBsp5/N6BzgXmbdKosRf4pl0Qq1OBj8tLU2gO02M T9jQo0ZKDbVnZMkKlEQovOOb1ElycjHtBBjw0Nzv0XEn7dp33FLkf1shoGQUuJY0RX8/pgG677L A5VdlfC/DtiPzq1Nxsu8aeOldQuqPowhtAPvnnXb84pHUyuPmy5aD/CTwwxk/hKOHWue1hyvSaQ OEPlvROR0XrPkwxJI68pdMSgzuCaeWqD9H6gA0tpjDQWw4Mm9jJldqBXNyrAlrUnsGFdm9saX9N 3KbNR7NHJWh8DTE4xIVxZV0HhHfE8za+oajRmLrFMY37gjpM6OdCcfKLOBfPsR6K3lZF7+Z+y3i d7sCPrlVA8+HSOfIS6YfdmQgl+12MgRoqeh4uJ+A== X-Google-Smtp-Source: AGHT+IGaSZIeLgA1DSYe1Edtt2nFxptVzVsZjO6FEl+dMeeiZFMCtYOIywzmB53/LE17yEr8UdtURQ== X-Received: by 2002:adf:e350:0:b0:3e7:5ecf:c760 with SMTP id ffacd0b85a97d-3e75ecfca36mr1404955f8f.11.1757582358466; Thu, 11 Sep 2025 02:19:18 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:18 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Denis Mazzucato Subject: [COMMITTED 04/31] ada: Better warning when single letter package conflicts with predefined unit naming Date: Thu, 11 Sep 2025 11:18:36 +0200 Message-ID: <20250911091904.1505690-4-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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: Denis Mazzucato This patch improves the warning message when the actual file name of a child package with a single letter parent isn't the expected one because it may collide with a predefined unit name. The warning explain why in this specific case the expected name is not the standard one using the minus to separate parents with children. gcc/ada/ChangeLog: * par-load.adb (Load): Better warning message. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/par-load.adb | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb index 4a97f14ffb51..0206b56e174f 100644 --- a/gcc/ada/par-load.adb +++ b/gcc/ada/par-load.adb @@ -117,6 +117,29 @@ procedure Load is end Same_File_Name_Except_For_Case; + function Actual_Name_Collides_With_Predefined_Unit_Name + (Actual_File_Name : File_Name_Type) return Boolean; + -- Given an actual file name, determine if it is a child unit whose parent + -- unit is a single letter that is a, g, i, or s. Such a name could create + -- confusion with predefined units and thus is required to use a tilde + -- instead of the minus as the second character. + + ---------------------------------------------------- + -- Actual_Name_Collides_With_Predefined_Unit_Name -- + ---------------------------------------------------- + + function Actual_Name_Collides_With_Predefined_Unit_Name + (Actual_File_Name : File_Name_Type) return Boolean + is + N1 : Character; + begin + Get_Name_String (Actual_File_Name); + N1 := Name_Buffer (1); + return Name_Len > 1 + and then Name_Buffer (2) = '-' + and then (N1 = 'a' or else N1 = 'g' or else N1 = 'i' or else N1 = 's'); + end Actual_Name_Collides_With_Predefined_Unit_Name; + -- Start of processing for Load begin @@ -163,8 +186,18 @@ begin (File_Name, Unit_File_Name (Cur_Unum))) then Error_Msg_File_1 := File_Name; - Error_Msg - ("??file name does not match unit name, should be{", Sloc (Curunit)); + if Actual_Name_Collides_With_Predefined_Unit_Name + (Unit_File_Name (Cur_Unum)) + then + Error_Msg + ("??file name may conflict with predefined units, " + & "the expected file name for this unit is{", + Sloc (Curunit)); + else + Error_Msg + ("??file name does not match unit name, should be{", + Sloc (Curunit)); + end if; end if; -- For units other than the main unit, the expected unit name is set and From patchwork Thu Sep 11 09:18:37 2025 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: 120031 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 6FB213858418 for ; Thu, 11 Sep 2025 09:25:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id A48E13858D29 for ; Thu, 11 Sep 2025 09:19:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A48E13858D29 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 A48E13858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; cv=none; b=TGguMrHxkgDa+vhjG5w9Fjz60witYbGEY+LPCP8NUDNdwQqD7z6esybSn65hfw34bzQ6sLnDRj7K5c5ELN10CKJMNqG8FA6c0HHT0FzzmCC0QOsJ6Wan1FN05jbSuZd6g9/e1L4yD58LzU6xX+DvHOJTpHEFAO77xBvKWlcwgSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; c=relaxed/simple; bh=t9N3yKV2ax+z2lVLNT3fB9jaejSH3oA4MGUKtiveikQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cZpHhNJOZbj8OMzHtKw281UcL4svvFR3QVKEcp5Xk6PEkAKPsz3j215dM758A/M2gYwwcqcH7rRopIrmkQjBCETBIBCqN4IYsuGN9UqSoJiibvZPsMIb01UF5hr2Mi2oNK05GUvcTcnBn36ZUvTnEeIQO5UuqEwX9LUArULLjPs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A48E13858D29 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=it0F9mpo Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-45b9a856dc2so2969555e9.0 for ; Thu, 11 Sep 2025 02:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582359; x=1758187159; 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=3vgbttR7bK4j8INRky9bZDlasGH53BF35+6LpbxVDVg=; b=it0F9mpow+D6F0qshH9fMmJwuiQo4mP+pWo2/cfG1avgGdKB0Klzvkvk2vMBNHwxOj 65YTskD/K282xNTOc3Jetv4ZQ0G8Nz2IOCgM8wKd2tbFFMh1X0nwgzjRCLPZGyClETjY WE+YyviePL8solM7AMPexYylETneh3ct+disfpITgqusY8xihS5e8cbO0SNmdCVlVws9 ULDWorkoZ/50bO7tOURHsNYdaXlNAKy7eaqNBRqAxsqFWl3xnaolnQr0qbuzTXp+i1Wb MWRuKOxaqwuXeo1PgoroPppLwYJTsQNGupDDZTrQBXISEb+yh0wNdq2h/BOuM+MdcU/R HLmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582359; x=1758187159; 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=3vgbttR7bK4j8INRky9bZDlasGH53BF35+6LpbxVDVg=; b=fCtzwjvBE2aTR8ocI1SmHwJzJNbXJusSOg+s0w+5vdQqppI5bjced8xyTW8gdnjcHl KBIB8y415WAhwuE1ukOxPVtXySMKciLJbYTIHpDWJvgeMFfAI4rMvWTyrprhsLVjmWpi x8e4ei4JaG6E0GzTNknX6vryBaCebpSfwk4dYgaluf5Dle/IEL99+VSnTeJNmQuJH4Np ddr+DgEDoElu54OmSzE+WI41hnI5EdnR9M0NwwVRedS2zAmyaRSw0fBN78NusoPXBVgl LOCxFQvQ/YdHThEFEA5Cmu0vxW0XNjoUGrQOBqKanO5rzXE8taRa3oq3PYMb+2wMThg2 wILA== X-Gm-Message-State: AOJu0Yx4K0ynm2UEoTobGKUoQ7v/pRsBy9sYx7I+OJRIb15JBtHyRYyd 90BtFrikJgbKKSZpZ79/pQ8RKTlZzX2qRPq6VUqpT0kqCXumIKQnWJwZIyXzCSPRy2AaH6mN6E2 SDbw= X-Gm-Gg: ASbGncvcsHfoW4GksbbA3igLJTw1fi0Wl3h+3bu4OeBgxl1A6KOYfRqCK+M6itCxJTc YvmQjaJaPmHGNlB0wV9ON2Wce7fZ5Z8agHmwJGnT4gXYLvl8TZOxlujlOcUUGWHkI21QsK32oXT Na82go5ZwA1LYNqmQYSin5SjFtiuonRyLaEHSnh1UtfTHGaVPGz/QE7M9+RnC9MsaE+EkCIxcCt YxRZTCVS8FFTuaADVIsr6hQVCx4NgsVfrOaX1QXqJ0cH1Yv5n3MllwRc4dC81A70LMfpWZJPuto ESDPrd0/aj3Ztvoxzy65QykoWNAM11bgJQCOZK9o/vid9BsixklVncV1DXJeHFUR4Lt61vyS5dP LGGd9UXioNUFX/lRcAOxSSX4gFfcb+o5Vvmq272nS5LG8J/rNz4jD3+qjBl66ZhoQK1D6wwaC1a LEzxAQSwjyQzaqqKCZniKjO2HHCvcD+ZKq/t6wBBWb+VuST3qv X-Google-Smtp-Source: AGHT+IGmLZ2hTpbFU7Ayn1ojlD2SUVldSuqzn9qwWa/0Jzg5nee9haRMCPVFrzDWNVgHkdXeZA2TGg== X-Received: by 2002:a05:6000:2f86:b0:3da:484a:3109 with SMTP id ffacd0b85a97d-3e6462581b8mr18632068f8f.38.1757582359273; Thu, 11 Sep 2025 02:19:19 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:18 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Denis Mazzucato Subject: [COMMITTED 05/31] ada: Fix compile time evaluation needed for static unfoldings Date: Thu, 11 Sep 2025 11:18:37 +0200 Message-ID: <20250911091904.1505690-5-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Denis Mazzucato Unfolding of static expressions is needed when evaluating static bounds, even in the presence of strict analysis. Otherwise, we may wrongly identify static predicates as dynamic ones, and thus require unnecessary "others" default case. gcc/ada/ChangeLog: * sem_attr.adb (Eval_Attribute): Remove strict analysis condition. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_attr.adb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 3a494ad940f6..2a92ffbce4f3 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -8195,13 +8195,6 @@ package body Sem_Attr is if Nkind (N) /= N_Attribute_Reference then return; - - -- No evaluation required under strict preanalysis because locating - -- static expressions is not needed; this also minimizes making tree - -- modifications during strict preanalysis. - - elsif In_Strict_Preanalysis then - return; end if; Aname := Attribute_Name (N); From patchwork Thu Sep 11 09:18:38 2025 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: 120028 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 5A2833858D37 for ; Thu, 11 Sep 2025 09:22:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A2833858D37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=P4MayME3 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 59D6F3858C62 for ; Thu, 11 Sep 2025 09:19:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59D6F3858C62 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 59D6F3858C62 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=1757582361; cv=none; b=o/8vk3LveRyKYLXSLawAKG6dl1fOd9CgpSHdj1Nu3gEPvHvQHQGMxKZvqNWOYKkjMzsqXVnIbSJJvqz4D3xzUEU5JCx7HtnZ1lCuuh0oQtaEY8zHA9Uo8YULxVWR3wOqOQEeMu464QAAFzZlBwjxIczQbJkutQPj1D0oQ+iZBds= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582361; c=relaxed/simple; bh=n4aI0v0vsLuriu93uYED7mkkpYlnhmb/IcfPrRin0iE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=umzdPJ9bxIuR1Ja2d3BYWV7qi3Q5NOlJAV7k8edLEpabVOVMcon5Bx+Re9jB7AEbP2m1taXvToKU7BCTtqCfTnLB9EFMIAFpSIOm/ZpT7BZ0LsICM/jzxJIf4tKZqzllc6tF5H0TXHAUvk78+1koEW0suP7UUryI/Zok39zO6Ps= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59D6F3858C62 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45dcfecdc0fso4791625e9.1 for ; Thu, 11 Sep 2025 02:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582360; x=1758187160; 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=SQ6DsALtT79jlLd0UfHQbBpkoAVXbLiyCETxgrxT/hk=; b=P4MayME3C+FfAtjKPbbBiwajnZhwHwy1FJjVPAq6rYyCNABuW675BuWmH7kisB1JBO P9pMWi261c8z3WtuBdod2zHk5S7LgNdvChF3fQtD7blW9a4I8erlElsRW9VgGbtg/6q6 /aeMmHPWNrIK9E6HWX97hHFozUDSZbJOqumxkz0vCAkHpK6QXVzU1w4TLOL3bmTQGC8Z iDVtjHoovSUZC2GQauieSezuZmVx90fSAwDFTpBvUKI4oravGkgPo8OhgeTFgMDVHzIH HOEgW64A7MpMktefR0Waz3LFkYxpHaN9d4/VSqBl8GqNIp/3PeV+hfoJl05vf9OI9JcW Jb2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582360; x=1758187160; 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=SQ6DsALtT79jlLd0UfHQbBpkoAVXbLiyCETxgrxT/hk=; b=vOUjDEeCp43HGP5Aq5wlB6J1ggKgpt6ECpbPDRbbnNCgzmUQUtVyB74BEVG/MQ27Vf cDDz7JuwqrO8n63X04HEGlDp+XNdTY0pZbfSV7smBLnjM3McvG2QggZt7IhLOSzcQF5j nSLKD7X9zy3zFA/VP+Uv/XynxspN3MnFj9iw+bjPqKdT7zy5Y8amUf5ONKaHQT7/4khB RBPJJITlNsnh1KQQbLuXG0ZRQEziWZVutFxU8fqzVOscy+SwA9qQZvpNcEpPi1/g0+oc o48REJW57YECfsr5lvy7XWkjDvowPDhzPaEhySE5CuXHaRAW04dfOm/ZMTXh5YAh6VLV NQXg== X-Gm-Message-State: AOJu0Ywx1IsyyK1KwcleIC3vOqaSyn1s/M/5tO+BGvmXM5cyWf/ono25 CKHT4dAQ9Fe+TCPtFru3szpF6c1P27lDOB0lc2Us+7ekya9v8vVK+m9gEgwIGh4erYT13sCkktX nVwQ= X-Gm-Gg: ASbGnctzbbFLlz9h401Zc3dYjd3z5uk8GOmCStjDwdO6rZ3AA80z1VNkcW5XXYQIeDh L1vCR/JOrptNVOY2ygOsaS/5JEx5jUFxlPqh8JJAg/aVR+LkfbJzb9PLXDnh5FeICs1cw/+Ls/4 S5aq9Nh1CqJFGsXylq0IYxRP4h8g0SLOBAZmwxocOcDhu3Ui85ZYl5+lPBSbCdCNN2ZVefygJnA 0MWvgzPWWE2wBdzSXrJWY6qeLr7OvNtKpBgsC3spISovD4mrdI3kPyoJ6ywq+Mclvut//ZMRDwh 1qPZyaU50KH2AXo9qYe4zzuFplh/W9JywOIxgEC+lYUnigp7GL0SwhkqgAKucp3eE6rd6rK7Pwv c+6bKgBK36PfnaSFalV7QLeaEd0JqOfFhhucbahHwlg44+89uTInPDWvVy05fS11HAlcHufmcZT VKsejdFz6Lmf4nEImnlnoEeJqiskavK25+/CnV+cTndWOG4C+g X-Google-Smtp-Source: AGHT+IEuoqtkMram9eSXZSnsoH2FeAXu0avOWCs2rfJZueN8MWiyUfqGQ5QwTgJSP9NCY7vkc2BN0A== X-Received: by 2002:a05:6000:26ce:b0:3cb:3ca5:870b with SMTP id ffacd0b85a97d-3e64c1c2b58mr16769879f8f.44.1757582359976; Thu, 11 Sep 2025 02:19:19 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:19 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 06/31] ada: Fix comments Date: Thu, 11 Sep 2025 11:18:38 +0200 Message-ID: <20250911091904.1505690-6-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Ronan Desplanques This patch fixes a reference to an Ada RM clause, fixes an occurrence of "unconstrained" that should have been "indefinite", and removes an incorrect claim that completing a partial view without discriminants with a full view with defaulted discriminants is an error situation. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Discriminants, Process_Full_View): Fix comments. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.adb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index b91c6785b035..b31587b4bcb1 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -21578,7 +21578,7 @@ package body Sem_Ch3 is Set_Stored_Constraint (Current_Scope, No_Elist); -- Default expressions must be provided either for all or for none - -- of the discriminants of a discriminant part. (RM 3.7.1) + -- of the discriminants of a discriminant part (RM 3.7 (9.1/3)). if Default_Present and then Default_Not_Present then Error_Msg_N @@ -21969,8 +21969,7 @@ package body Sem_Ch3 is else -- For untagged types, verify that a type without discriminants is - -- not completed with an unconstrained type. A separate error message - -- is produced if the full type has defaulted discriminants. + -- not completed with an indefinite type. if Is_Definite_Subtype (Priv_T) and then not Is_Definite_Subtype (Full_T) From patchwork Thu Sep 11 09:18:39 2025 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: 120035 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 B541C3856260 for ; Thu, 11 Sep 2025 09:28:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B541C3856260 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=PgUioHc1 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 192683858C74 for ; Thu, 11 Sep 2025 09:19:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 192683858C74 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 192683858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582362; cv=none; b=RJ1qKUe9IEgfzmTaY4Sg6X/yioKXFdc/eULkmK4xnSS7QFEJ+d9SH8yxf/yf0MQLQUNj8aiBk9M/TduAWlwvqRYrnxlk8M88QFU52r8S0Mzo2jgrjt/6Z/wbW80mCJN38WJQ6WcWXu6pFOdXKfgYH/sBfE/+rfQic7o2kDpf3WE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582362; c=relaxed/simple; bh=UPfeXmpc7iP4kHmw4DNCuPMq7L98KbKEr7hdgUlhpOk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i+cD+UtvSWG+6g48FjeRvwE1JPsdYYSLTefwxBSaL+0UIzrHjD2SuvfqyYVfoZIdDNluPDPDPA428Ov4XpB0k5FBgc0Pel341iwECIZ6OivX4MbyS5I5Zh8mF9wDnHQpe/x6Lur0W8Pa1GAFK6TcIYasLtDDfp/91sxOAAZlQWg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 192683858C74 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3dae49b1293so278262f8f.1 for ; Thu, 11 Sep 2025 02:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582361; x=1758187161; 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=3Mx9ZjJdYkMPIDvUpLVslPQvvU+9sJiQZmRstLgQMaU=; b=PgUioHc16TEQQWhLjrket+lH3icbNv6KlpicnsV/OSJEMkZz7DATdx0oBY7gV02sXe X6bCnhzy2ANAZys5QaSf29HAUwHzf6RAxvEGx+1X8Nf5Tkx7RvJ5qK5maWLMdk592TUp 2IG+h1ljxHET86sMr6ol/DeUwEPJMmcZzwkwmiYHsiVuNNlimhhbVXziH326s8LW05yQ XTRhzIIjqJr6ma4+ZBN3Za8pN4mdbXSpVPLDxz0wIIE+8bRqjE8ycCv0cOEizvXwp5ey mXFVdHv0uxsJbjsKB/6Yn2AEW3047yGN4DQHhGIXFEAozqSGzErYIn8k6ql5lPskkdXK eQAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582361; x=1758187161; 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=3Mx9ZjJdYkMPIDvUpLVslPQvvU+9sJiQZmRstLgQMaU=; b=lD046h4q6o0cvfpPk/oF2Moe7WjtWbXxnvz9st93OT8VOPXiLIlV+tXWZug0ApW5fn 8rDkJvzARELHysQkGVdY/YMqV1XKx+uvX7tVQNA9lraybGysqw5N55nMlrS6BFaohp8Z dxMFCvTkKccCf0aWBkKGh6DzsErNPV+4S8ev2NF31sMxPstjEpB+xfPR4KrqtYz2zNgi tGnBBNe7mZF2vvvjmMZkeHd8KmrZq7KSJc4SmFBW+xqNqLCQJe40842iGcz7grIuA7Bv Iah/ggmkb+kHPsvDc/eW6SmJb7soxo638oWXE5lJJslvsqWdtliOKDYuxbhuk+FDn5Kv +chA== X-Gm-Message-State: AOJu0Ywh9wxQ3naAO7CSoqCUabAxCEEwCWskI1t1ye5yjTHTXkUy4kIr fkH8am7FUEAXCQuSNYzS43Y5h6z3j0nXLSaWg+aBzAFRRHaMZ6Wd3oJgW2Yu1TM1/roGe0pt5SM dpHc= X-Gm-Gg: ASbGncuiA66PvKwc3PlR0wGZu7sJ8UKZQ9M2EiUwLtoibUssSNlB73kDoe0bGSairBR eWMrylOaeix6UynyTnZZ5UpYz0bO36WlYl/EiEGxZCFWGG2x4mcjtE+0jU++iF2X4VHwiqGiMng KrFs958JbUKUD1qlB5H94WNix0WsgVfebKuIYSw33CAxm34qopfWlzkJQO7U2QUduvZgQfqX3af ASJ9j3EggEMvaF7/S8sY0j4lTm7Yj9Qmty2KDP/LeyQiUIYstQ6nUuN8oAacaPjux1uiOD+CbeO G0UiAFi4eiBRojjgwGWlGmwtP1BXzo5tqYE/tpqxeoQnH07EZ+uTM+GM1E8MOagIA8Sh1uQL6R3 At02Wj8NuKtBWQxoZ/lFewZI/LJP2LV8fAVRc8BEYqvQwZlMHUaKfxJyXCTn6eIcLiUMw95O1Dd F+LP9uhIFMepW8uaV6UWJjA53KdkFpwOWmnRqjfMTpR7Ohp3VdFy7kLZHyWUc= X-Google-Smtp-Source: AGHT+IFzO13hoTD372gSvyomL7n8atyZp+Oih5cyi3fDyvIcA8uBJg9DId4PX/4zbkuQboUjxRFyPQ== X-Received: by 2002:a05:6000:2882:b0:3dc:1473:18bd with SMTP id ffacd0b85a97d-3e636d904d8mr13499655f8f.3.1757582360740; Thu, 11 Sep 2025 02:19:20 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:20 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 07/31] ada: Refine condition for reporting warnings on components with abstract equality Date: Thu, 11 Sep 2025 11:18:39 +0200 Message-ID: <20250911091904.1505690-7-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 The initial implementation of the warning resulted in unwanted false positives for types that have a user-defined equality function (in which case abstract equality on components will typically not ever be invoked). The conditions for reporting the warning are refined by this change to exclude checking for presence of abstract component equality functions in the case where the containing type has a user-defined equality. gcc/ada/ChangeLog: * exp_ch4.adb (Expand_N_Op_Eq): Test for absence of user-defined equality on type being compared (for both array and record types) as a condition for checking for abstract equality on component types. Add a "???" comment about current limitations on issuing the new warning. (Warn_On_Abstract_Equality_For_Component): Remove temporary disabling of the warning. Improve comment on declaration. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 60 ++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 2ac5e797e512..23a59de6f872 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -8187,8 +8187,8 @@ package body Exp_Ch4 is procedure Warn_On_Abstract_Equality_For_Component (Comp_Type : Entity_Id); - -- If Comp_Type has a user-defined abstract equality function, then - -- issue a warning that Program_Error will be raised. + -- If Comp_Type is a record type with a user-defined abstract primitive + -- equality, then issue a warning that Program_Error will be raised. ------------------------- -- Build_Equality_Call -- @@ -8423,13 +8423,6 @@ package body Exp_Ch4 is is Eq : Entity_Id; begin - -- Temporarily disable warning, to prevent spurious warnings - -- occurring in vss-xml-implementation-html_writer_data.adb. ??? - - if True then - return; - end if; - if Is_Record_Type (Underlying_Type (Comp_Type)) then Eq := Get_User_Defined_Equality (Comp_Type); @@ -8509,7 +8502,16 @@ package body Exp_Ch4 is -- Array types elsif Is_Array_Type (Typl) then - Warn_On_Abstract_Equality_For_Component (Component_Type (Typl)); + + -- If the outer type doesn't have a user-defined equality operation, + -- check whether its component type has an abstract equality, and + -- warn if so. Such a component equality function will raise + -- Program_Error of objects of the outer type are compared using + -- predefined equality. + + if not Present (Get_User_Defined_Equality (Typl)) then + Warn_On_Abstract_Equality_For_Component (Component_Type (Typl)); + end if; -- If we are doing full validity checking, and it is possible for the -- array elements to be invalid then expand out array comparisons to @@ -8580,17 +8582,35 @@ package body Exp_Ch4 is elsif Is_Record_Type (Typl) then - declare - Comp : Entity_Id := First_Component (Typl); - begin - while Present (Comp) loop - if Chars (Comp) /= Name_uParent then - Warn_On_Abstract_Equality_For_Component (Etype (Comp)); - end if; + -- When outer type doesn't have a user-defined equality operation, + -- check whether any of its components' types have an abstract + -- equality, and warn if so. Such component equality functions will + -- raise Program_Error when objects of the outer type are compared + -- using predefined equality. - Next_Component (Comp); - end loop; - end; + -- ??? Note that this warning is currently only issued in cases of + -- top-level components of the type and not for deeper subcomponents. + -- Those could be handled with more work, such as by adding a flag + -- on record type entities, but it's not clear that it would be + -- worth the effort. Another limitation is that the warning check + -- is not done for tagged types in some cases, because equality + -- comparisons for those can be changed to calls at an earlier point + -- during analysis and resolution, and do not reach this code (but in + -- many cases tagged equality comparisons do reach the code below). + + if not Present (Get_User_Defined_Equality (Typl)) then + declare + Comp : Entity_Id := First_Component (Typl); + begin + while Present (Comp) loop + if Chars (Comp) /= Name_uParent then + Warn_On_Abstract_Equality_For_Component (Etype (Comp)); + end if; + + Next_Component (Comp); + end loop; + end; + end if; -- For tagged types, use the primitive "=" From patchwork Thu Sep 11 09:18:40 2025 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: 120030 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 52BE63858C2C for ; Thu, 11 Sep 2025 09:23:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52BE63858C2C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GJMFOnJI X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id CBC6E3858402 for ; Thu, 11 Sep 2025 09:19:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBC6E3858402 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 CBC6E3858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582363; cv=none; b=CnNZkVLyg1tju122lP7dCT57yy6Vr4XPozaqhyimdRwydK25BYpLYQrk8QA1Wz8t3+6ijsxJrAEOgutuBfOkyWliz/zFBy3jggLyJJaf43uwUo+ttHqzK9xzQdXbua97wexBZxpdlo829K5hAJ8Q+KrSsUzGy9LdxgzUqO8S27I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582363; c=relaxed/simple; bh=2OfAnmTfc07vQR4p6+TS6incuRpegeuxff7XXU35rzw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FY7Ugl8fB1j8aG3PB+cbFftqAyLxdhDGfGNur1AAqMsfYz9Yc2ZQLUC5ItuBlSnW7H4nUsObTfASS4CHF1bhF/K7xFFQllFSUOUCl40AOC0wMNdAbcyG5diAFe79e4905a9vG0/YhaS7EE4K+4xYiq9RyClVUfn+KRXdxwC1+g4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBC6E3858402 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3e4aeaa57b9so533587f8f.1 for ; Thu, 11 Sep 2025 02:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582361; x=1758187161; 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=qihdNTUbS0kos4rVJQ5TNeCqa4MGeu8tVsciKfAiYsY=; b=GJMFOnJIrLiDTTIXusVLydAssnJ9ePRzrNOHR/SJfVu3XVizLjwAI5SjI7WzeFRLQM aA4lePp5K9PJPNmrimAo+4MeljAIEqZ26lpx3muOnH/QGU3ZvmuwVeQtUfaAILttha6j k6aYjaVwejRPxBPWBr+SiDNaJ3yLij1xXKjcoS7i/dNOiLg6lc/r+GR35zZzrgvSq3vn yFn5MkQKvd0t6sDKZLMXb3HZUorZS55KGVdjbP70VdFTQQqhhfnALtHADujwnugAPzlR n8kXQa8jDhFcqLL1oZZO54x2Htx2lYNHRYRl3Wz+w1AnJ7HTfX1XH8j3FZOhX69JQIPj PBVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582361; x=1758187161; 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=qihdNTUbS0kos4rVJQ5TNeCqa4MGeu8tVsciKfAiYsY=; b=cVQDGkSnEfVXLMj/EoS1dnDkS3tpIc7D8/ctA9vlSC18kYACgtBvQEsLHHSiTXmRmb 7gp+bMu2xEI1GDGXzJam+g7xdMoI+BtHXiCZZBz8bezvmPenLVL2xHfnBO6tMriM6hMr Qpm9WvQanggGfKzTEOScTZOW4oXMQnpmqeH4pmppM80NtTrpuU+xDZep7SDVTaotKFIE EgotplMdCZi7Flv4qMKdIC2mw7FDME9lNjwaRjkL52avuweyLE2gQ3O9ckuB0c8NkaO2 3nLxiNdkfSYUHiWWx8lBI5QAsHFPV8KHtSkpJQZZ80E3RMeedOyGi/Teor/1jo4ZxAn9 uwnw== X-Gm-Message-State: AOJu0YxOL1eFFLeevFPZduTCvu9IylCF+/1ks0Iq+OwCDnkpVS1jsySV HbXpg9fRgSC3y7UYtYlkqlNHu6NxajeBu7V1yMdvZn2Q5kZqPbw2AUyJg0VbdhSBfP9c8zzPYmV O6Gs= X-Gm-Gg: ASbGncsn2h4Od8op1KzIWFC2aTiKUQm5oLKF5NzghBzJqyAaLfsMen7YIecfCdcZNEX fxIjH/3kVd4gdGmbgNUzfdu68Z+8jai4ISbEU8aCfPsl3/RUtIyO6hhO1uwOvSa94GO+uh6D4B/ iMHQr3mp6LKxxl+I/us4KQwoIyYW7UwQazcYCJQglIrdhT8C+Yw++6dEfXbZqcwNKONge2/Xoo3 +6QSuRnyqhpuheXf9vYxn8OqFGNIUWMzELiUVv/2He8fD5uo6cjaCnRDG4VcFfPk+PO2vQ9Na55 9UjvxMQbiZWdBmVl/7QyFQqVwn1ZvEY9h0NecbtZCUyfmzr1Ar1D/HzawyDx+OSm55OTbkC7dVv a3tjkhHEig6H5ZnSEAWMcMLy0+1eYvj5FKn6tuRyWcFlCTguNE9WOL4bc98YLYiFWtBPftGWH5Y /LxkbC3nbh90FouHGKGKIPYC/URC8a+WromGok8haJiCoA+i+2 X-Google-Smtp-Source: AGHT+IG2DTu3M875pzskCOTTLYlZIpBvz4tPlhzOk+vlCA5vPltmP+mevMud96Ggin9wZlY82rmt/A== X-Received: by 2002:a05:6000:310d:b0:3e5:a68:bdc5 with SMTP id ffacd0b85a97d-3e63736c735mr16202910f8f.13.1757582361464; Thu, 11 Sep 2025 02:19:21 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:21 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Johannes Kliemann Subject: [COMMITTED 08/31] ada: Disable signals when calling pthread_create on QNX Date: Thu, 11 Sep 2025 11:18:40 +0200 Message-ID: <20250911091904.1505690-8-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Johannes Kliemann The QNX Certified Products Defect Notification from February 2025 mentions a potential memory leak when pthread_create is interrupted by a signal. It recommends to disable signals for this function call. gcc/ada/ChangeLog: * adaint.c: Add functions to disable and enable signals on QNX. * libgnarl/s-taprop__qnx.adb (Create_Task): Disable signals when calling pthread_create. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/adaint.c | 63 ++++++++++++++++++++++++++++++ gcc/ada/libgnarl/s-taprop__qnx.adb | 24 ++++++++++-- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index adc39517280a..7b78d91e0e72 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -107,6 +107,7 @@ #ifdef __QNX__ #include #include +#include #endif #ifdef IN_RTS @@ -3719,6 +3720,68 @@ void __gnat_killprocesstree (int pid, int sig_num) */ } +#if defined (__QNX__) + +static __thread sigset_t set; +static __thread sigset_t oset; +static __thread int signals_disabled = 0; + +int __gnat_disable_signals(void) +{ + sigemptyset(&set); + sigaddset(&set, SIGHUP); + sigaddset(&set, SIGINT); + sigaddset(&set, SIGQUIT); + sigaddset(&set, SIGILL); + sigaddset(&set, SIGTRAP); + sigaddset(&set, SIGIOT); + sigaddset(&set, SIGABRT); + sigaddset(&set, SIGEMT); + sigaddset(&set, SIGDEADLK); + sigaddset(&set, SIGFPE); + sigaddset(&set, SIGKILL); + sigaddset(&set, SIGBUS); + sigaddset(&set, SIGSEGV); + sigaddset(&set, SIGSYS); + sigaddset(&set, SIGPIPE); + sigaddset(&set, SIGALRM); + sigaddset(&set, SIGTERM); + sigaddset(&set, SIGUSR1); + sigaddset(&set, SIGUSR2); + sigaddset(&set, SIGCHLD); + sigaddset(&set, SIGCLD); + sigaddset(&set, SIGPWR); + sigaddset(&set, SIGWINCH); + sigaddset(&set, SIGURG); + sigaddset(&set, SIGPOLL); + sigaddset(&set, SIGIO); + sigaddset(&set, SIGSTOP); + sigaddset(&set, SIGTSTP); + sigaddset(&set, SIGCONT); + sigaddset(&set, SIGTTIN); + sigaddset(&set, SIGTTOU); + sigaddset(&set, SIGVTALRM); + sigaddset(&set, SIGPROF); + sigaddset(&set, SIGXCPU); + sigaddset(&set, SIGXFSZ); + sigaddset(&set, SIGDOOM); + + int ret = sigprocmask(SIG_BLOCK, &set, &oset); + signals_disabled = !ret; + return ret; +} + +int __gnat_enable_signals(void) +{ + if (!signals_disabled) { + return 0; + } + signals_disabled = 0; + return sigprocmask(SIG_SETMASK, &oset, 0); +} + +#endif + #ifdef __cplusplus } #endif diff --git a/gcc/ada/libgnarl/s-taprop__qnx.adb b/gcc/ada/libgnarl/s-taprop__qnx.adb index e7d245fec7de..b51f2b527082 100644 --- a/gcc/ada/libgnarl/s-taprop__qnx.adb +++ b/gcc/ada/libgnarl/s-taprop__qnx.adb @@ -766,6 +766,16 @@ package body System.Task_Primitives.Operations is function Thread_Body_Access is new Ada.Unchecked_Conversion (System.Address, Thread_Body); + function Disable_Signals return Interfaces.C.int with + Import, + Convention => C, + External_Name => "__gnat_disable_signals"; + + function Enable_Signals return Interfaces.C.int with + Import, + Convention => C, + External_Name => "__gnat_enable_signals"; + begin Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size + Alternate_Stack_Size); @@ -840,10 +850,11 @@ package body System.Task_Primitives.Operations is pragma Assert (Result = 0); - -- Since the initial signal mask of a thread is inherited from the - -- creator, and the Environment task has all its signals masked, we - -- do not need to manipulate caller's signal mask at this point. - -- All tasks in RTS will have All_Tasks_Mask initially. + -- (QMS3263) lists PR 2894086. This defect causes a memory leak when + -- pthread_create is interrupted by a signal and later resumed. To avoid + -- avoid such a leak the document suggests to disable signals while + -- calling pthread_create. The signal mask of the calling thread is + -- restored after the call to pthread_create. -- The write to T.Common.LL.Thread is not racy with regard to the -- created thread because the created thread will not access it until @@ -851,6 +862,8 @@ package body System.Task_Primitives.Operations is -- Restricted.Stages is used). One can verify that by inspecting the -- Task_Wrapper procedures. + Result := Disable_Signals; + pragma Assert (Result = 0); Result := pthread_create (T.Common.LL.Thread'Access, Attributes'Access, @@ -860,6 +873,9 @@ package body System.Task_Primitives.Operations is Succeeded := Result = 0; + Result := Enable_Signals; + pragma Assert (Result = 0); + Result := pthread_attr_destroy (Attributes'Access); pragma Assert (Result = 0); end Create_Task; From patchwork Thu Sep 11 09:18:41 2025 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: 120033 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 95C193857833 for ; Thu, 11 Sep 2025 09:28:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id D56203858D33 for ; Thu, 11 Sep 2025 09:19:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D56203858D33 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 D56203858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582364; cv=none; b=RSp1zXeVECJJJFuXfdFTiBJUXWHm3dzAhSttBKQA27wDrnW2wxCh9m1PUTYGUziY1JrPS3uzVRMFWDa9tRf9u3TH5iAYGsXrnoMEkjv39G2UVTBcNyIp9lS7ZKJep2vlMVBvvPgQDa49kKW/S6EOHMOjcT9eSTZsbMvN+G73qdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582364; c=relaxed/simple; bh=eWLaBRMeggKFO6GdY6Ci1IP/j7z8ciuNtPsiocfVEq4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=S63dZfCNwTIBCzYlt7yureJ4YSnwuGdXASZdF3OtwAWaDtrZt0H5JKXBI3YlZ+OqE4mblneJAcjxSCIXBa5AvkClfgIl7n29cPxqPQcwgc9gG0p1+pyt5QYHja8t6YIwIEt+GsNM5MaeV4WeghEhxco5B9M5acj/T+cbC5RSKLc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D56203858D33 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=gg+CMUEI Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3e5190bca95so379048f8f.0 for ; Thu, 11 Sep 2025 02:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582362; x=1758187162; 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=zIZtghP2tbKeAsQi4diD/przVQfiWxfWfGqXT2dDl7Q=; b=gg+CMUEIebkpI0wEqdZ3rSPkpYsb4N70mFu72tT+GDk9fDo8/g7A0jXTSzHhfJO9DW qj7wARURv+Y7rmQAH8F+bO/6DXfi5fB+b6u1j+iColsdc2RB3PL6ejYcbDwKd1wBL65y FdPC0sdxZW96TfmLU10av6KPaKHdXpXKoFHiTI77lJ2p9q207jKn0Ev/ADUB+uNUYtSi WyoCAKBVDrWuil2DgJdqHjNFi5pF1V2M1/GsTJAtKn4bNemb0Rc4pU1URkXHogxuzR3w 5JfUxlNOYAcASM7+TLJFA2dmCHUOqWI+fbOZxnVS9Uw1Fqt4yaKSASnLCubgpQzXRwmZ kRUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582362; x=1758187162; 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=zIZtghP2tbKeAsQi4diD/przVQfiWxfWfGqXT2dDl7Q=; b=VfYMy1349+tkItkmAw1GAwfoxpABJcRWfvAmLEn4siUBaIFTCPD03sW7J76VtdP24w wO/aJDQFuG10ifkkgDfigU3YCyCS1EiEjhysDvk7HXlXcOv2PZTQdMQi1u2D/xv3URLO VhrYAGndxbHBThQoXKqJY6TYFLe+jdSYBUFSmWqY+FGKyPyr/rSqYRlXYQb168ZujW1+ ByCVTbQmKKMd7mZN9Xs0lK6zhaBK90B7e65DiiXoJg7TYYWItb1VbXyatGDr1kqjESjg Q+ES87eAfCi9VBDlFNNnNIdJfghsPOclDt4Ydn1ugU0YOTCEbUVwKEfw4vHAjlcJzsot zdjg== X-Gm-Message-State: AOJu0Yxg7sU0d8/tcl3fXYlKt3p1p798ppL8e5fHQ6lDmWlS+Or0LUSW /+BmWsTAuMpYxpOEan/KsgVq0NVImtLpryD2h5NfuqqOhUNaG56KX5lQNBM6+BOv25dimvvUXkG b2Rk= X-Gm-Gg: ASbGncu8B+WbCwXZmSwu49bvM4DpwsTygySbCHTir0iaEspih1QcYU8Cs0qGCV3vs6O OWHRq9ivJG2L+5uZc/MLqzbaSNJ4qxwt4+/wQqc0GwPMs/gRc5JSLIWbmrdh8gYJCdLbcxBbYYb HqJux3Od0JBu6HHXcJ49UFORvTDA7Xkguv43YF+AYEZ17us4qMmYU02tB43c/6eEjOImLTuurGk Uq/iqmRZAQq5J8gkGezbpmtcL604pB1+N+41tzavXZlLANNx7S7PmM1zd1er0uzOC/EkwPorIyS KK1YQBeY3vU8NzCMsSkm80k0ptNpsVKz/hw/KY6/6E7a47hHBk8J3XigTsCYJ+5ZL678BFiQYFO 0vqoF6BUkVazA9K9kl1PlTJq7stBhk95oVJg22E6yBoaPSSOCcfDdBZkQCEeD5DqJePWh/wGr5Z bb6u8n+ygdqQ1zwR83tIvozGksvcnRaZ5YgUpVWA== X-Google-Smtp-Source: AGHT+IHd1NKH8CQxagsfS27p0Mqxi/n15cPDuW5P6t7cFxkEMjT9O+K4rgtbqt7/w7TU8lsCDeOf3A== X-Received: by 2002:a5d:5f48:0:b0:3de:78c8:1223 with SMTP id ffacd0b85a97d-3e6440ef6cemr15849956f8f.31.1757582362368; Thu, 11 Sep 2025 02:19:22 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:21 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 09/31] ada: Make pp and friends more robust (base type only) Date: Thu, 11 Sep 2025 11:18:41 +0200 Message-ID: <20250911091904.1505690-9-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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 Prior to this fix, if pp(N) tried to print a "base type only" field, and Base_Type(N) was not yet set, it would raise an exception, which was confusing. This patch makes it simply ignore such fields. Similarly for Impl_Base_Type_Only and Root_Type_Only fields. We do this by having alternative versions of Base_Type, Implementation_Base_Type, and Root_Type that return Empty in error cases, and call these alteratives from Treepr. We don't want to Base_Type and friends to return Empty; we want them to blow up when called from anywhere but Treepr. gcc/ada/ChangeLog: * atree.ads (Node_To_Fetch_From_If_Set): Alternative to Node_To_Fetch_From that returns Empty in error cases. For use only in Treepr. * treepr.adb (Print_Entity_Field): Avoid printing field if Node_To_Fetch_From_If_Set returns Empty. * einfo-utils.ads (Base_Type_If_Set): Alternative to Base_Type that returns Empty in error cases. (Implementation_Base_Type_If_Set): Likewise. (Root_Type_If_Set): Likewise. (Underlying_Type): Use more accurate result subtype. * einfo-utils.adb (Base_Type): Add Asserts. (Implementation_Base_Type): Add Assert; minor cleanup. (Root_Type): Add Assert; minor cleanup. Remove Assert that is redundant with predicate. (Base_Type_If_Set): Body of new function. (Implementation_Base_Type_If_Set): Body of new function. (Root_Type_If_Set): Body of new function. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/atree.ads | 14 ++++ gcc/ada/einfo-utils.adb | 167 +++++++++++++++++++++++++++------------- gcc/ada/einfo-utils.ads | 11 ++- gcc/ada/treepr.adb | 6 +- 4 files changed, 141 insertions(+), 57 deletions(-) diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads index 802db8709338..f14491c2d75b 100644 --- a/gcc/ada/atree.ads +++ b/gcc/ada/atree.ads @@ -651,6 +651,20 @@ package Atree is -- similarly for the other two cases. This can return something other -- than N only if N is an Entity. + function Node_To_Fetch_From_If_Set + (N : Node_Or_Entity_Id; Field : Node_Or_Entity_Field) + return Node_Or_Entity_Id is + (case Field_Descriptors (Field).Type_Only is + when No_Type_Only => N, + when Base_Type_Only => Base_Type_If_Set (N), + when Impl_Base_Type_Only => Implementation_Base_Type_If_Set (N), + when Root_Type_Only => Root_Type_If_Set (N)); + -- This is a more permissive version of Node_To_Fetch_From, which + -- returns the same value, except it returns Empty in cases where + -- Node_To_Fetch_From would crash because relevant fields are not yet + -- set. This is used in Treepr, to allow it to print half-baked nodes + -- without crashing. + ----------------------------- -- Private Part Subpackage -- ----------------------------- diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 417da6e828bc..d84e562853cc 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -669,6 +669,8 @@ package body Einfo.Utils is Result := Id; else pragma Assert (Is_Type (Id)); + -- ...because Is_Base_Type returns True for nontypes + Result := Etype (Id); if False then pragma Assert (Is_Base_Type (Result)); @@ -679,9 +681,29 @@ package body Einfo.Utils is -- expect. end if; end if; + + -- pragma Assert (Result = Base_Type_If_Set (Id)); + -- Disabled; too slow end return; end Base_Type; + ---------------------- + -- Base_Type_If_Set -- + ---------------------- + + function Base_Type_If_Set (Id : E) return Opt_N_Entity_Id is + begin + return Result : Opt_N_Entity_Id do + if Is_Base_Type (Id) then + Result := Id; + elsif Field_Is_Initial_Zero (Id, F_Etype) then + Result := Empty; + else + Result := Etype (Id); + end if; + end return; + end Base_Type_If_Set; + ---------------------- -- Declaration_Node -- ---------------------- @@ -1374,30 +1396,43 @@ package body Einfo.Utils is ------------------------------ function Implementation_Base_Type (Id : E) return E is - Bastyp : Entity_Id; Imptyp : Entity_Id; - begin - Bastyp := Base_Type (Id); + return Result : E := Base_Type (Id) do + if Is_Incomplete_Or_Private_Type (Result) then + Imptyp := Underlying_Type (Result); - if Is_Incomplete_Or_Private_Type (Bastyp) then - Imptyp := Underlying_Type (Bastyp); + -- If we have an implementation type, return its Base_Type. - -- If we have an implementation type, then just return it, - -- otherwise we return the Base_Type anyway. This can only - -- happen in error situations and should avoid some error bombs. - - if Present (Imptyp) then - return Base_Type (Imptyp); - else - return Bastyp; + if Present (Imptyp) then + Result := Base_Type (Imptyp); + end if; end if; - else - return Bastyp; - end if; + -- pragma Assert (Result = Implementation_Base_Type_If_Set (Id)); + -- Disabled; too slow + end return; end Implementation_Base_Type; + ------------------------------------- + -- Implementation_Base_Type_If_Set -- + ------------------------------------- + + function Implementation_Base_Type_If_Set (Id : E) return Opt_N_Entity_Id is + Imptyp : Entity_Id; + begin + return Result : Opt_N_Entity_Id := Base_Type_If_Set (Id) do + if Present (Result) and then Is_Incomplete_Or_Private_Type (Result) + then + Imptyp := Underlying_Type (Result); + + if Present (Imptyp) then + Result := Base_Type_If_Set (Imptyp); + end if; + end if; + end return; + end Implementation_Base_Type_If_Set; + ------------------------- -- Invariant_Procedure -- ------------------------- @@ -2540,52 +2575,76 @@ package body Einfo.Utils is --------------- function Root_Type (Id : E) return E is - T, Etyp : Entity_Id; + Etyp : Entity_Id; begin - pragma Assert (Nkind (Id) in N_Entity); + return T : E := Base_Type (Id) do + if Ekind (T) = E_Class_Wide_Type then + T := Etype (T); + else + loop + Etyp := Etype (T); - T := Base_Type (Id); + exit when T = Etyp + or else + (Is_Private_Type (T) and then Etyp = Full_View (T)) + or else + (Is_Private_Type (Etyp) and then Full_View (Etyp) = T); - if Ekind (T) = E_Class_Wide_Type then - return Etype (T); + T := Etyp; - -- Other cases + -- Quit if there is a circularity in the inheritance chain. + -- This happens in some error situations and we do not want + -- to get stuck in this loop. - else - loop - Etyp := Etype (T); + if T = Base_Type (Id) then + Check_Error_Detected; + exit; + end if; + end loop; + end if; - if T = Etyp then - return T; - - -- Following test catches some error cases resulting from - -- previous errors. - - elsif No (Etyp) then - Check_Error_Detected; - return T; - - elsif Is_Private_Type (T) and then Etyp = Full_View (T) then - return T; - - elsif Is_Private_Type (Etyp) and then Full_View (Etyp) = T then - return T; - end if; - - T := Etyp; - - -- Return if there is a circularity in the inheritance chain. This - -- happens in some error situations and we do not want to get - -- stuck in this loop. - - if T = Base_Type (Id) then - return T; - end if; - end loop; - end if; + -- pragma Assert (T = Root_Type_If_Set (Id)); + -- Disabled; too slow + end return; end Root_Type; + function Root_Type_If_Set (Id : E) return Opt_N_Entity_Id is + Etyp : Entity_Id; + + begin + return T : Opt_N_Entity_Id := Base_Type_If_Set (Id) do + if Ekind (T) = E_Class_Wide_Type then + T := Etype (T); + else + loop + Etyp := Etype (T); + + if No (Etyp) then + T := Empty; + exit; + end if; + + exit when T = Etyp + or else + (Is_Private_Type (T) and then Etyp = Full_View (T)) + or else + (Is_Private_Type (Etyp) and then Full_View (Etyp) = T); + + T := Etyp; + + -- Quit if there is a circularity in the inheritance chain. + -- This happens in some error situations and we do not want + -- to get stuck in this loop. + + if T = Base_Type_If_Set (Id) then + exit; + end if; + end loop; + end if; + end return; + end Root_Type_If_Set; + --------------------- -- Safe_Emax_Value -- --------------------- @@ -3010,7 +3069,7 @@ package body Einfo.Utils is -- Underlying_Type -- --------------------- - function Underlying_Type (Id : E) return Entity_Id is + function Underlying_Type (Id : E) return Opt_N_Entity_Id is begin -- For record_with_private the underlying type is always the direct full -- view. Never try to take the full view of the parent it does not make diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads index 78b49891f609..27cf9e670f0e 100644 --- a/gcc/ada/einfo-utils.ads +++ b/gcc/ada/einfo-utils.ads @@ -161,6 +161,15 @@ package Einfo.Utils is function First_Formal (Id : E) return Entity_Id; function First_Formal_With_Extras (Id : E) return Entity_Id; + function Base_Type_If_Set (Id : E) return Opt_N_Entity_Id; + function Implementation_Base_Type_If_Set (Id : E) return Opt_N_Entity_Id; + function Root_Type_If_Set (Id : E) return Opt_N_Entity_Id; + -- Base_Type_If_Set is a more permissive version of Base_Type, which + -- returns the same value, except it returns Empty in cases where Base_Type + -- would crash because relevant fields are not yet set. Likewise for the + -- other two. These are used in Treepr, to allow it to print half-baked + -- nodes without crashing. + function Float_Rep (N : Entity_Id) return F with Inline, Pre => N in E_Void_Id @@ -238,7 +247,7 @@ package Einfo.Utils is function Stream_Size_Clause (Id : E) return N with Inline; function Type_High_Bound (Id : E) return N with Inline; function Type_Low_Bound (Id : E) return N with Inline; - function Underlying_Type (Id : E) return Entity_Id; + function Underlying_Type (Id : E) return Opt_N_Entity_Id; function Scope_Depth (Id : Scope_Kind_Id) return U with Inline; function Scope_Depth_Set (Id : Scope_Kind_Id) return B with Inline; diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index 857b9263f012..fbad71a3765a 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -1047,9 +1047,11 @@ package body Treepr is FD : Field_Descriptor; Format : UI_Format := Auto) is - NN : constant Node_Id := Node_To_Fetch_From (N, Field); + NN : constant Node_Id := Node_To_Fetch_From_If_Set (N, Field); + -- If NN is Empty, it means that we cannot compute the + -- Node_To_Fetch_From, so we simply skip this field. begin - if not Field_Is_Initial_Zero (N, Field) then + if Present (NN) and then not Field_Is_Initial_Zero (N, Field) then Print_Field (Prefix, Image (Field), NN, FD, Format); end if; end Print_Entity_Field; From patchwork Thu Sep 11 09:18:42 2025 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: 120032 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 73EEC3858418 for ; Thu, 11 Sep 2025 09:27:33 +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 8F86C3858D35 for ; Thu, 11 Sep 2025 09:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F86C3858D35 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 8F86C3858D35 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=1757582364; cv=none; b=QGvKaBjk2+/RyRdBWPdlX/mXV77RA9tO28ZurjONF0lQuLsokl8RbaYOKWgKJyT9LYVYTAoyDBjSu2k52CC+vV7YkGk0EHO6pAPlpvFTHvSllmvWRZE7DZzEBt59tDgkDjjl4B0xkcRDTJyRBGoM+ZQtmAqHf1yNdA9z3NhJbCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582364; c=relaxed/simple; bh=oYAe3gcAh7Ky3LQ3+uEdHPUkf6nh6kBR4kyNSg5hV7c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AZvusJqFmJCoZwQKYni6qL3K7kjENZv+ZxuIb6bEzmE4Zn9lS3XqlKGav2oemFP0QOweFoC1VFpCfj6Ou5MctCEyODPk4FnbdEosnN9R+VdFaXX27ydTssRTN3VkIQrL29vXZscFRfKUsCM2B7Hf7mJW6hcY2if6CPKWnge9ie4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F86C3858D35 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Xy3+Xepe Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45de60d39b7so3612865e9.0 for ; Thu, 11 Sep 2025 02:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582363; x=1758187163; 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=DDYyuqWNMxvm+CO5noWtiH532oVf0oOjHftW4MB732g=; b=Xy3+XepeWQEeuM9u6HOLinnF3MstXodRGHkT4/S8jZeravFNKqdDW+Hgj4jyCjsCjU 7yLEW40UV770M3PewfKC4Z/ArWCOW7so5PwCyEOiPaeR8mfxaEvVnuICQCQ4SQ/5h/Xa Lq3gWRkCRGkgpL6EaCJNmLlLRyy6uUJz6Nmn/LDCeqoC4D98XYJvWKepjrjoQMCxYJkI /dwVMdKlzeCqqXhkLIuewz/FPDKRBG6GPlJjBok4JjtGbj/9YcvOHmisW7962583EjBE DDVk3l10vQLLXh+x35ZvYqxLruH6vaqokaTS9aGUdKUqzHYAYs6Reekem7JJ6SQ0QFS6 YzCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582363; x=1758187163; 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=DDYyuqWNMxvm+CO5noWtiH532oVf0oOjHftW4MB732g=; b=JttAFdeFxfzsgsHY+uhV/r6To0T/9Qf0EuLiCLfwcuhPbkvHlECXyApsA19QmWsDK3 bgPlJ6Je0zJAU0dijumBsMCXMKb6xkdb4tIwSMvGOaK/GKNz0Ag5Z0FtnjBFXLyURQ49 nbkK7lEYZDZ7gEJCiFW/1r5tVebgfC+zyfPhV6tSa7HvY5SlJQxMBCi5dVNZmCpmF/Ri 56dtkjXLqZ1aMe2kvKuwuW7yIwPH0wK1uGJp+jTf5WglCetdWz1T6Nm8fvcdHWpu5iU8 MVOtc5NRvkdTnLTNZA+oGO2LCNGdMM6PFXJYrAMuiBTJmBrq2hIftyQLOJXOKhn2uwGN bDWw== X-Gm-Message-State: AOJu0YxjmX+5yCOL4+YSuRh2UHZ2aoI/KjLi7VpL5ciTCYe6YWdUmpJl aF3MlZNo43AsevckeaNdX6dWl/DMyxkJTS6Jyxa07aS19hdOSzQoZvLZIHM7xZy0WxPFafrTVjH N/wA= X-Gm-Gg: ASbGncsJZuOoLqu+DiGSUNSU/h3Lw90RFAFZoJcdWrnmE9zIgCzzAJWNuCkgVwq7ScW 2mi6GifJQdUMif2op5UmD9HMMmDtT2/ZNnEId9M8U64RAscnvq2XeNr5nTS9tavH0GAGuVn5EJB hfS7K5PXole6oZv/0zUVyN/bJ2J3ROl0qU7efdQaxKpcsZJPGRWT83UIkTUF5Cl/lxE0S2SZcw4 hn4RTuVM+36UrkB1IDeS2W5nWkFZ1jzKIbhLVmI9DjUWafUstoz8gRreTfF6Jav8eNDdoMSMJkU iSufR0bQeI4qt5ZlyeoIyGIyC7otEkAQaoDxCeUelhzUMZbNg5OyGptnyLLzaN3pLGOY/eszBsb y+5+R5E84D11k3MTqsZ9RFPtBStUB8ySU6P39hZiVA6//yaUqJEmHbe3kXx6VBhYRfZQpZhbtcy uVjrBkst/gpcCHf5kq8CxSQ4QMcZx7Odl19k/BcohEXpuEcuJN3E/ver4SZ+Y= X-Google-Smtp-Source: AGHT+IEyYNhjKW1fl6LjsfC405+ZVWzA/5JFUZZ0od8jFOeu6cQLEdpMqn3OXfHpEbqcAY113fgXNQ== X-Received: by 2002:a05:600c:1907:b0:45d:f7e4:8969 with SMTP id 5b1f17b1804b1-45df7e489eamr57068495e9.4.1757582363268; Thu, 11 Sep 2025 02:19:23 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:22 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 10/31] ada: Crash on null aggregate of multidimensional type Date: Thu, 11 Sep 2025 11:18:42 +0200 Message-ID: <20250911091904.1505690-10-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 A compiler built with assertions enabled crashes processing a null aggregate of multidimensional type. gcc/ada/ChangeLog: * sem_aggr.adb (Report_Null_Array_Constraint_Error): Adjust code for reporting the error on enumeration types. (Resolve_Null_Array_Aggregate): On multidimiensional arrays, avoid reporting the same error several times. Flag the node as raising constraint error when the bounds are known and some of them is known to raise constraint error. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index bbd0eaefb98e..baca06800abe 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -1139,7 +1139,8 @@ package body Sem_Aggr is if Is_Modular_Integer_Type (Index_Typ) then Error_Msg_N ("null array aggregate indexed by a modular type<<", N); - else + + elsif Is_Enumeration_Type (Index_Typ) then Error_Msg_N ("null array aggregate indexed by an enumeration type<<", N); end if; @@ -5463,8 +5464,13 @@ package body Sem_Aggr is Hi := New_Copy_Tree (Lo); - Report_Null_Array_Constraint_Error (N, Index_Typ); - Set_Raises_Constraint_Error (N); + -- On multidimiensional arrays, avoid reporting the same error + -- several times. + + if not Raises_Constraint_Error (N) then + Report_Null_Array_Constraint_Error (N, Index_Typ); + Set_Raises_Constraint_Error (N); + end if; else -- The upper bound is the predecessor of the lower bound @@ -5478,6 +5484,15 @@ package body Sem_Aggr is Append (Make_Range (Loc, New_Copy_Tree (Lo), Hi), Constr); Analyze_And_Resolve (Last (Constr), Etype (Index)); + if Known_Bounds + and then + (Nkind (High_Bound (Last (Constr))) = N_Raise_Constraint_Error + or else + Nkind (Low_Bound (Last (Constr))) = N_Raise_Constraint_Error) + then + Set_Raises_Constraint_Error (N); + end if; + Next_Index (Index); end loop; From patchwork Thu Sep 11 09:18:43 2025 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: 120037 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 B1B503858C2C for ; Thu, 11 Sep 2025 09:29:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 868CF3858C78 for ; Thu, 11 Sep 2025 09:19:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 868CF3858C78 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 868CF3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582365; cv=none; b=fO3bUX6hgHwHRaqrc/8VbeDNrw5KTDJzd2AO+Kx2q7lmNSeYHNumu298NutEE+A0Dw8Aj+kXl9e3OrEQXh/K1MeodyJ4cUmL2raisVkxMQHbFe8Si4TZZJPi636E3g3mVPmeX88dqjvV61x8TzOocqkrZSEflZPPQ3zadVGinoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582365; c=relaxed/simple; bh=ehmJerw/pR0/S90ooch7KjxpWvik/aPU8jtns7ipbTE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XV2TXRsbc8Atg+RTChnUW4bCkiEK5AbJyCdKH+nWLeGYYuKgRwaFBuxqm8Dtrz34uoVR3jKILzr52oQatEXT5mt0Ikmkx+l1ohFyMWStc0xEbb8qP815JFvcx9LGTlSjCG/D3M/YhHGkxonp/y9sCuTNYL2pnyqMgEFsQKO/FCQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 868CF3858C78 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=jckHPaVB Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3e75fb6b2e2so545915f8f.3 for ; Thu, 11 Sep 2025 02:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582364; x=1758187164; 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=UbFrMCuJxttHX8fTcEqnHF3fl01hc5kcypQDs//7+5A=; b=jckHPaVBsudQaQn4EX5ZNSGa8rBs3d6VnkKrV1hBRkNz00Wrh/oB2Nj29YyxceC7s0 cdIWNaxQMg64OAIF0E1DLH9FgltyKpfISSsal8O2HzcvGOhYtC5804O4y2CUJu+PDzUS ouZKclJUVOkxesLz+y0LKDP967TY6v52442HctFg241jOtrSpMNIVaNsL+lwkgv1Ex4h 1WUtpNdoEOn4tjBR3zxTtvo3rZvFD1SvsCQKvICNIEhRrhrD9VagTF1uE8nCZNml5GPU R6J2OQ2FafhJFvhOpbayIRJjPkBvmKlDm6fXi+Z3MH+noifg2jUluvQE6t1MbWNdS1+d eMkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582364; x=1758187164; 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=UbFrMCuJxttHX8fTcEqnHF3fl01hc5kcypQDs//7+5A=; b=LdYqx2aGP8Qsi2pFmX2gFFskUgl4yjIs25fyQg1+61lvzo34LjnSfRUXB9oMZEDLOQ 3JXA/mq6nntoFyILLFc94w92/w33xBBjWdBoDfbYxeJD/3LOmbgo47+CWb6xwanaBfZH wOzgwhob6N8KSBnF2bT8TQRPDt9LcIpF08RJg+UuLEqSquUxdxEugwbzFEr3KPmqTOea Z2dUSjfMhoaxwr/47PFQsCP9kh/DqCQWFTS8M2YffV4n3JQ/0BZB9w0Q5dLl7mwFwEep 8GMKcSpNP6wwfGxZwjOZsEkVaCXofQrkyTpY645aloiiV314ScPOry20jVPpJb/cmFLE 0g/A== X-Gm-Message-State: AOJu0YwONdlojpaUSSORQjcQfYm0tN/ovURMwpl6/4UUpiwuyK+TZzzn qFpC19Ozgk5wfE0aa6gu9oAWw6/8OXf9FFttb/2DQKebEzoVfqJg5BL1H248ZLGn9ukyJ2AmYjB i6wA= X-Gm-Gg: ASbGncu9+R5WTI4dJ6OXVuQh/6HPODw8JewLNacfTVHQJPQ2/FDmauyOVfcaLlZL6sh KvfFH9kJ6gCxAtZTh6BcJrVfXBOGvwnDSMbO0d/+xHrKevw0n0gn8BVDmYVERnrdzoQF6mVkbbf zGnuoI+PR9y+Y+aCm5Hn4OOG/DLiOI99n+U0GeTjcVkuhmzjAm8NyRJdQZW754GSuj4l8zmxPOa 3L1KLxRKH3pcnc4BYyBAxh5LlK6UHL5LnFLHOh9VNj1JyeRHUE5nPWG4Yj2Yf1MJo76cd+xdbDq 4QE/WXhYizR47mkslSIeYj7GmFVovwRAjrwNEhJfkzEAUpsMu7YBtwz6+1eusgZKh53FqRjI208 H4H95s9xC5V44EhnSy8CTwd3VVL0cBaYowhPnXmUKL3rlg0qfObG/xTot9z4tPQzbshcDlbnWfF 3AWxLrLU24arR7w98d7iJzof3TKUk6uxw6s3xX+N322d5La62B X-Google-Smtp-Source: AGHT+IGdiERz+z6481wPFAjswuq/pF+A+WNHcApKPTXYg2X8YCpgZH7Kv23y47VRlTbXfT8txsibuw== X-Received: by 2002:a05:6000:2c05:b0:3de:293c:9377 with SMTP id ffacd0b85a97d-3e64ca76b1fmr15995284f8f.63.1757582364127; Thu, 11 Sep 2025 02:19:24 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:23 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 11/31] ada: Allow implicit packing of arrays when larger than needed Date: Thu, 11 Sep 2025 11:18:43 +0200 Message-ID: <20250911091904.1505690-11-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 For Implicit_Packing, do not require the Size clause to exactly match the packed size. For example, an array of 7 Booleans will fit in 7 bits if packed, or 7*8=56 bits if not packed. This patch allows "for T'Size use 8;" to force packing in Implicit_Packing mode; previously, the compiler ignored Implicit_Packing unless it was exactly "use 7". Apparently, customers have that sort of code, and the whole point of Implicit_Packing is to allow such legacy code to work. We already do the right thing for records, at least in cases tested. We deliberately avoid changing the error messages given here. They could possibly use some work, but there are subtle interactions with the messages given in Sem_Ch13 for the same thing. gcc/ada/ChangeLog: * freeze.adb (Freeze_Entity): Change "=" to ">=" in size comparison for Implicit_Packing mode. Keep it as "=" for giving error messages. * opt.ads (Implicit_Packing): Minor: correct obsolete comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 43 +++++++++++++++++++++---------------------- gcc/ada/opt.ads | 6 +++--- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 8fa25b3d8510..1bbc24f62fe2 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7151,31 +7151,30 @@ package body Freeze is Next_Index (Indx); end loop; - -- What we are looking for here is the situation where - -- the RM_Size given would be exactly right if there was - -- a pragma Pack, resulting in the component size being - -- the RM_Size of the component type. + -- In Implicit_Packing mode, if the specified RM_Size + -- would be big enough if there were a pragma Pack, + -- then set the component size as if there were Pack, + -- and Freeze_Array_Type will do the rest. - if RM_Size (E) = Num_Elmts * Rsiz then + if Implicit_Packing + and then RM_Size (E) >= Num_Elmts * Rsiz + then + Set_Component_Size (Btyp, Rsiz); - -- For implicit packing mode, just set the component - -- size and Freeze_Array_Type will do the rest. + -- Otherwise, if pragma Pack would result in exactly the + -- right size, give an error message suggesting packing, + -- except that if the specified Size is zero, there is no + -- need for pragma Pack. Note that size zero is not + -- considered Addressable. - if Implicit_Packing then - Set_Component_Size (Btyp, Rsiz); - - -- Otherwise give an error message, except that if the - -- specified Size is zero, there is no need for pragma - -- Pack. Note that size zero is not considered - -- Addressable. - - elsif RM_Size (E) /= Uint_0 then - Error_Msg_NE - ("size given for& too small", SZ, E); - Error_Msg_N -- CODEFIX - ("\use explicit pragma Pack or use pragma " - & "Implicit_Packing", SZ); - end if; + elsif RM_Size (E) = Num_Elmts * Rsiz + and then RM_Size (E) /= Uint_0 + then + Error_Msg_NE + ("size given for& too small", SZ, E); + Error_Msg_N -- CODEFIX + ("\use explicit pragma Pack or use pragma " + & "Implicit_Packing", SZ); end if; end if; end; diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 524a823bb8f6..109d28245de9 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -835,9 +835,9 @@ package Opt is Implicit_Packing : Boolean := False; -- GNAT - -- If set True, then a Size attribute clause on an array is allowed to - -- cause implicit packing instead of generating an error message. Set by - -- use of pragma Implicit_Packing. + -- If set True, then a Size attribute clause on an array or record is + -- allowed to cause implicit packing instead of generating an error + -- message. Set by use of pragma Implicit_Packing. Init_Or_Norm_Scalars : Boolean := False; -- GNAT, GNATBIND From patchwork Thu Sep 11 09:18:44 2025 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: 120036 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 D2ECD3858401 for ; Thu, 11 Sep 2025 09:28:53 +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 4FAE73858405 for ; Thu, 11 Sep 2025 09:19:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FAE73858405 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 4FAE73858405 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=1757582366; cv=none; b=Bio5yUE3XBxqLgoRNWNpf8LhRc3Oj5uhStQUHGYmaCqTLJoPOXrFKkN93s15At9r6AVxyoREadCpkuakWbR8T+HUVphRCyScsRF8OvYadZmkw0F5c/04ny6ahurBBcCNZDyw3JCLEYFusJQkqPpbu++FzvjY8jwIQip02XMJvsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582366; c=relaxed/simple; bh=YcHkGQ0dNXSmG/elxmTxGBtrttsAqFG3uK0gBpYjlPQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pxklv5Yqx4ro40v9mMsEdo2XqI02l0fZHxh0uPl4YK7w/YQ9Nh37OsP3ywUlSEKry3ebgvyMO5VLzoDHUXV5NU4tt6ruvaDjKwUf39HLK2wSi8xUaaKEM73ZtFMv9Im344xtScalD2cPmW3zl+kwMMVwhG+hWorL1y06P3/KPJ4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FAE73858405 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=JTtrHjSX Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3df35a67434so336608f8f.3 for ; Thu, 11 Sep 2025 02:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582365; x=1758187165; 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=gTSlDsSyesIbBdJpJesW8jZRgsr/C+L0C0xsI6NqNbE=; b=JTtrHjSXXSRcKBWqv/91ejDdWyem8DinyXW9fd5Dki1nqIqkjloDJzZt3YB3RPM85P f11rN5YyfSlJCTOKSUpuU7SDGBG6FncuFEvDfUgULK1D8oGn3wpRoI/JyMqUGZeb6Zsi LcVgk268bNYQMugF/vdqSqMYamJB6yYEGXajDMFMRMlEiBnyGki058BFINGrb5T9VGWA 0yTYYjuUXvGJfagI69jXR40CHF70TZJuJHsWgnIAYDKD6hFuu2RgfJrQtOtco24hnUIx yQqcaU7UX6AX7kI/l5iAeskWgLJKGBaYrIczMV1yx5TwzJ9w1BJMd0sNcp+qK1R0z0Qu Ma4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582365; x=1758187165; 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=gTSlDsSyesIbBdJpJesW8jZRgsr/C+L0C0xsI6NqNbE=; b=r2sM2vV/woAZ9FJ+sg9b32MAj2Fr2TBXe1sMhuKmdtLaj0+rtxW3tu+jgZryDENXnR hKaPyvkDFZVxH7oFsFoIGAtyAByLGZlfgA67/0SrT3XlVeDYa4DH9ugLaI/kDHgDcgyE QMed5ni6HFjhjBr2QICjGqoJ3qYlUMTE5PiTNZMUbqtM6IhLUoAq3tl2ejp4+zkfgs1m E0I8TvVCxvF9bced2qUQv2Bk7HlatDWKhflDpges4F4Gl4ehlbl2Zn2b3pYMtlvfv6Bq izjSTuk2bOsd8Y+tfhwu+3KOcicmyuMPr2dKc/Sk+X+V4Cv7/XKODCHyF6cOn9aP7n7E dEuA== X-Gm-Message-State: AOJu0YysW5C6TIIPSJLP07nbp+Z3f68oPDLVScVw6qNdj58zavXXlNYr p6VGMfN0xhh6H8uI76l08UC6/9WQktlYFqi8BvUlxayjqur+dmmclwT36c+ayKkBxHerfSpR0Dq lUpg= X-Gm-Gg: ASbGnctsIezTLCVqV7MMfdbDNCQnz12MbnUyYM0JaMw7Zo11cGOvNgJZsHjC7H6iq39 FhvNzc10/FNbNlc2hPdVB/D1wSXxR6mKbxLKBz3j1yY2eGXINZTYOYyUnu7ggLx4sxtxrEcZYHn mmam7Hl6C5WwBz9gCIcqUg1CxJT/ha6ageVv4ApM9rGTcRD0FubmNVhGYADo98/r3LaIjKp5GBp 47ehrPNbmOujV4UoOF/zdaL81xiyzzNtY4/Geb3w++l16xpzg5E+s3J+VlCsFYkY42XJ4gBJ8O9 Y3B7hxOAoBlQ5tktdersPk4PFuHColfS6GCdo35ZzpVhdWJKnFUCniEw06wBZwEDLdG//v8DPm9 G3pMzn2oW8Bkxl4p0rnhhOxTR+5CfSAAjLmfJIcO5DZsIur39H08ow0vnd2tSmop2Z4IhHzr+Fv sFee2r6SFWCK8oD29KZpZeJuBn42VQrWsMeI/5ybfYgpLbJsdu X-Google-Smtp-Source: AGHT+IEGywPTLIFwCNB6GexiT8o5uunGvQC+WJrPDT03zhwjLclFNH7kIGlK4TKesC3p3pA3tkbFfQ== X-Received: by 2002:a05:6000:2f87:b0:3e0:c28a:abbb with SMTP id ffacd0b85a97d-3e6374655a1mr14261160f8f.13.1757582364910; Thu, 11 Sep 2025 02:19:24 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:24 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Tonu Naks Subject: [COMMITTED 12/31] ada: Fix argument type of read() and write() on windows Date: Thu, 11 Sep 2025 11:18:44 +0200 Message-ID: <20250911091904.1505690-12-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Tonu Naks gcc/ada/ChangeLog: * libgnat/s-crtl.ads: define unsigned * libgnat/s-crtl__mingw.adb (read, write): change arg type Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-crtl.ads | 3 +++ gcc/ada/libgnat/s-crtl__mingw.adb | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/ada/libgnat/s-crtl.ads b/gcc/ada/libgnat/s-crtl.ads index 196b0109ab55..5ca7fc468495 100644 --- a/gcc/ada/libgnat/s-crtl.ads +++ b/gcc/ada/libgnat/s-crtl.ads @@ -50,6 +50,9 @@ package System.CRTL is subtype int is Integer; + type unsigned is mod 2 ** 32; + for unsigned'Size use 32; + type long is range -(2 ** (System.Parameters.long_bits - 1)) .. +(2 ** (System.Parameters.long_bits - 1)) - 1; diff --git a/gcc/ada/libgnat/s-crtl__mingw.adb b/gcc/ada/libgnat/s-crtl__mingw.adb index 6b1035974519..8f10cb8c13f4 100644 --- a/gcc/ada/libgnat/s-crtl__mingw.adb +++ b/gcc/ada/libgnat/s-crtl__mingw.adb @@ -40,10 +40,10 @@ package body System.CRTL is function read (fd : int; buffer : chars; count : size_t) return ssize_t is function read_raw - (fd : int; buffer : chars; count : size_t) return int; + (fd : int; buffer : chars; count : unsigned) return int; pragma Import (C, read_raw, "read"); begin - return ssize_t (read_raw (fd, buffer, count)); + return ssize_t (read_raw (fd, buffer, unsigned (count))); end read; ----------- @@ -53,10 +53,10 @@ package body System.CRTL is function write (fd : int; buffer : chars; count : size_t) return ssize_t is function write_raw - (fd : int; buffer : chars; count : size_t) return int; + (fd : int; buffer : chars; count : unsigned) return int; pragma Import (C, write_raw, "write"); begin - return ssize_t (write_raw (fd, buffer, count)); + return ssize_t (write_raw (fd, buffer, unsigned (count))); end write; end System.CRTL; From patchwork Thu Sep 11 09:18:45 2025 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: 120048 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 32A923858C42 for ; Thu, 11 Sep 2025 09:38:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32A923858C42 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Z/I/Os39 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 313683858C39 for ; Thu, 11 Sep 2025 09:19:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 313683858C39 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 313683858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582367; cv=none; b=RCN+iO9wnDIkOvxNMdwn0BDW9n6PKuReEJ9ioIhV6OUgT55bohr/O7r4D4Dq9kTX16AocCKJCiz8DAkDguSeHxAx/PjIIMFBnlElXE12NH/AZ/GHQ3BPZtkUrW1SbDtR9ODxdItRf0LD5ZY7VmuVVkCa64klRinOFZEjaHQQhUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582367; c=relaxed/simple; bh=sW7dXfwd8azsHC7btYkgCtUeC3JvkV+jjeNAZvDc42Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jXzsKdmvXR1saDXe2655reGMypPGlmfJTaIPJykRUCUVsIQcZL01PGKwXC15mztRaTDlwlWlq4kxn02n+FnAOYqPTtiDspKXR0AW40fA8PMEujINfGYFHIGRoz5cAVSM8NZyf4458sjKDMBLFmPi9EsiCRkM1P43M/sePJREbXo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 313683858C39 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3d19699240dso910541f8f.1 for ; Thu, 11 Sep 2025 02:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582366; x=1758187166; 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=bUiLTgKyxFtES8mG5Uz5FEtgHH+eWTE/pPsSKuUs6O8=; b=Z/I/Os39QVnzbh6XjJahH5LImOe1EgO/QEqdZIrt1P9FAiPA8A+mnceB5c5eCJZu3g ZP4B5OqkOLKuZ57cvBb/wGnoSgJghUy2Bjmf3v6Uj8Y2hPMafHG+J0xSzpU47uOQg0T6 eVCPbqqabNzfQkEQYnUen+EJOUkt+Ip/cO31O6mFxc/4HdY7LDw/PO0vG8wBR+vdhpHn O8k2hWZLLp7lpnAPZbsht6sYEQlVngYwQQmj/7KGIt9EeckZI5zvnl2w7BjacPDlTX8y TnJ3BTXNutnKZOcENwUl4/0soUFwT+48Q4c3MX9lnIdYsagAJYuPaKCrwK4igQFtTEk9 Atqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582366; x=1758187166; 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=bUiLTgKyxFtES8mG5Uz5FEtgHH+eWTE/pPsSKuUs6O8=; b=GtyJgdil6pwmXZpjGMx4qg1s0SRBFWdIzh4XRqjTb/kRh2l4FSAO4fzwVNn8qgFsue kST7p4VgZfAowe+ObDcVlWni8L6CTIJkgOqyX6tImOGocJGlASm3gPgJhQeny3Q8VABM 2+1N0cy95RkP11Cg9J2BzJgPKZHZHYSGQTyP7940f1IiOq1c9g6RGMQPoEfiWswnOKQC A6gzcKxbntJ7S87p4pkLfzeukprYcC7htpvfItxd5cCsgjrhb3btExCVdgUS2/LkDora xRdP6Lfpplf7gTDUHPMu6gIyNYPnjH7kX6U7hR4oDSYLhyMM+wDk1FZTM8xnP1UhgG7C ujJA== X-Gm-Message-State: AOJu0YwlilD3dgF/UUZHkvI+wMpBUW468eCCFqTt+szWDEJzPzdbq2Fh 5Y6nEgfxl1aoKa9BT8GqtC3xFOcAB3VSoixXoNpXJJ1G2wYJ900jgehZzmlQpXh1NUq4EOyxsxI lo74= X-Gm-Gg: ASbGncvJWKLcmu6zq72TmqIN28ZFPPe2piKszWXjlAHVAmxB1oQOF9z8YjqYvL8C9Up 3IPxm7HgvQCOekh2bEn+0ilNoZOI9HHylGQy1jimwfzZ529wet/XcOm0ghH/tH7+ImMyjSheUfb 01DW9u9gtyn1SOmuecBQL0UdZQzkJxFbNzX+7rP5VpXlMsETUGXeUxn6W34lzBQ9IsVT45Jz3HV qRMVoJ6ah0J50SATErkmdvhgP7xrhDmdLnkn65Z+zPIqVYx6IEFzsCnzDT97ean2UcXCUs352vf 4Lmq756DP7vTK/XkAnUaVnkTebbd8LeNabh8Xxmz+bDUNJcPOxe/OdEErHQs5pva4elz57aOxaR N1JE1adymKrGbWlTrWijHASkcDzGdUeeIYKDhUkOesDeqjuOayMUpIGw4ECPNuxKy03DSHAMFFk XojLtrIUHv5p7D6w1srqXgPUK+gzN3Isk2S6X61g== X-Google-Smtp-Source: AGHT+IGj4rQA9vDE/+dGScO7bMWQ5UpS58Ny1imtgxIHROKuBLxKuJ/Tdu4BwOL+BzxZHX3e3Q7+fA== X-Received: by 2002:a5d:5885:0:b0:3e1:ca94:3199 with SMTP id ffacd0b85a97d-3e75e0eda07mr2434698f8f.14.1757582365710; Thu, 11 Sep 2025 02:19:25 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:25 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 13/31] ada: Crash on b3a1004 with assertions enabled Date: Thu, 11 Sep 2025 11:18:45 +0200 Message-ID: <20250911091904.1505690-13-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-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, URI_HEX 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 The compilation of files b3a10041.ads and b3a10042.adb crash when the compiler is built with assertions enabled. gcc/ada/ChangeLog: * freeze.adb (Freeze_Entity): Protect call to Associated_Storage_Pool since it cannot be used when the Etype is not set. * sem_ch3.adb (Access_Type_Declaration): Ditto. * sem_aux.adb (Is_Derived_Type): Protect call to Root_Type since it cannot be used when the Etype is not set. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 9 ++++++++- gcc/ada/sem_aux.adb | 1 + gcc/ada/sem_ch3.adb | 10 ++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 1bbc24f62fe2..31a583b769e8 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7750,7 +7750,14 @@ package body Freeze is -- Check restriction for standard storage pool - if No (Associated_Storage_Pool (E)) then + -- Skip this check when Etype (T) is unknown, since attribute + -- Associated_Storage_Pool is only available in the root type + -- of E, and in such case it cannot not be computed (thus + -- causing spurious errors). + + if Present (Etype (E)) + and then No (Associated_Storage_Pool (E)) + then Check_Restriction (No_Standard_Storage_Pools, E); end if; diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb index 0aa74e39050a..58a4beb221db 100644 --- a/gcc/ada/sem_aux.adb +++ b/gcc/ada/sem_aux.adb @@ -959,6 +959,7 @@ package body Sem_Aux is begin if Is_Type (Ent) + and then Present (Etype (Ent)) and then Base_Type (Ent) /= Root_Type (Ent) and then not Is_Class_Wide_Type (Ent) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index b31587b4bcb1..3317fd209816 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1476,9 +1476,15 @@ package body Sem_Ch3 is -- This reset is performed in most cases except where the access type -- has been created for the purposes of allocating or deallocating a -- build-in-place object. Such access types have explicitly set pools - -- and finalization collections. + -- and finalization collections. It is also skipped when Etype (T) is + -- unknown, since attribute Associated_Storage_Pool is only available + -- in the root type of T, and in such case it cannot not be computed + -- (thus causing spurious errors). Etype (T) is unknown when errors + -- have been previously reported on T. - if No (Associated_Storage_Pool (T)) then + if Present (Etype (T)) + and then No (Associated_Storage_Pool (T)) + then Set_Finalization_Collection (T, Empty); end if; From patchwork Thu Sep 11 09:18:46 2025 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: 120040 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 6D90F385841C for ; Thu, 11 Sep 2025 09:30:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id A524C3858413 for ; Thu, 11 Sep 2025 09:19:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A524C3858413 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 A524C3858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582368; cv=none; b=gPUiLWPaoA6GiE8KXJC0vrxNWlvLtWJDtITXuRTaHEqoRxQzbn3VZpQdG6o9l0RjYTTfRN7gr0r+m+a0R4edbUH1+3/VhlC0dXMNxCL1GExg70/7Nz9WaUsNibsibObJbzNl3Awvz9GO86hXbZHZWx/GnG9Ym7cVF2UBLRPraxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582368; c=relaxed/simple; bh=Xq30kS3n9IkbZ5RTy6IFV39ig8y4uvYcTvuMdCPbQPE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qxKJEk4x59JEurOy+eWnSjOtIDmRXMxjrf2wYX4qas/8fXwxXzk5uXVwltX+RE80vUtIWeQOIcn6qpCXCH54Y325uH17XyMxPDUYwhDFBBs8dY30f7GSF0hf5UcCP6/uo3IFhCtWzVN9rjdrPk07HVEw/AfNwqogjzmK8687dYM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A524C3858413 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=QDQC3Gsg Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3df726ecff3so294682f8f.3 for ; Thu, 11 Sep 2025 02:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582367; x=1758187167; 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=voKtY9gXfuO1YTlrs0uNPgWFkgKxRq1zH+FTyN5wsYw=; b=QDQC3GsgI4q7a/c92P+hAFcw+vhNRRC3nAd5iHc3amB5WPwYV19wxP0lGff2ZxdVwq lP9m528cHtdIQRrQq3xe5eSbkInRmlLaIpmC7/dQTe+WTySU3q4MPeAxn7rZ8H8j1g2W QErutr6ebylGwHLQxBKfAf/sCuVduPjEdtntdLNrD7zsDDTn1FPGpKxDVX9Nxc37RCJs QjV314PfmDK2vdIKYcWFEd/CBO2jGpRwgt3Behfu9ybrPxTdXOc/JDYdPILPdVFf5Kmd 5UOV7zcTBo1qseP7mlEiideiuQaMDUn64tpZSdq2qsOFOO+moVx8As6asAZ3ioCSYFLL d8Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582367; x=1758187167; 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=voKtY9gXfuO1YTlrs0uNPgWFkgKxRq1zH+FTyN5wsYw=; b=vBpJLPmtSt4C0fgholDn9dVEiYETtABf/8lShFo1vGZ+YcWthNPK5I24Qcp9GKvfaI pXnH5JWgABiWlrxJ9gR6iPW5q+bYYFQAXfSoznrmEyQbQdulAp7Zy6QdkGEChLgUrXq+ ZRgbLCp7KncZV4IYMEaXwDQh7mxmUCoWU8kpRUaafEkTiI0N3+s+oMghNYx4aW+eS+LE Lb/AeS8z2WJD09+8ARMiGxsvCrhVCr1rUDlulPve4vluSEBFbfPSbeDfxlm5uC24jfCi 1KkrCxKKioDnEbOkqsF5n5v5jadZJkldf2BgDj30iVj+90Nd6WNkH9LYBVYWawysQ106 AUkQ== X-Gm-Message-State: AOJu0Yw1zu7tCgSKibIst7XFPm4aBOG0B/wB1qLQgiT+gjQq53nSU51h 1zosxxR44kUTtHi3NHmAfBOwcFI/mDdQncvlkvdAydWVsyDuLLmw8n3yq5g5zQ45L+GQ6Iy9SiY LaGM= X-Gm-Gg: ASbGncuSZXxMyQk6TcLm0YteLOkCbnR8890vkZ5yTLk7I5DPxH0mybIQ8VdWWPIOFV+ L03qNhG6E8MYhzFFXOGcDRih4BQoMrkGNX0ORNrpffcAbzpsBhw1iXjh+XZGAVG+jMbwt+OLlKU +g1WmGr+VIrJ6J3CHzvbNTXXqVTXNJcRmWYU30ukgqY9so1c13TzJBUVuByE/VUnuTj1+PNpNgI /43/Gt8IP1vhJ2q7E9whao7yOH1FIgInCp3rIWaeX1BI1YhYKUU5mPz+BGiywlTh23YGV62nrTm KI+ZGyqzVQslhuBVnFroL0pwDQTCnLCJf2BKbIRpbgDRphi9OPFIAhNyGwduL/rafZ+i4EcNzax b0i8tm5CNLK0lWiC9kVA2qBf9sai8xnKdyq+cXletDwBenX/ffJ/kbsv457G0ie7JNlYsWqESeG m/brDpPsQHhF1Sc4GuVfvLF6aAkZ62KtJyY5yklw== X-Google-Smtp-Source: AGHT+IF+r62P8nGXOPwbc9BBjAHp1jXke6TAaE/Sd7nqvLqxJXh+Gbr9tOrG8b3jayarYiVZwz/J/Q== X-Received: by 2002:a05:6000:24c4:b0:3e4:9dab:3f4d with SMTP id ffacd0b85a97d-3e643e08c96mr14344567f8f.48.1757582366490; Thu, 11 Sep 2025 02:19:26 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:26 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 14/31] ada: Fix regression in Root_Type Date: Thu, 11 Sep 2025 11:18:46 +0200 Message-ID: <20250911091904.1505690-14-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 Previous change, "Make pp and friends more robust (base type only)" introduced a bug in Root_Type. Etype (T) can, in fact, be Empty (but only in case of errors.) This patch fixes it. gcc/ada/ChangeLog: * einfo-utils.adb (Root_Type): Deal with missing Etype. (Root_Type_If_Set): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo-utils.adb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index d84e562853cc..450d4c36b211 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2585,7 +2585,11 @@ package body Einfo.Utils is loop Etyp := Etype (T); - exit when T = Etyp + if No (Etyp) then + Check_Error_Detected; + end if; + + exit when No (Etyp) or else T = Etyp or else (Is_Private_Type (T) and then Etyp = Full_View (T)) or else @@ -2609,6 +2613,10 @@ package body Einfo.Utils is end return; end Root_Type; + ---------------------- + -- Root_Type_If_Set -- + ---------------------- + function Root_Type_If_Set (Id : E) return Opt_N_Entity_Id is Etyp : Entity_Id; @@ -2620,12 +2628,7 @@ package body Einfo.Utils is loop Etyp := Etype (T); - if No (Etyp) then - T := Empty; - exit; - end if; - - exit when T = Etyp + exit when No (Etyp) or else T = Etyp or else (Is_Private_Type (T) and then Etyp = Full_View (T)) or else From patchwork Thu Sep 11 09:18:47 2025 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: 120043 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 36E3E3858418 for ; Thu, 11 Sep 2025 09:32:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36E3E3858418 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=T99vk7Ph X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id DE3FF3858C66 for ; Thu, 11 Sep 2025 09:19:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE3FF3858C66 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 DE3FF3858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582369; cv=none; b=m4djrVjqptUEgSiec9YXuXfh3Z1NW3lpbAVtuE0O+Rk8ho9EezlPYUofpBPjYWpXgeq1UPUR2skkCV+rsbM9hERTX7+u1unONTh3GJRF9WJtVlcRGgSQHBmfUs1l9+DZp6UBOvmFwvUX73gl8wFtpbAUmp1ZIRfm2+pk6Sz4jHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582369; c=relaxed/simple; bh=p1FemgNkZ7X7G3BwCN/EqTkeWtgQfROr1/092K1v4h0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e1wnsXWyvqxZOKqgCr/dPelKUq2tYVIN+FOOSWDF3dMLiyHN2u2O1i4q+MaCWE52scwVmnmGx5hlc1OiIbs2cVs5XNMzazjnYE1waadJ4NMbu1Lvnwpl9D1xfRVs+vKn5ukmvRZOpV+smJwTjFnupvwcKDeFbkEBhjJeF4Hllis= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE3FF3858C66 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-45b9a856dc2so2970625e9.0 for ; Thu, 11 Sep 2025 02:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582367; x=1758187167; 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=NrOseLxRzpwC2jwYJIKw52QNEN7hn2Qn4l4GSa8ZDIk=; b=T99vk7PhOErbm/4LqrNOa7+slG7TwidN1H/7QGRYLFzAs+K3B4aSeINBi0ksO6hQdR Rli4ZyCc6ozt6XLNXnZg1/ibNxQPuTSCQ8pgfnCbi4RbzkPtMnrqvLIr3iWLahQoFa7M EBJjDvS5MZLNcNNGomk5KsyW60jRT0PxgN9o0EYPNrROV1ZZ/a2/OMZ9Z9cHp2kSC400 V1wxYbJmnzuoAD3dclf+GIQrs+KFpcjLHHmPYIT/IXz02/TUXUhYhZv9P0tyfikO1+X+ iCB1H+g1unrUG5HBCdUVQwqvQmrSxddH3df764ahhOP+Clm+ATO0c230Wc7LIfEhBbBB mR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582367; x=1758187167; 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=NrOseLxRzpwC2jwYJIKw52QNEN7hn2Qn4l4GSa8ZDIk=; b=UFz2icg6eUcj6x0piiw9JRjrldh2a1dG8joSDKu0aw7ngdSdCN1GrM97CBTa+5h/8s gYAsQY7PO+cgevV04KdwDt4LdEdxnfbXqXqR+p2IMBQ9QRNCw7KRXupW0Dre1fBGPTTg nZlkAIwEeZo7YdE9iEcTXKS1mqlWC6kVnxOYwXJnKseweKaNwcyzcPgt20FlF9uLgOB/ nwFokBQYBw39up13uetev8uGohjBbO5c9dOq0mQ4IAH+XxfVvAVuq5W/6d8Ez0Fu2uEv e5J2SlG4N8HUPOVYWXypXOywy7XkYYhhAiN0oFdPgkx+Z2HrtEeEgnVi1rxwj+cNbds2 Z30Q== X-Gm-Message-State: AOJu0Yx70ZcyjMt1tD9nF+xoJo0PPmOOvqhXBeRMKsNEaecas2Tl+W/O uDBQ5CKKSd9lJrbqtwQ3bjchtrzPL7cc+g70CdZiAjSfSYu3UUwSt6nsvDX7M5xGXR5+VTIB3nb b/MM= X-Gm-Gg: ASbGncvZ5nDuYd3kf+YQ7NG3WuH1/lpdlwcFyr8EpoAsmlm3EB0Jfm1YA8J5cLA63c2 0V1cJzCzQcW7v5dnWGrupvSfKbsLofJoMGFaqR9QFYg4yj2itg1fNRodmN97oTWDE9TNThYTSwf 5BFFnwDtBkXlaNqzv0s7vMzLOqkm3y7ADbDXC+m31FfglNUirF07gZMH7nuwgxF0oud49mzq5Sh CvSpj4yJsyjNURrbyEjrX6UbylrvHXwRWVuqJ5GAX6KzRWKizub9FICvYESaROWoLW5hlYFjYsC CaLeZlO3u4teal6ZcFsanssrQx1gN0R4xbp3cVIIVVYmCI+ZJp8TZsm///AnBMVL4+0lZxVINP0 imfXuNoylSknpViUyW74jb1kC5d11tOPPK6nq1m3MPnEQ5TDhcgSEcu29W/jLBDTwoKkRTZ6Zyj 4ieQ9MySLXHgwpde/O27fJ5fFmpxNZ/RucnDuuaxGwHPQmOtYt X-Google-Smtp-Source: AGHT+IFAwH0acQBOc4M/z9nx8QKxDj2O0Moqygps4GghFTRdCWNdX44Zy4rzJKf4kmyGC2QUlvC1jg== X-Received: by 2002:a5d:64e4:0:b0:3d6:1610:1b6a with SMTP id ffacd0b85a97d-3e642f9154dmr13269529f8f.22.1757582367334; Thu, 11 Sep 2025 02:19:27 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:26 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 15/31] ada: Fix regression in Root_Type -- adjustment Date: Thu, 11 Sep 2025 11:18:47 +0200 Message-ID: <20250911091904.1505690-15-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 Recent changes "Fix regression in Root_Type" and "Crash on b3a1004 with assertions enabled" are partially redundant; they are addressing the same bug. This patch adjusts the former in the case of Root_Type. But we leave Root_Type_If_Set alone; debugging printouts should survive bugs when possible. gcc/ada/ChangeLog: * einfo-utils.adb (Root_Type): Do not deal with missing Etype. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo-utils.adb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 450d4c36b211..290ae331d37a 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2585,11 +2585,7 @@ package body Einfo.Utils is loop Etyp := Etype (T); - if No (Etyp) then - Check_Error_Detected; - end if; - - exit when No (Etyp) or else T = Etyp + exit when T = Etyp or else (Is_Private_Type (T) and then Etyp = Full_View (T)) or else From patchwork Thu Sep 11 09:18:48 2025 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: 120044 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 D40E33858287 for ; Thu, 11 Sep 2025 09:32:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id B2F463858D37 for ; Thu, 11 Sep 2025 09:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2F463858D37 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 B2F463858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; cv=none; b=tqi8E/F6SZ028XMDuvCGfoRzv54NvFpRWpUvWNRqKjs0qhY3n+zGAsGYs4aGrMolcAEWbTArm8hTIc4KuKeYZo/LyjuD6fMdTGeSIlQuXyGTKgm37zcD3Tovzd70qEcaQLQjLKWWq1J2UzPjDSYy2xh91MDCioEch9MG2okJ5t0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; c=relaxed/simple; bh=yRSsNTOkC1F8uEYm3OmgMIrM9FsNyUYJKiRIjk9iHFA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hI1+Xqgoa35vxeZDHYjE/Xby8HX/VAt1IG/s9DE68LPuc99cUa3Xd7sAvSuSp4b8ljHM1VTLbFpKKgR40WSb6cqfWci1RUpJK+TWcfgEnvnjouo6zzOix+707+ikR567ktWXNBt8ZOUiK919XTF+gXgxrTshUO1RE83rQg/CpPA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2F463858D37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=jhV0UWCp Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-45df656889cso3138675e9.1 for ; Thu, 11 Sep 2025 02:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582368; x=1758187168; 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=EO+6sTPBE01S7b/qX+Valr9sS/Ok3MAInysDNUEhMTM=; b=jhV0UWCph70pSyh6gIAOHPHNMaGoaftRNj/mCNCMihT6MV6q3ZDZeg5zoFo0nzTku/ SXc772SSaRrrkj5OM6QHy/Ck7KHXsvSwTWZWKGncr/79hXRk14kNhViKw82vtadkK9tn N2+hNbRGz1a+W1KU51T+RfNqzt/I0cfuWm/KdA9gzG65quYAHAiPi2oMKt6HjtVEMaYT NebVWXgb2flohi0VEW5ufo3NzVBsEWG+pPM0RRL4IpMGhb+rtqbrBnB0mILXYtw65HTv QP0wT3rFIMv68hYvfWFjoX1LbAGRlKU5G36qrD3Jx9oIYs5q90BOwSoYtcImiAqQzRt+ +wNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582368; x=1758187168; 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=EO+6sTPBE01S7b/qX+Valr9sS/Ok3MAInysDNUEhMTM=; b=Gj8JYYsHnyWqBvpyMywfRtufMUDvs4vxMargsDYScV1vg8J/4YFPI/00xG4b1PYz50 yKvWurZWM/daTyxOyL1GzhRfWqHdLkpeaEKczm+9Y8fv2GjtrwznayJ+OyK6006yxk+9 XkNQ2IPDmsd/4krW8SZ0mT0WyK2fTIVyVdtSly6YPgcJOZXH/vTxfVsJYQoWGhIPwgaM rPPV3FYo+VT/x5DH0kTP/jVE1DcFFvPusYzogxdA9hgjbtIFcPkMf8cha6Q2+8W3ny71 QU4nqy1qUbqSNDLHAhgfEYjvy/Bk3hDn5hpnJzq+s5DX8N2z/lFb1+ZuHoY987tW2J71 xmtw== X-Gm-Message-State: AOJu0YxjnX/pHY7vxhuDKMcBuqZ2yQZnnwi9gBlE0NiwW31kInQWh/3l Dwy4lSe3uaGOD4B2oEZ3vRFxSwj2gBvAeSPxM8QfC3Dxw3b9J3RxXqNKc1cg+6MizWwG9SW1czq znOY= X-Gm-Gg: ASbGnct4E5nR45UkAeKbzsFAk+xdLP58aGZEI6CglkpFzPhDQAVUIVjO1AwARufxLhO mlsqLke0kDh7GdUgNay/1JmqugEAvGHm08OF7h2DWLHYICGipnclKfB0Wwg6Vk8ZlEzF1rWg2mb rVH0VVwXFkXOhJavRGST5cebMmkoBYMeAoluI4r4ZlMO7wutE6mMzsz8H10dhiqQeEkaq+P5WrF VSPtevgEWmW6S8PDuN5s9194ITrVnG8DkEq+ZDAyRJRcLUqUkKwkeUbjFColK+PDPNxLqfNcMZe yJ1sw7FKDtvhgXZW2AO3bAA1L1LxsUbwTYTBYVVxKMDpPxNlvQuZrsR0/YHonbeQjLR/NxmGlKG At90p5BxsUfcBAT1Qs+IzLckxyWoEO8rWj58J3L6ULlF1lMCYeoPNh3uxDSv6lCODzq+EjzUSEZ 6roBe9oYS2dkBJwtDMpasUu0QTAgXSRMD0dxMo2jevSTPWMj+/ X-Google-Smtp-Source: AGHT+IHhSBULR/hIsisEVAuP+iwY2OGmLgW0chj2bAoh2GXrYM47UNYJp3jMZOhUW4sdaCD4Tu8QaQ== X-Received: by 2002:a05:600c:4fc1:b0:45d:d5df:ab39 with SMTP id 5b1f17b1804b1-45ddded614bmr161301815e9.26.1757582368318; Thu, 11 Sep 2025 02:19:28 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:27 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 16/31] ada: Fix visibility bug related to target name Date: Thu, 11 Sep 2025 11:18:48 +0200 Message-ID: <20250911091904.1505690-16-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 the following bug: If the right-hand side of an expression contains a target name (i.e. "@"), and also contains a reference to a user-defined operator that is directly visible because of a "use type" clause on a renaming of the package where the operator is declared, the compiler gives an incorrect error saying that the renamed package is not visible. It turns out that setting Entity of resolved nodes is unnecessary and wrong; the fix is to simply remove that code. gcc/ada/ChangeLog: * exp_ch5.adb (Expand_Assign_With_Target_Names.Replace_Target): Remove code setting Entity to Empty. * sinfo.ads (Has_Target_Names): Improve comment: add "@" to clarify what "target name" means, and remove the content-free phrase "and must be expanded accordingly." Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch5.adb | 17 ++--------------- gcc/ada/sinfo.ads | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index d78df5c8315a..0949d5864bb5 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2254,7 +2254,8 @@ package body Exp_Ch5 is function Replace_Target (N : Node_Id) return Traverse_Result; -- Replace occurrences of the target name by the proper entity: either -- the entity of the LHS in simple cases, or the formal of the - -- constructed procedure otherwise. + -- constructed procedure otherwise. Mark all nodes as Analyzed=False + -- so reanalysis will occur. -------------------- -- Replace_Target -- @@ -2264,20 +2265,6 @@ package body Exp_Ch5 is begin if Nkind (N) = N_Target_Name then Rewrite (N, New_Occurrence_Of (Ent, Sloc (N))); - - -- The expression will be reanalyzed when the enclosing assignment - -- is reanalyzed, so reset the entity, which may be a temporary - -- created during analysis, e.g. a loop variable for an iterated - -- component association. However, if entity is callable then - -- resolution has established its proper identity (including in - -- rewritten prefixed calls) so we must preserve it. - - elsif Is_Entity_Name (N) then - if Present (Entity (N)) - and then not Is_Overloadable (Entity (N)) - then - Set_Entity (N, Empty); - end if; end if; Set_Analyzed (N, False); diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index eb9529f52cec..bde67a05b6e6 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1476,7 +1476,7 @@ package Sinfo is -- Has_Target_Names -- Present in assignment statements. Indicates that the RHS contains - -- target names (see AI12-0125-3) and must be expanded accordingly. + -- target names ("@" -- see AI12-0125-3). -- Has_Wide_Character -- Present in string literals, set if any wide character (i.e. character From patchwork Thu Sep 11 09:18:49 2025 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: 120039 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 A186B3858C62 for ; Thu, 11 Sep 2025 09:30:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 821B23858CB6 for ; Thu, 11 Sep 2025 09:19:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 821B23858CB6 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 821B23858CB6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; cv=none; b=dlZfZnznTPTkRaPjmbSqLfahny7fYYJ1iCtvWAxUcJaiDFD5IUwQnwsbQZJsx2rCZrNSC7chMqc7+tEhWmWQdgv98gHjQ3kGUuhGQOS7I7jbGLKEK0lhFEg1UbFsblWC8dpvv+UbpBdhytF9O7gkCKp42P/txIqriXygm60YYiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; c=relaxed/simple; bh=KEOviqWatkbxDO0Aa72y5IoE4g+0eWVdrtVJJxQBnQg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=csR7WN/ukEHHBcFmAUDTt+SNWEh876djQD+OMRfWwDWVHanKJoquzXuODA5sQ7kWS49tY1Wl5jrlKtobmC7qKLjxNa7XzuVuTzR7ALdiTpmI7PbI3IfiR6vipHaIB/1ooo+wtX7E0jpsccf4lD+yvuS4szeuZRLpeOlBka2DrpQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 821B23858CB6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WLr5quQ7 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45dfb6cadf3so4418465e9.2 for ; Thu, 11 Sep 2025 02:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582369; x=1758187169; 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=l6VZFd2Wpv+8ZvVD9LFHPz/4Wnhv9yaUUKmoRpVmpQ0=; b=WLr5quQ723SQGpjJgorQu8xKLRnsLDTFQt9JxwzujV9u6MNgewUEr5483ucjjKURR6 dT3I93DJX51P1PkcTJ82EwlpT06F5NngNoW0GoFJlfSzPYAu3dL7Z410T5ISQnUQfJ5i Pntig3/9NzSfRr0lVu8OtdJOp5jGGVHA6xxP2WblAlrZ2JB6whXU0ucK3thtzvqmaRFE TMnocEmdg/M5Sb7A7HBwumbT8H/A8yrkj+tf86afo6Pt0Gy0IrcnM/JsHM89t2nTpTDj oSBbpRnZ2kRC36AReQNM2SeSSeW3ypz5NasjTClJWj7CYF4ii/XHwyEoOJ44FEdiy9jv 5hJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582369; x=1758187169; 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=l6VZFd2Wpv+8ZvVD9LFHPz/4Wnhv9yaUUKmoRpVmpQ0=; b=NU7I9tgcIc4BcINAeOGkDS4mS097tD3mU70gQoMEO3kJ458wcD8da5qVwr/6t6qSHV p3UGjxnvqtCKh5iclNycK6L6VemHsU223az34EnzIOdycY/oLq35S5Kb/8pLYorfioF9 nu5qckbV+9zBdBhkttuqsxrlE/6JGtLa1Mh3KmLMCk4+Z059C1cM0leI/xrrv1bbhTyj hqJMtKp94AJjk15Hbbvk8D1N8nDB2amlJ5Nkjc1INNzFRcARckl2EhCF7aizktCl718+ VGtrqcYqnYbSxXgjNvUL7pgG+mrOBOcKVBjZE5HBN2qJc40z7zQumj8BOxnw9ocCV9pO Vx1w== X-Gm-Message-State: AOJu0YzjHf33B+q2h2Hgg5goAWzvWG/4xbfTHYC690IVKDBjdCng1q/l zTQ2FrVsqBnWUvlMy335vd0d3OmsJQf0YaGiZQ9R4XwiB9Q+025exMkATHHCORt2EdmMP5wFgEL qyDs= X-Gm-Gg: ASbGnctq6Q3fZnT9ksg+SDxpON77AxCv3ATEx0VUNFwQsHAhcYs6+SuxBxPchArXMiQ wWZfh1vz13jTsEv40OpXJ+I+w3ypvansDsHM+atC+/+9CoQB2xqppdHiCTqMtCltuKof7nCZcku rgDLfCoUTMMSJMVhUY8L5cvqO+t5t6+Vi93KYFfGPumTqXGVRI4Yk4HF3gccM5QAOnbNhIvT84u h9xu4Kbaan29l8qc02ZnAvV61c5yjaDoohB+HjMQltdwPzqGfAEUrvdd1QlQXmLZPZkE2B21hY4 67IeDVDQ9oKFXxcnceSC9Xse3LlWkZO0L0QduW2WqIDEL9t0ZRTbhR7MzoqiQVVTCANU7ERlnQ+ psQo9cN+7nYXjUDJtABc1FNb7pMDi29RqjIDNzkFxURMtEV0TlatzrgNeII974oEz4gVhi7LcEU X4SpxL5aGEJ+3aE2FjbZe7fXEsq/jTjI/iNBO7JSq/w03cOutBUXSf1dfGWVg= X-Google-Smtp-Source: AGHT+IF3Lwev0MQYm8Iqtg42oIUhNNGDPRTxgmTq3lh/m8TfXOkkg5pkN4LA7WGnQUt5FxG7GqWVqw== X-Received: by 2002:a05:6000:4283:b0:3e1:734b:5393 with SMTP id ffacd0b85a97d-3e6435551d9mr14946746f8f.28.1757582369115; Thu, 11 Sep 2025 02:19:29 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:28 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED 17/31] ada: Compiler crash on container aggregate association with nonstatic key choice Date: Thu, 11 Sep 2025 11:18:49 +0200 Message-ID: <20250911091904.1505690-17-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 The compiler blows up on a container aggregate with a container element association that has a key_choice given by a nonstatic key expression. This happens in the size computation for the aggregate due to calling Update_Choices with the nonstatic expression. The fix is simply to condition the call to Update_Choices on whether the choice expression is static. gcc/ada/ChangeLog: * exp_aggr.adb (Build_Container_Aggr_Code.Build_Size_Expr): In the case of an association with a single choice, only call Update_Choices when the choice expression is nonstatic. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 34d4f84f95e6..6b4f4a19d1f9 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6984,7 +6984,9 @@ package body Exp_Aggr is -- Choice is a single discrete value elsif Is_Discrete_Type (Etype (Choice)) then - Update_Choices (Choice, Choice); + if Is_Static_Expression (Choice) then + Update_Choices (Choice, Choice); + end if; Temp_Siz_Exp := Make_Integer_Literal (Loc, 1); Set_Is_Static_Expression (Temp_Siz_Exp); From patchwork Thu Sep 11 09:18:50 2025 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: 120042 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 7F053385842F for ; Thu, 11 Sep 2025 09:32:16 +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 511663858415 for ; Thu, 11 Sep 2025 09:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 511663858415 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 511663858415 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=1757582371; cv=none; b=M2Jqb3KfzXeRxbDBoFxQI3D2Hq3P3qkCvLp/bXHphqAVwOGvt85pJqVZCw9JSfqvTUy/UQGwU6ydoMr4bNK3ijddz/8J/nrFLTdFY6e/eliYlL4Z2K8OvTCxza1h4fUXd+Pt39nBYPmOWZDtT9cyPuudB5wf+JYWbTP0EXcuOmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582371; c=relaxed/simple; bh=e0SgPGLNOGJfhQSfLzX0DJdmCBup70AsgYvbXDqEHi0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q2OJ1ReJNpMxm/fcg5gM5Mwvmj5uz9XNQSZZOn3dZPKWlTTJ1pGZJQocefm/TDdoJy9Fdo3cKqcWPojGqcRAFl6fWL65zAnWA8/Wcyyo7qrKUG8wXrJ2HcebSr+atZxKuFUUhaMMNE3uFeZDmjdB2VdB/8HJ5FG9qqkPnPctDGY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 511663858415 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=TS6qqlAN Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45cb6180b60so3361845e9.0 for ; Thu, 11 Sep 2025 02:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582370; x=1758187170; 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=ooT0W1t//rTkSNhPFhJ843TmtY1EynfMVb2Bz803pq0=; b=TS6qqlANA/vx3/wLfEMAqiG8bppdSGAJSCBbJHuwziOFxINeoLNOCCflhZ/2r3G/R0 V5c70cfBVYSICa9SRJYtXCsS37o9DuKgJ8EaU6BItZpSq/FZMSRk87mrcnRLkC2Q4hha 5Gt6llRFuCXEVPDk9KoWOVL7siuCZiQiP13KLVAqCxa86b5UqrgRrprfISCfEoODWWAT KR0nqat35vi82xDOFWKaKP2Qx1zasGLj42r9jZmOHWpeNnbuYKYel84F2Za7IV1C9Ima blE4sGOIzMDzoThzWw6wx3QOvbKo7LA+V/TCTNGz1+zWIOntENB9nxSKtoyOMi/BOgc6 oQyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582370; x=1758187170; 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=ooT0W1t//rTkSNhPFhJ843TmtY1EynfMVb2Bz803pq0=; b=kgDP0Wk8UYvK35J5YpjiAcNd6tg7jN3XNiL+CVZDYAa6kpQ4JixPjYZm92az9edIyK uGjxQ8vcuDYvvOp8SB5qRoJECDMaHCGBIZniVUVv8tD8TpBLqQo0XpokQfIJgqK27F/q am6xOGxS0wvB6RjoZhJcjJbh+n1eRRuQ53wZhPCMLL+yfhGCh0scpeCcjO49PXYXZXfr xQohFnJ2diTJkLPXEiJNFbs7ozP4fJMzddD5U70Ldqg2APxvRISwZ5QcgCkTxA0toqUA 7WoIh0PTam3K6+Yx0+EWmQ3zIcw7dyrJS2iVIdo7TU8pLH48srUGYON5UN1hfKbpTOOX 1B9A== X-Gm-Message-State: AOJu0YyLdi2e9vpNKTPsFeIeVztATOj1ik19TpmscQVcLZae3OnTrqsB mCeuQqZNUBuRQyH49KKSW3ENsQOms+ynNncDYBRPawu6HQ0Qv1sZacYADA3IXYw0+vV0t+lcP8b m7QY= X-Gm-Gg: ASbGncu/g5WuP8YB3P/DpiUC5+ruLQNlJ+S6kdP5rLeX1UW9i+FiaX91RubCzGnMWVX ryIhDsVgVN7UV1i1WkyAdpWLohbeE1ImCKl/aR4y3cnBrIx5eugX49/mnbrBjPIsv/4ozPD9Glk gR0k42KDSjq8h8TT9Xn1OGdEibTdIO12bwBuw+/AF142AW8wndq1r8LCqSBEsrt157JFUu0cFsw G7TVfzlltueTR8QAkqdOtVdavOHoZTz5zdQv8VIYi21rHuSMLMNhJxNtXNWgVHw6NTQu7bAGuAs KfOl4D4Z6gMH3JiQi8UqNDYaWKd7WRPzGU05dRbd5dd94GuYe2EsNGUL4xgsIiBX3DaQCJh7kGr HhVMaEgPUM2lO5qO4hPZ8HjOoRxglrxtgZgy9hG2hRdFE/m7f/hcuhqEg0VLE7hdPLVrolSHeS5 s2h+qSVDeSqMiVHnzEF0Fg+JEOMrrex/Esop3b/g== X-Google-Smtp-Source: AGHT+IEW2q02LXVrhDqTp2un8nfJvmRjYzdsOfGH8I0PyXX1UWfJiiwT5Woz3I26kGOZ4As4Hx6MBA== X-Received: by 2002:a05:600c:34cb:b0:45d:e0cf:41c9 with SMTP id 5b1f17b1804b1-45de0cf447fmr155077625e9.22.1757582369936; Thu, 11 Sep 2025 02:19:29 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:29 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 18/31] ada: Apply ghost regions for assigmnents correctly Date: Thu, 11 Sep 2025 11:18:50 +0200 Message-ID: <20250911091904.1505690-18-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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: Viljar Indus When frontend is operating in GNATprove mode (where expander is disabled), it should check ghost policy for assignment statements just like it does for other statements. This is because we want ghost policy errors to be reported not just by GNAT, but also by GNATprove. Additionally we need to perform the checks for valid location of ghost assigments based on the region around the assigment before we create the region for the assignment itself. gcc/ada/ChangeLog: * ghost.adb (Mark_And_Set_Ghost_Assignment): Create a ghost region for an assigment irregardless of whether the expander is active. Relocate the Assignment validity checks from Is_OK_Statement to this subprogram. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/ghost.adb | 134 ++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 77 deletions(-) diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb index 7d8bcc2a96bc..bc646b22fbe5 100644 --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -515,15 +515,6 @@ package body Ghost is function Is_OK_Statement (Stmt : Node_Id; Id : Entity_Id; Call_Arg : Node_Id) return Boolean is - procedure Check_Assignment_Policies (Assignee : Entity_Id); - -- Check that: - -- * An ignored entity is not used to modify a checked ghost - -- entity in an assignment. - -- * A checked ghost assignment is not used in an ignored ghost - -- region. - -- * The level of the ghost region depends on the level of the - -- ghost assignment. - procedure Check_Procedure_Call_Policies (Callee : Entity_Id); -- Check that -- * the a checked call argument is not modified by an ignored @@ -537,61 +528,6 @@ package body Ghost is -- Check that Call_Arg was used in the call and that the formal -- for that argument was either out or in-out. - ------------------------------- - -- Check_Assignment_Policies -- - ------------------------------- - - procedure Check_Assignment_Policies (Assignee : Entity_Id) is - A_Policy : constant Name_Id := - Ghost_Policy_In_Effect (Assignee); - A_Level : constant Entity_Id := - Ghost_Assertion_Level (Assignee); - Id_Policy : constant Name_Id := Ghost_Policy_In_Effect (Id); - Region_Policy : constant Ghost_Mode_Type := - Ghost_Config.Ghost_Mode; - Region_Level : constant Entity_Id := - Ghost_Config.Ghost_Mode_Assertion_Level; - begin - if A_Policy = Name_Check and then Id_Policy = Name_Ignore then - Error_Msg_Sloc := Sloc (Ghost_Ref); - - Error_Msg_N (Ghost_Policy_Error_Msg, Ghost_Ref); - Error_Msg_NE ("\& has ghost policy `Ignore`", Ghost_Ref, Id); - Error_Msg_NE - ("\& used # to modify an entity with `Check`", - Ghost_Ref, - Id); - end if; - - if A_Policy = Name_Check and then Region_Policy = Ignore then - Error_Msg_N (Ghost_Policy_Error_Msg, Stmt); - Error_Msg_NE ("\& has ghost policy `Check`", Stmt, Assignee); - Error_Msg_NE - ("\& is modified in a region with `Ignore`", - Stmt, - Assignee); - end if; - - if Present (Region_Level) - and then not Is_Assertion_Level_Dependent - (Region_Level, A_Level) - then - Error_Msg_Sloc := Sloc (Stmt); - - Error_Msg_N (Assertion_Level_Error_Msg, Stmt); - Error_Msg_Name_1 := Chars (A_Level); - Error_Msg_NE ("\& has assertion level %", Stmt, Assignee); - Error_Msg_Name_1 := Chars (Region_Level); - Error_Msg_NE - ("\& is modified within a region with %", Stmt, Id); - Error_Msg_Name_1 := Chars (Region_Level); - Error_Msg_NE - ("\assertion level of & should depend on %", - Stmt, - Assignee); - end if; - end Check_Assignment_Policies; - ----------------------------------- -- Check_Procedure_Call_Policies -- ----------------------------------- @@ -683,9 +619,6 @@ package body Ghost is if Nkind (Stmt) = N_Assignment_Statement then if Is_Ghost_Assignment (Stmt) then - Check_Assignment_Policies - (Get_Enclosing_Ghost_Entity (Name (Stmt))); - return True; end if; @@ -1872,18 +1805,60 @@ package body Ghost is -- where P is a package, X is a record, and Comp is an array, we need -- to check the ghost flags of X. - Orig_Lhs : constant Node_Id := Name (N); - Id : Entity_Id; - Lhs : Node_Id; + procedure Check_Assignment_Policies (Assignee : Entity_Id); + -- Check that: + -- * A checked ghost assignment is not used in an ignored ghost + -- region. + -- * The level of the ghost region depends on the level of the + -- ghost assignment. + + ------------------------------- + -- Check_Assignment_Policies -- + ------------------------------- + + procedure Check_Assignment_Policies (Assignee : Entity_Id) is + Assignee_Policy : constant Name_Id := + Ghost_Policy_In_Effect (Assignee); + Assignee_Level : constant Entity_Id := + Ghost_Assertion_Level (Assignee); + Region_Policy : constant Ghost_Mode_Type := Ghost_Config.Ghost_Mode; + Region_Level : constant Entity_Id := + Ghost_Config.Ghost_Mode_Assertion_Level; + begin + if Assignee_Policy = Name_Check and then Region_Policy = Ignore then + Error_Msg_N (Ghost_Policy_Error_Msg, N); + Error_Msg_NE ("\& has ghost policy `Check`", N, Assignee); + Error_Msg_NE + ("\& is modified in a region with `Ignore`", N, Assignee); + end if; + + if Present (Region_Level) + and then not Is_Assertion_Level_Dependent + (Region_Level, Assignee_Level) + then + Error_Msg_Sloc := Sloc (N); + + Error_Msg_N (Assertion_Level_Error_Msg, N); + Error_Msg_Name_1 := Chars (Assignee_Level); + Error_Msg_NE ("\& has assertion level %", N, Assignee); + Error_Msg_Name_1 := Chars (Region_Level); + Error_Msg_NE + ("\& is modified within a region with %", N, Assignee); + Error_Msg_Name_1 := Chars (Region_Level); + Error_Msg_NE + ("\assertion level of & should depend on %", N, Assignee); + end if; + end Check_Assignment_Policies; + + -- Local variables + + Orig_Lhs : constant Node_Id := Name (N); + Id : Entity_Id; + Lhs : Node_Id; + + -- Start of processing for Mark_And_Set_Ghost_Assignment begin - -- Ghost assignments are irrelevant when the expander is inactive, and - -- processing them in that mode can lead to spurious errors. - - if not Expander_Active then - return; - end if; - -- Cases where full analysis is needed, involving array indexing -- which would otherwise be missing array-bounds checks: @@ -1919,6 +1894,11 @@ package body Ghost is end if; Id := Get_Enclosing_Ghost_Entity (Lhs); + + if Present (Id) and then Is_Ghost_Entity (Id) then + Check_Assignment_Policies (Id); + end if; + Mark_And_Set_Ghost_Region (N, Id); end Mark_And_Set_Ghost_Assignment; From patchwork Thu Sep 11 09:18:51 2025 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: 120038 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 26268385843D for ; Thu, 11 Sep 2025 09:30:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26268385843D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=B2xFoIYI X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 03A96385840C for ; Thu, 11 Sep 2025 09:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 03A96385840C 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 03A96385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582372; cv=none; b=qKiIMczPoXKd/uN+PIcST935uCpS7fXLS5CLn3intBo1ZIB+CH6WaDEEmMTRVettsK9wQeTlp28/JtzVxa2xcyEtnSChcke5zgUf5Pvk3NZ8upbTIDOv7GQ4Rhaes6pM4XYPTxPLGfJGa5fGtCafcglNSECQjiXYG32wL3ru5PM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582372; c=relaxed/simple; bh=2Oz2MThsdmpREn/TvhA56h+alBvyHt/EB+l8ZxyyvV0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Cwj1DjWXQvQy5LYpPOpBBo2jPTb4Cn1LVGQNSFQBA8THT4gYUKRIFqbcmNgESBkxxj08ksuAGvLCmUhLkFYVvTaXcZBcAHWhCYVW3nt+wEODylnNYFe0+w+hiXucau4sXUDmHgNx+Q4HdHMy5tLLxlmfTDxGfr+2aX1lckg20Lg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03A96385840C Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3dad6252eacso204367f8f.1 for ; Thu, 11 Sep 2025 02:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582371; x=1758187171; 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=N8Uf9QA9HNCE83VgiJ8kh9N0As9cyhJTSMkHjtliM30=; b=B2xFoIYIToNyxUwD2DraT6AgYwpCSZ2fh6o3HjipvvgZxqMfh6J66JYzRp6dMcM7+m a7V4JmB23tqTE8OwfEjy2uIzXmOAJ0fiyQsybYd0NT0wvmECV0DUdDD8PPC4V6GZg7wX GQU40HNUJhO6L/s0LZkx9E0fv/0XSjxLBfen6Y65xxWOWWm2iwE99VvD0OLtLasclTl9 a1SMgGHIRr2pqVghSYeHW8knkmGouz+yzwXLRpk2Hf3EZShFRSPNEoyYhuTloTqzWyCr PbIgt/+EMjK+prkM1cEdZlSzgNSIm+XX5QhJr061wN7OOqkEllt+vM8Zc0W1HXa4cA0R j5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582371; x=1758187171; 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=N8Uf9QA9HNCE83VgiJ8kh9N0As9cyhJTSMkHjtliM30=; b=VGWfMCQ2keVNsaUIXCmHFyeQbadQJhBinpLYd9oDWB6kNwEl57e+oIR/fCtib+7s17 K7uPDgaKNVQsYl9kq/IgoEeWNX8T8afp0YoR0VQ/r9eb6ZojlviUoiyHKv1lRFydL0tc VHkk6CWB1qH1+nj4KECXVM23LhBySZO7XQBYkQsenW6F5F0aRGFwCSBiFR5N/HlYw2HU n2PlgfQHHVmgBMuE8RBwJniYeSJHpMDuWERNeAi0DTRDv6bJ1xXbAv43bdzaX9z3r8dy lBJqIWosWAzHe2JTiPww/SOjQY/uU9FKaoS3deS5Ry1E/gSnpqU81/WTcnUzK0sbuFSk yBTw== X-Gm-Message-State: AOJu0YyF7K7vo0ncDtZj1slEK4GuMwrmbbjGmTq3HqB+CZiECcokTEYx xUQp9u5pA7pidCXNYdrAFCXdo28G6M5H2hzbiMXclk8X7TGer3/RsxU4U1Bf+mZnMr2W8FwlOK4 VjCo= X-Gm-Gg: ASbGnctz1kx5K0o1iw2AcM3kzofwb09gm8lT7cj1Vscsq4xpd3fmZAC/DMAHfA8u49/ +fHIG4hHiV1l30GcAeD13ezs/eGwJbSMhNjfUsO+td8KPYzZCSDz9Th8hQMuARu02ajIu6gvffG FauySK9Ktlf9z24QX3GLw7Z3zQNFeyE/xDNe10yR+l0ax0XRpkGdT/sQF+eNvZAksWn7DQ5+uhC Q9DLDduSl66i+2GBPJAy25r1RmqEbAh+8PhMgQtOUJ7N7MMBTGeJWI5lnfDWMVWgkkrEPyd5Hjv GI+wfu7B+M3UcxE49639NjJFhjkJJn31Lt56IUcVgcHRJHts6voHjS1OBQ9HtWhgocW2GPAlFh4 pfAyI25F6XgTlbuYySX5r0E6lKXpa/bxqrvr2uXtPVDqN14q/ZdTOsFh6BrsxKZhFA1kljpo5oU O4Gq5HvleMZZvylsqj1Zfwj3TS3YGBdsXA9WxXcQ== X-Google-Smtp-Source: AGHT+IFFaeIjzm2OTau4qQbu++feieJbQAkgmfpzGgLui1RXhG94N5AHCExYZivYse5ukoH1LOWW/A== X-Received: by 2002:a5d:5f48:0:b0:3d1:9202:9e with SMTP id ffacd0b85a97d-3e64392bb4emr18317779f8f.36.1757582370626; Thu, 11 Sep 2025 02:19:30 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:30 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 19/31] ada: Tune description of Ghost_Assertion_Level Date: Thu, 11 Sep 2025 11:18:51 +0200 Message-ID: <20250911091904.1505690-19-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Piotr Trojanek Fix grammar in comment. gcc/ada/ChangeLog: * einfo.ads (Ghost_Assertion_Level): Fix comment. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo.ads | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 6fbb76d4de04..669696d4bbb9 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -1467,8 +1467,8 @@ package Einfo is -- Ghost_Assertion_Level -- Assertion level associated with the declaration of the entity. Its --- value is either Empty for non-ghost entities. Standard_Level_Default --- for Ghost entities without an assertion level or a user defined +-- value is either Empty for non-ghost entities, Standard_Level_Default +-- for Ghost entities without an assertion level, or a user-defined -- assertion level. -- Has_Aliased_Components [implementation base type only] From patchwork Thu Sep 11 09:18:52 2025 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: 120041 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 3B6B2385840F for ; Thu, 11 Sep 2025 09:31:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id C19AA385840E for ; Thu, 11 Sep 2025 09:19:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C19AA385840E 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 C19AA385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582373; cv=none; b=fdFCFtzf4+/gUkUoreBdrf3JtbIHC4TCugtxqK3/VbGMvfA8Z6wlcv2xqvBIZlWEpqdtp0k0+TY0dDVn81SfY4CVirn+QQo2TBwvsvzsXzN6v0SzwoODVy2vvGen/1mX+hiECOBbY36FGQwdXOzO2H2v2Sf5R9SGr0NzRRvKhMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582373; c=relaxed/simple; bh=MS8EWFwMW/wN3bVu5nf13svQm7L+2qlBTk628ndq5H0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fx6/TrrEMmyWzgfm5Tjssklqn3O6YcFLy//lGTIqEVc5BBPOXNfhAZHO8Fyz0BUqPKSXdAeTi/Qi2wvXC8mmMEwje1MT/4rl8znHdrUJLb8fhSqxwr0v2+bPKPNGe9ypFXaIH3Cpmul7XZ8L5/BdruXbd9ie0cA33wturJPXaf0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C19AA385840E Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Brgq/UMa Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3e7622483beso171279f8f.3 for ; Thu, 11 Sep 2025 02:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582371; x=1758187171; 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=Qmt9X60DoCwo8msoSkznyIVwpuBwnZQwQc21XGkZXow=; b=Brgq/UMamd3IWSGSeE8/htGpJqRxjbReslJhoX63f0YCropCbRgWLw+BQx/he5moG6 sTl15KFvw0Ms6bDac1VugGhO/0wq3abxGIB/CnBeWXk3Xlsisvb/HHfaOG4uysVW6K23 NaGuszbG+/Zq9n0cLpqx8RJQuWkxDQf9JITq32u7MoxaVVGM2aYCdVcFDil/L9UpXFld Zf3EH6vYoFOlmoV3q2fdIXMXN774QJ32N8cnWZGzSDikPxI+RPCVQ859N/JD3fEly1EJ 4/A821Nr7peO5Ge6rcK6i/QnEdFrQbgKIE9XLWEDa/yiIA4YbZqPaeeGZqNsxrH4KNsy PHoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582371; x=1758187171; 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=Qmt9X60DoCwo8msoSkznyIVwpuBwnZQwQc21XGkZXow=; b=ufs/I9vNLivN+ka4BeDXyROIG6Sx3rh247I5AIpxOSKfVBJUU691yFCrTtBu++ufg5 jMlwoY41Z2JJVjkSK4o0roVgVn7M5ni4vt7+7aL99CTVml5V6ViGbiy8SgGt45jsqK7T avAWH+SjJLqSJ5DrGP4u65yuSL3YNiWyZ81hkeV0Q8mARD2LbIhc8RQXP+Hk9geD1GvE /MbDxNKGIofvWIX3YGACoYuZmTwHQceC2IpzgFsPn8cCt5sOzo7pdnoJKAuzq1j/qao1 Zr+LPPHMduAiArQ3CMvpF9U8LSpkiPs7tdnHoF4FGVp3pBu9avUNwUIjA/F/DLxtSr0B YNMw== X-Gm-Message-State: AOJu0YzlUKRpncl2GTjr9zZjyoLP2fax4V8A0/I5CGkzPkn955x3jiPM 4R7CxXr529ehMRXB9yBog92ItQWu+LqvfqHZC/urWnIBE++MWzGOX3M7IArHxHnhH49zSQQ/RHF u3Fo= X-Gm-Gg: ASbGncuKp8RIdoCILMrwnccAw5nv6F3KGpGKuKgbRHR8WVQod89ednmZZ3Ns/LsN16t ixVhCqmnBbRt5KXjoSlB4pE70g1gVWU8+N5TsEbQcvqIy86SBbO4TtF5yue0boWlJc9Zoau1oQN LVS5DKuUAF7h/a3G3hSzbQvW3mxwK2G0KOq1FTEQu/YXtWK5BAVjaFg0NyrBZh4QzcZZ37uW99L eC4gxCounxngzpKaYkQ9hhnfpMz+NShvzCDaBIavZTtOr2gT04uO0ySunGu2yzRnE/KpBg7Zy/x +xU11WRm9TEOF0SayiNYi34pRKe7hmfPj07uPP94An/SHwuAWY6mC0O77GAMvwsO96pp1WbSlVG UGqc67my6/gq3ifzrTbRAl+1mgo8/XCKUNLKFXiY+KnuKIZKkBTKjgE1m2ZKjOznRxUHXSKq1Pe ZqtvwnCjIlEzp1Oo9fpRBN67vabUbHPU6vdY2lHwgQOpF8H/+R X-Google-Smtp-Source: AGHT+IEV9LWgstjJFfCIN07FoXd044kSCO5AnpWZ1wOEOONjwV+RG8cHBOXcgUZNPXMYL2zi17lVPQ== X-Received: by 2002:a05:6000:40c9:b0:3dc:280c:5f83 with SMTP id ffacd0b85a97d-3e642309219mr19172081f8f.5.1757582371440; Thu, 11 Sep 2025 02:19:31 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:30 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 20/31] ada: Check ghost level dependencies inside assignments Date: Thu, 11 Sep 2025 11:18:52 +0200 Message-ID: <20250911091904.1505690-20-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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: Viljar Indus Check that entities on the RHS are ghost level dependent on the entities on the LHS of the assignemnt. gcc/ada/ChangeLog: * ghost.adb (Is_OK_Statement): Check the levels of the assignee with the levels of the entity are ghost level dependent. (Check_Assignement_Levels): New function for checking the level dependencies. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/ghost.adb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb index bc646b22fbe5..0fbcf20da7c1 100644 --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -515,6 +515,10 @@ package body Ghost is function Is_OK_Statement (Stmt : Node_Id; Id : Entity_Id; Call_Arg : Node_Id) return Boolean is + procedure Check_Assignment_Levels (Assignee : Entity_Id); + -- Check that a ghost entity on the RHS of the assignment is + -- assertion level dependent on the LHS. + procedure Check_Procedure_Call_Policies (Callee : Entity_Id); -- Check that -- * the a checked call argument is not modified by an ignored @@ -528,6 +532,39 @@ package body Ghost is -- Check that Call_Arg was used in the call and that the formal -- for that argument was either out or in-out. + ----------------------------- + -- Check_Assignment_Levels -- + ----------------------------- + + procedure Check_Assignment_Levels (Assignee : Entity_Id) is + Assignee_Level : constant Entity_Id := + Ghost_Assertion_Level (Assignee); + Id_Level : constant Entity_Id := + Ghost_Assertion_Level (Id); + begin + -- SPARK RM 6.9 (13) A ghost entity E shall only be referenced + -- within an assignment statement whose target is a ghost + -- variable that is assertion-level-dependent on E. + + if not Is_Assertion_Level_Dependent (Id_Level, Assignee_Level) + then + Error_Msg_Sloc := Sloc (Ghost_Ref); + + Error_Msg_N (Assertion_Level_Error_Msg, Ghost_Ref); + Error_Msg_Name_1 := Chars (Id_Level); + Error_Msg_NE ("\& has assertion level %", Ghost_Ref, Id); + Error_Msg_Name_1 := Chars (Assignee_Level); + Error_Msg_Node_2 := Assignee; + Error_Msg_NE + ("\& is modifying & with %", Ghost_Ref, Id); + Error_Msg_Name_1 := Chars (Assignee_Level); + Error_Msg_NE + ("\assertion level of & should depend on %", + Ghost_Ref, + Id); + end if; + end Check_Assignment_Levels; + ----------------------------------- -- Check_Procedure_Call_Policies -- ----------------------------------- @@ -619,6 +656,8 @@ package body Ghost is if Nkind (Stmt) = N_Assignment_Statement then if Is_Ghost_Assignment (Stmt) then + Check_Assignment_Levels + (Get_Enclosing_Ghost_Entity (Name (Stmt))); return True; end if; From patchwork Thu Sep 11 09:18:53 2025 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: 120049 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 C2BB13858C62 for ; Thu, 11 Sep 2025 09:38:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2BB13858C62 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=CHYhZ6u1 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id A6BD13858420 for ; Thu, 11 Sep 2025 09:19:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6BD13858420 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 A6BD13858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582373; cv=none; b=xX9u8dNdeCFVnvfPZW4cLGo8FVExuVL5C5cHn1NP6isKuTk0zycknZ4GKNvEEYN9NWbubbTDkx1pc7NGlb5CzZ8yIunSccro2WgTHSguItnUknf3WVUefUieXmPPto8hgiDLtfw/CY+Zo2oJZC1OUq2s0eOyGKyXLKRu4H8j8GU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582373; c=relaxed/simple; bh=cUl+cah2oiowfDIhpUs6axPgjxYM80vEjuaQDit7z8w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lKICnZaXWVW87qfw/KrV4d2nB6CAtTdSI58y2TicN0NCKzYJLiwOgc3ndR5Jj4Gdz3eJR9AIZgrHWI2Ye6sUJcl58hX/h3VtIDVCrgXvcWeAtMq0RPHzTiW2/JbLBq7fk3vjKRss8lxcIo3RhPTd2l1pKNjNj6FEiN9fbZaNRGU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45ddc7d5731so3422635e9.1 for ; Thu, 11 Sep 2025 02:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582372; x=1758187172; 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=+r7Hr+eLWhb+IfppmiIMxQqlEMcK7gVyHpWGhH5i6lM=; b=CHYhZ6u13jtNzjsJIatpVcKeQbYIM0lqOv88eOW8hI0N6ypXKxlhdJsssKQzG8mK2W 8GE3B0golPIBUi1MSSrvxFCkVFV07RtBhHhsnxGgXVmT5L/E5GXBHQauLTnSk3Bs8e9p WdEnbLqSkVo3BLrlNI5ViurJAGsqDAO98jvNwOocGcAdHFbeJTnklFhaPKrNOtiRZhnG pvaRuuaj03shwkN9Y2pGV/clImfn1f6DkK3P/DgJO7MniSL6ALYyPtF6Ro7HGseqKRad OoOPQbvK74xCy0MEim8veRxSyMWN7Z7kc44MfR3bgVURBHVifv4Sr83LMD86paAhVOQm +odQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582372; x=1758187172; 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=+r7Hr+eLWhb+IfppmiIMxQqlEMcK7gVyHpWGhH5i6lM=; b=vt4xiYHPNkbhBMOMNtes795wTe+wne2/pvFccsb0L/dIBxHyUMz0XpJkCWR99WTROp GA4nPz7uIE29JUynWgUwGUKF38KWLJxzcylqp+Z+AqNcYxDT5umXiZt8NjNwujJHVLay 8Y96/LDAkK1ZocnwExnTc1mI9uiagxiAvALU2JTZaLAF0uvXWBXrHV44TjCeXF4A90aM AMgPXZsdBhfiRBfa6Usd+qdTbSBPuI/S791Cp3GaBW/ySgk/SEgUncAtEAn68LzK6jR0 NCr7VTGp5gM1rEMLgZla2mzASW2t/fG+o2XHmARP3L/qx4aNPj0OzWRufaABbSKC9aSU EB2w== X-Gm-Message-State: AOJu0YxtVHeeLWVTPZr1akdsuBWe9R5SbxReu5ui7WCGY4727clHlSnN 3UF7v9+NOPAnKABe4dvG12Hfl6fxedc5x9kt87WTbiz01tgdkoGdIfsXeG88q7XUdjMQJk+A6A9 /slk= X-Gm-Gg: ASbGnctK2pCy0fl0Je4EtMmzj5jwWtep9FgQqOpxWj22EJWK5uJtWkgcXiHpqHOL9qP cXhKvbPOKOwFXIP74uLhVWcWybBnnZEVj5W9P5JUlxV0pZyb5HsCOU1yDUFVyiVL4M+u7C2UFKg kv45d5xYO3TAamY8vsfrCcD+ffKvPBWyxc3tKKy3Efp9aX1NN/Vh0Bon5Ur2ivKBQ7zTKGMGDej wju47qWG078GW789pma27gMLrgCWLNLJVk0R/k23WcQuk6USDAT02n9aj7TnUnwD2Aj1AiFLDs6 AHjd3cYsTf2SW2/vc70ztkWj6gNx+gtS4Ue0y3/IHVIHCO57joR75XJotek5f81aR8385ShA0Gu rulyP1cAtW5JKUi+gZe2+dSUkSgj/GKIymEXiCzRKK+7yMo8YomzQ1+00YGFKBi2Y0s7xszSfkK UtQr/H38wVHOdp1OOxqBslRN2RkKk4MQTusJWuFw== X-Google-Smtp-Source: AGHT+IHLVIsQdqUJuBIknBJSx9pgT1A+EWHmMsb+FON6Xz4HGM3zVsROMAyjKwmpqXnQ28Cq0DIuhQ== X-Received: by 2002:a05:600c:1f14:b0:45b:97e0:22a8 with SMTP id 5b1f17b1804b1-45dddecda9bmr159352115e9.22.1757582372272; Thu, 11 Sep 2025 02:19:32 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:31 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 21/31] ada: Ignore ghost policy errors inside aspect Iterable Date: Thu, 11 Sep 2025 11:18:53 +0200 Message-ID: <20250911091904.1505690-21-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 It is OK to define a checked ghost type with an iterable aspect that has ignored Iterable functions. gcc/ada/ChangeLog: * ghost.adb (Check_Ghost_Policy): Avoid triggering a ghost policy error if the policy is referenced within the Iterable aspect. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/ghost.adb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb index 0fbcf20da7c1..0918d27daeb7 100644 --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -807,8 +807,28 @@ package body Ghost is ------------------------ procedure Check_Ghost_Policy (Id : Entity_Id; Ref : Node_Id) is + function Is_From_Aspect_Iterable (Ref : Node_Id) return Boolean; + -- Returns true when the node is contained within an Iterable aspect. + + function Is_From_Aspect_Iterable (Ref : Node_Id) return Boolean is + P : Node_Id := Parent (Ref); + begin + while Present (P) loop + if Nkind (P) = N_Aspect_Specification then + return Get_Aspect_Id (P) = Aspect_Iterable; + end if; + P := Parent (P); + end loop; + return False; + end Is_From_Aspect_Iterable; + + -- Local variables + Applic_Policy : Ghost_Mode_Type := Ghost_Config.Ghost_Mode; Ghost_Region : constant Node_Id := Ghost_Config.Current_Region; + + -- Start of processing for Check_Ghost_Policy + begin -- The policy is allowed to change within renaming and instantiation -- statements. @@ -844,6 +864,14 @@ package body Ghost is Error_Msg_NE ("\& used # with ghost policy `Ignore`", Ref, Id); end if; + -- A ghost entity E shall not be referenced within an aspect + -- specification [(including an aspect-specifying pragma)] which + -- specifies an aspect of an entity that is either non-ghost or not + -- assertion-level-dependent on E except in the following cases the + -- specified aspect is either Global, Depends, Refined_Global, + -- Refined_Depends, Initializes, Refined_State, or Iterable (SPARK RM + -- 6.9(15)). + if No (Ghost_Region) or else (Nkind (Ghost_Region) = N_Pragma and then Get_Pragma_Id (Ghost_Region) @@ -853,6 +881,7 @@ package body Ghost is | Pragma_Refined_Depends | Pragma_Initializes | Pragma_Refined_State) + or else Is_From_Aspect_Iterable (Ref) then return; end if; From patchwork Thu Sep 11 09:18:54 2025 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: 120047 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 BC726385840B for ; Thu, 11 Sep 2025 09:36:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC726385840B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Gm3URa83 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id A50503858C53 for ; Thu, 11 Sep 2025 09:19:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A50503858C53 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 A50503858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582374; cv=none; b=gg6p9ZhvTnww4WrAvs3/g1XIcvRVf6Rynj+UIcHZfgPYsNsWgwySmki0alxdfLLwLHSmVYATJax7Kq4KAIBpyU2BGpTvUHQqHKBJB9D0qsBLLqjsw21r69sZMR+BWNEbfm1EGTyRNvvNNpi+/QnebIKRwfPqr7SsABzPRPCgfPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582374; c=relaxed/simple; bh=agMRg5Y/vqJI++kojMu2gsSg/BzTkZ66iZQwlLZ/BLU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dbFa7tAfXua31jPEi977urn4DTCoNcutbBzpDognl9x/2iqWU4rLsMXsGuVIxGZEogUXOdYLsRwIYz7MfpKmmfp1g0JewjjxZvKCwvBkSVcFe4pXmNnHn476VsM4SCaoa/2g372wnEH4vWAS4Mca1pVQ546Afe45NA5xqT0WZLs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A50503858C53 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45b9c35bc0aso4656945e9.2 for ; Thu, 11 Sep 2025 02:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582373; x=1758187173; 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=/Ldrv+fUPNimv9GFQubsA67l/p8Iwq3D/x5izCeO74A=; b=Gm3URa83+f5zatc0p3PecPT1rXZya8UxkRxlvtfxLPktGwHT2YwMSGpUrfk7/0cTQ8 wU7byC7IGvXImaDp89q4HL3Pkl/WvZCM9esm554KAC1l6nJIdzq2lW/q88rP2Toh3vcA 3l0vPhQt+RafiZ5gZSU/MMpYJlnv9qlnsH6mVa04wLhKMMCgt+FyyE70tuk3DX4Flo4x k9BTAMAhY+qymU46o3GkyOa/9QnsYWAQGCdszAGnkaB2KG9k6hNwrQrcQlYG4QW3T0SN uuofjw/+c3StJyBnn6W342xYCZbqyax2TdE1UQcTatjfXYl4XlE9IAQGFpa1APKOgj/8 ya7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582373; x=1758187173; 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=/Ldrv+fUPNimv9GFQubsA67l/p8Iwq3D/x5izCeO74A=; b=gIF2HCU6CP1eDdrh4swxufW4EjiL88ok87BHl+9xH98388Po6E8QlACx2NSZWXv1ek 7pI2GjzbANkL8iYGmB5dJfp4X8/spBUY2QCrtvcJuz8VbQh9+w1KnKLE4p8QkPnOIk6b dGfo9vn9BTyqLb6Y2bMbh3CUBnnjrb9G85oMifBS/Sue3jz6Ug7j92XiyKbottztS2P6 uOsauCjA7S9JWMVY1jLpyp55q7Mf8dr1mxSYvNfYPBMsNbHL8PX87Xx6OnLxNlMCScIN uk6GbfSS3F7UwWtVs1ZTxvTAdqNmYHadmoWvrs0y6YJt8TW9MgCFfocIKFfXVYpk4rlD ul0Q== X-Gm-Message-State: AOJu0YwIlUhPyvpzTgP21ghgw4bfiQinJ8ULMAxv3y3jF/gqlUb8Zkhd AdpriiSp5oahrGJrfMT3FU+6BhwU9Ll3xSjEsz3+WPVV8ZuK2H3ByOcz8yokc0GCQ0ysG/PwHp2 EcJQ= X-Gm-Gg: ASbGncvJS0GhFxa2b95Lo2LieOuxbSOleGV6w3D33Df/iz7hI1XiFSQlJhon4xfpb6w 4EzM4fXZejaZTnXlhLWrNF8XBKU2b+uorot9sIvUF1p5dpjrJL1rz/AVa+N6VVg72AoNOr6V9fN EuHZGglcwxkWMhB3YNcqQW3+QotYfolA6H15KGd0/Q35f7kfyG3XfM9LNJIr7Wff8vAqmjf+7GZ DVeYbopzxt2BvPjq7DoQXIK/jKuKztieV55KiBaQlOUX+gSlia2HRFsGoinLpFDsXSI39EjSp5q gxj4iHzrrCxVCUyjJfMa2WqPlSMXTw8xfVfdVCJvfI7pnRLRnyI+qMWJ0I7x8udpNlX4K54Q5/N OKv3R1sLP98OAAjBTjCJ+pHAdTxxq8vJsr3PmHrpQU7EpPd44NKHfKvjQh7tkFA377h7xyeFDea 4/5hTtUyaf6j6k/CJX8VNZxsiWrMhWBZjdoUzv0A== X-Google-Smtp-Source: AGHT+IGHRQ9JJGd5wbwwdTapIzcCyejADxUolYjzvzQwv1SaiCgiMlViGTfPfOGnzXOmos/xoxRuiQ== X-Received: by 2002:a05:600c:3b97:b0:45d:edf6:367c with SMTP id 5b1f17b1804b1-45e41a18c99mr2763325e9.30.1757582373047; Thu, 11 Sep 2025 02:19:33 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:32 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 22/31] ada: Update coding style Date: Thu, 11 Sep 2025 11:18:54 +0200 Message-ID: <20250911091904.1505690-22-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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/ChangeLog: * ghost.adb (Check_Ghost_Policy): Update coding style. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/ghost.adb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb index 0918d27daeb7..4f1a0d9d6a46 100644 --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -857,11 +857,11 @@ package body Ghost is and then Applic_Policy = Ignore and then Known_To_Be_Assigned (Ref) then - Error_Msg_N (Ghost_Policy_Error_Msg, Ref); + Error_Msg_N (Ghost_Policy_Error_Msg, Ref); Error_Msg_Sloc := Sloc (Id); Error_Msg_NE ("\& declared # with ghost policy `Check`", Ref, Id); Error_Msg_Sloc := Sloc (Ref); - Error_Msg_NE ("\& used # with ghost policy `Ignore`", Ref, Id); + Error_Msg_NE ("\& used # with ghost policy `Ignore`", Ref, Id); end if; -- A ghost entity E shall not be referenced within an aspect @@ -886,13 +886,12 @@ package body Ghost is return; end if; - if Is_Ignored_Ghost_Entity (Id) and then Applic_Policy = Check - then - Error_Msg_N (Ghost_Policy_Error_Msg, Ref); + if Is_Ignored_Ghost_Entity (Id) and then Applic_Policy = Check then + Error_Msg_N (Ghost_Policy_Error_Msg, Ref); Error_Msg_Sloc := Sloc (Id); Error_Msg_NE ("\& declared # with ghost policy `Ignore`", Ref, Id); Error_Msg_Sloc := Sloc (Ref); - Error_Msg_NE ("\& used # with ghost policy `Check`", Ref, Id); + Error_Msg_NE ("\& used # with ghost policy `Check`", Ref, Id); end if; end Check_Ghost_Policy; From patchwork Thu Sep 11 09:18:55 2025 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: 120046 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 4EB793858C41 for ; Thu, 11 Sep 2025 09:36:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EB793858C41 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=am8QAL+G X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 4837D385840B for ; Thu, 11 Sep 2025 09:19:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4837D385840B 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 4837D385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582375; cv=none; b=fnC0MlggEjtpT0iN8k8STO/Ws0yJLjyBfhHdVVuDjk/Qf1CSbdnaNni3L3jiSwOied+cKAG8Ri5VTyaW6msSeZVhrN1ZRKaF2miMU+H34I5YPt1RKBB2QhzTWBt1HsRRkE2EaI+jK5qq0QpT6QlLgBOGGewIEfwvdwAEl96pBlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582375; c=relaxed/simple; bh=mzBwZy8griOK1rC0TjwGG8kS08cD7vQ6Fnb5UCozWgA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UBwrJ78d47QmeNOVEDDL3lRQpvY8p4j7mI2ldJDZXYkjmA4JJ/1M/PJTpz4ei8a92zfgrAnRqOysneUuRgQ3QQry7IHrsI7W4KkBeZb062i52OLlKAObuQuzVLd8noz7JkohtI4njXqwyWv3xclk0iV5fTTIRZ7OI1eb5W/TDBg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4837D385840B Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3b9edf4cf6cso427376f8f.3 for ; Thu, 11 Sep 2025 02:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582374; x=1758187174; 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=cwZV3jS76NBIPI0yxIkhlGiTVbLP4OLARJSSn/qS65U=; b=am8QAL+GKHFTNpmRGoGPIjOYpP9vro21mv/i/YoXAPHynRVL9IrLDmjk2j7Tn00u1s M/ELlCXzPvR1bsuW7K5qcVILhjDKjX7iqxVJiVK5dXTa+Ifkc5w6S1R9sn3ffcAWKzTQ Q1jBj35n0/7UJDb6eNWd/A5ggG2mPf/gJ6ThI/Lb5Cb+uh7kvqlxvY9nNwTL8xxQUhn9 aJzgrvpDkHRwefPI69MIpQBUqVfs6hdfFaCCE7QPnq2ZDNZsnaEMMQUdf6gnC8HjVZDn hZ+TXvbNh58ERs6FRUHGWIHpkUIlnxgLnHfBkmKshRfMlHQUZLd8WOORjetoWJgB7Nqx ijUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582374; x=1758187174; 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=cwZV3jS76NBIPI0yxIkhlGiTVbLP4OLARJSSn/qS65U=; b=rHDc6LxSZ74hOq10Gb4XkHz1rA69Kaqpel/UTFBkmui5AaW0yCzCh8q4CMAO3PyVTf 6PEH9qxFgoD1cDMF4lY0fbkuNtpxJ/qjbBd+YpC/iiBLc0u8weXVpwHl5gKSjKlO4snI z8/XhYN7V0WtgFGejPgtCY+UL6yegmLGJ1ieJwrU6wP375gMJ9dWTJWRvep3rj7iuauI KyfUZj6tvl10xNa3RfuGoldlnCZvh5EypgOy0sN+6j/RuMIgqnLJREbCuMKg4Ehr2zZu QqM15stZHR4OSaPFvGtjdCxsh9PoEHkmHXrSC8YMh4kNbYp9ICIcL5wah/5bTGMFeJtd hRew== X-Gm-Message-State: AOJu0Yw84dqJKWdfRalL/EdixMLFvPZ8GHWyzAV2+noXUABe543yBg7+ myhPA7kiqD3RODuUyp3fpTDQfXmi5eU8Gi6OKCQIVYtP2XPsAdp/j+MS1NhYKRRRNw5Gq484Yo+ lXVc= X-Gm-Gg: ASbGnctNPyy/v6G5f04OTVSuewl1xLWeMl9FVPUfSm/uS30HKkSg5UlR7fS9X/t9hWy 03oL2Fb+5rMFb2ITUP9IrBLEcU4dDqORFNIkah8DCOg8uvFgrTmaUXkTSDd/MngCfqhvIiUVI89 A+wCWRTxIoWACM0LE8E2Rj86aF7SdecnardSrHuf0L39g+cMa2XP2qIB/o+cQ516mc3NqUpSQUd 5tg0MNaglnZVIZqN9jCBD0G8c/NQ4G/TXLWJ0JABK27HYEJ8He+xhVIJKAr5uoAf4lGraH3MGVR zTXWw0cUdI0WeYb3zmC0OBCj4szcxPoQWFNTKjyr1bzvhH/IzgtXdeH413i2IUwlp2SpUQIJ5mb x1EUB0OiiSY3SQREVL/58/S4kFPI8oZtmEKMuBYm6tpsq2eyTqN4q63khqWp55nlvDAvIetPFEk wsiHC7JiCUMLF78yFqSOeX43BfVV4nJgG+KStLzg== X-Google-Smtp-Source: AGHT+IEPXbvdhhPmPa22O5ekG1xdp46BZNuqbgBnxEb0si/g7C886geSTJkaxR/MGZOViry85+dr+A== X-Received: by 2002:adf:e64a:0:b0:3e7:61f8:f5e6 with SMTP id ffacd0b85a97d-3e761f8f871mr751736f8f.38.1757582373771; Thu, 11 Sep 2025 02:19:33 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:33 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 23/31] ada: Check instantces of ghost iterator functions Date: Thu, 11 Sep 2025 11:18:55 +0200 Message-ID: <20250911091904.1505690-23-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 Since we do not analyze the policy errors for expanded code we need to check the functions specified in the Iterable aspect whenever we are analyzing an iterator spcification with that aspect. gcc/ada/ChangeLog: * sem_ch5.adb (Analyze_Iterator_Specification): Check ghost context of Iterable functions when handling iterator specifications with an Iterable aspect. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 1db5b75acbe3..a767ee0b560f 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2160,7 +2160,10 @@ package body Sem_Ch5 is Loc : constant Source_Ptr := Sloc (N); Subt : constant Node_Id := Subtype_Indication (N); + Assoc : Node_Id; Bas : Entity_Id := Empty; -- initialize to prevent warning + Iter_Asp : Node_Id; + Iter_Func : Node_Id; Typ : Entity_Id; procedure Check_Reverse_Iteration (Typ : Entity_Id); @@ -2870,12 +2873,9 @@ package body Sem_Ch5 is -- in the container package. We obtain it by name for a predefined -- container, or through the Iterable aspect for a formal one. - if Has_Aspect (Typ, Aspect_Iterable) then - Set_Etype (Def_Id, - Get_Cursor_Type - (Parent (Find_Value_Of_Aspect (Typ, Aspect_Iterable)), - Typ)); - + Iter_Asp := Find_Aspect (Typ, Aspect_Iterable); + if Present (Iter_Asp) then + Set_Etype (Def_Id, Get_Cursor_Type (Iter_Asp, Typ)); else Set_Etype (Def_Id, Get_Cursor_Type (Typ)); Check_Reverse_Iteration (Etype (Iter_Name)); @@ -2884,6 +2884,25 @@ package body Sem_Ch5 is end if; end if; + -- Validate the ghost context of he iterator function used for the + -- iterable aspect. + + Iter_Asp := Find_Aspect (Typ, Aspect_Iterable); + if Present (Iter_Asp) then + Assoc := First (Component_Associations (Expression (Iter_Asp))); + while Present (Assoc) loop + Iter_Func := Expression (Assoc); + if Nkind (Iter_Func) in N_Has_Entity + and then Present (Entity (Iter_Func)) + and then Is_Ghost_Entity (Entity (Iter_Func)) + then + Check_Ghost_Context (Entity (Iter_Func), Parent (N)); + end if; + + Next (Assoc); + end loop; + end if; + -- Preanalyze the filter. Expansion will take place when enclosing -- loop is expanded. From patchwork Thu Sep 11 09:18:56 2025 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: 120052 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 184F33858419 for ; Thu, 11 Sep 2025 09:43:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 184F33858419 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=UQN/zGZ7 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 12A433858419 for ; Thu, 11 Sep 2025 09:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12A433858419 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 12A433858419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582376; cv=none; b=QyCRocF6Ehk+slh0vUXdnB0x4nnq0AXi3KJPxh84kvjDESf1qInY+bN2YKnBL1gVX3PD0DYnkOUQ06b7fD6oyX2kMyx+Sgyi4ht3JbxyqKm+T6Zro4VUweGNR9wrnUqAoe2F/BHWF0lfI7s52wALQexK/UQD4ztjojk8MmmWkOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582376; c=relaxed/simple; bh=NE/mEc0bp+sLRJrKNK71IDfIMo5/CvlozQ8cPskqlCA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=m2ngJ/93HxsD8hDPXYYIMGLik8mHW6b7jqvQEyOiBgyelCqLOkb3p59pJUOaLbu9Cn08KLmqqXT3N3Mh2AMw5Dj5bsmKcIoh7EYOJTHjaONn/lJ8mRUbWjwfn621H1SD8ZZvviJqGDg6Xx/m8Ix4ZpdmR7utkRaULPwEjFPbyes= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12A433858419 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3e46fac8421so473250f8f.2 for ; Thu, 11 Sep 2025 02:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582375; x=1758187175; 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=81/LNXW775XUwASdFxzolRHnYpIlobfYC6ZDXaFemsA=; b=UQN/zGZ7hVUeM6H0SexXDJeFu9i92DZg8nBEEnIh2kJr9ue1W/MSCbAMHYaafbupBT 93Ga/zzYgxveF/FMTKe5n+WhVyO/E/HFnPSx23iEwrhmjLhibzxYwgmmo5GqLYvS0zeL sd8fC+gEQ4Ip9kI0U3lcD/CiANZ76ISNTJz82ebbvrf3BHyvKV2siWeZcRYM6Jbbpf4H lwuNoIFFua3U9hUYncFzJzCVA7kpljibH9vuROlcVNyvFJ915Qhq9Ycepo7rL1q0kKY9 iMdERsdDl4jAsHGKAfGX2UzW9ADXX5BvQt/Rc1Hh7X2yWh+KgD+H2AQ8G+QyWAFG25p+ ERSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582375; x=1758187175; 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=81/LNXW775XUwASdFxzolRHnYpIlobfYC6ZDXaFemsA=; b=YKYIh4cc8XIRqElovgqsqCA9NveaLUplhPIHPtuvqftHZv5zLYlOpiS0M/uEot4HyV AJ6h1p/SXhNqdC8MREJ+7kq61oRllOVd5fAsfaY3aStcpHY3KQAZufLhmRuvncFPUNJH +cz+CrNjgYwVDxmokZuS2vcyruRCyIA6ccNwVbCqohZzeGTDFbdC+6XMDX9jHRJAdSVk rXg5zp+UGMFwoVRxZg0/fVa6Q7gvChKJ1jbWX2wForgHq3pTrAlP9chLcr5/iQLnyq8p 76iI4agj/4wmEhk3K6+ce9R9LwmMO2qSQWoiZuzZdqLER6TNlWn11HWsG8VBfzDgWEhd EHGw== X-Gm-Message-State: AOJu0Yzpl1Vkp1vUNoAiZw9Fwp1NyN89KaWYjWt0pUQmwIZxHFINnT5F GAdF7VE9/2qHpd1lIJwEXwVOBe2goVDuEy9wYbPFpiqU5XnmpJW7O+rDWfqJzJ6T+/tgWUlFbuk 4cGM= X-Gm-Gg: ASbGncsejYZmfqP0PQptaqNYpO8bd2Vav8wfd+ZuzuKDqB3rKdULf/bbQjhOjjwVY5l MCU3irf5LsXWfbY9fRPr4rLTo+mJLAme1P3HsufxMJOa2Bf1Zt8AlVcIcH8BFqeHsIMe5euqHDs 1jGL7rdfI+DQT7I42yIjwEgiTaZKAdTE+dlF5PQX/FihL739aWKOni/9jYuTw86KNScZmbMVTUZ DeLlOTRhubMUvYzt5Ra1UuLgu0krTaZ6R1FXlnelUFnmtJbh+DZMOlvz9t2kPZTjf6th19Yyc62 0BRcd9z5H38oPgi3NJBxVDShH2AdcvISBTY+xkXjyNt6lYiTOFqR1lY2fwNh+IxgtDhOgUNB3w/ 3kczZAbvS78pPRmYe5NK7IW8zP9I251fzQa+KDEIqYQxflicIuVmG15VnGGXrzH0mS47ig1oJtl YZUim44fDAoTUbA5BC7u97+NsKyGqfIXsVlysXoeqUKm+bzn+b X-Google-Smtp-Source: AGHT+IGDF7KsEcy+t2zX5vr8r0mOi7isyCswbAaZExNOpHEXEFUZ1JA4Q2tQMF11rHoT4z7EcTq4ZA== X-Received: by 2002:a5d:588c:0:b0:3e2:9a5a:1f38 with SMTP id ffacd0b85a97d-3e64c692464mr12948180f8f.50.1757582374692; Thu, 11 Sep 2025 02:19:34 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Viljar Indus Subject: [COMMITTED 24/31] ada: Create a ghost region for pragma annotate Date: Thu, 11 Sep 2025 11:18:56 +0200 Message-ID: <20250911091904.1505690-24-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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: Viljar Indus Create a ghost region for pragma annotate so that we are able to analyze the entity references correctly inside the pragma. gcc/ada/ChangeLog: * sem_prag.adb: Create a ghost region for pragma annotate before analyzing its arguments. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 753ccda66756..661d4401d7a2 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14149,6 +14149,9 @@ package body Sem_Prag is Expr : Node_Id; Nam_Arg : Node_Id; + Saved_Ghost_Config : constant Ghost_Config_Type := Ghost_Config; + -- Save the Ghost-related attributes to restore on exit + -------------------------- -- Inferred_String_Type -- -------------------------- @@ -14226,6 +14229,10 @@ package body Sem_Prag is end if; end if; + -- Set the ghost mode before analyzing all of the arguments + + Set_Ghost_Mode (N); + -- Continue the processing with last argument removed for now Check_Arg_Is_Identifier (Arg1); @@ -14271,6 +14278,8 @@ package body Sem_Prag is Next (Arg); end loop; end if; + + Restore_Ghost_Region (Saved_Ghost_Config); end Annotate; ------------------------------------------------- From patchwork Thu Sep 11 09:18:57 2025 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: 120053 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 6CA473858C30 for ; Thu, 11 Sep 2025 09:44:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CA473858C30 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WVG9vnm/ X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id D06373858421 for ; Thu, 11 Sep 2025 09:19:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D06373858421 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 D06373858421 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582377; cv=none; b=GZDpH0h8fvZ+NhwwBqn101Saq8K0P7pMnZXzoLrJR0AySIKifHF2J7TTUodh8Rm3uf7k6pdfUPq0rkNhqZgcqJH5qFjX5BqHsNun3orTwD3nf9dNdCkqPEqpCKdPT/FvYPLJUQ/nk83TQz+n/56FQ0fG0YB/dNIKMmuSFBcT1Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582377; c=relaxed/simple; bh=IpAxEjQuu2rXLLorP7DI0Psbk0B810ga47bb2LTfq1c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZZDGYR6JKIZpuqcvxxftdGExU0/SjMwM0cBzk08x6/4y8oUopA2ll+UCv+letl3p9TarziZIjYbDrG6IIUsBc0gxnJFKrt3lh4OStl7P/Jdn42adqtpkEcRSW10rMEPvEA3bfvktq+loDLnlpCnXVRASmnkvgn3cQ8MvtIBU/Ng= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D06373858421 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3e7428c4cbdso363374f8f.0 for ; Thu, 11 Sep 2025 02:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582375; x=1758187175; 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=60ZF9IO4VoV8Gj0aF71IcKsYPG71AtX6hsAy95QL4cc=; b=WVG9vnm/r+vL8cNddpUPtDIpvng7HuxRLEmuSQBfWNnbkfkFxuZ8FG+pfMDqwoz2GQ udHalkh7izGWVDWSznpZyuX7LJ28ZNkSEZRogmjMBTYZ39wHDE6uV4yOk2PSQuAf7daO KW5dhqU+KPGXUR93ZcyEuDzn+agEgp50xSHm9PvBdaM7abUVwlr2oRe1igLNhXInBWkH 7NT7iDOEAh2+ujpoOoF+d0lm4dE9pNDb6A79/SJv/O2Kix6IiJw15foj1JaJCozUuG1o mYlBroKO1/8iXTNMdlcGe5x2Um4ee5kTs2TtSWEUxzhdrMzI7exPplWZ7ZQbmjnd2Sj8 2YRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582375; x=1758187175; 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=60ZF9IO4VoV8Gj0aF71IcKsYPG71AtX6hsAy95QL4cc=; b=FD8+cjW6xnonuJd7F9HTLgOv8d6Fzj0Yc7pH9L7yxtrDBeBvZQCoUdr9lyX20hl6vs wQ70n3qqUzGH4meblhcTqk4lEHESF0ggmK6J9wNKAmDcsvDqhZVwV7JCXxpzxe/sOCL9 Ydai8rRZNB2hyDhEVhZnK6hFFzf0xd1/kXK+ZJMN0RGwSKcggalZ107qp9jc6YBgGm3c 67ObinOdyB9rO1G2XAhKCyPXskeFqnELWksH1LMQx7JkbgQrBreD7ejhpkbezMKtG0ci Lhd+l5viMj7Dc/Wd3/aFUgN2DKzKB0CXeERsQHugElXZemjJQK6EgAOzlKPJ/pjcEw1m dd2Q== X-Gm-Message-State: AOJu0YzIxNb8HmvUfWB42WUMamABW+oVvNIwFQujKWaCCOGfyJrzZN7b YlHAbqVQIVuJXNL5ThkNJSjaOw0VY7MfGZ6aSMqUkm4Qq4aguXp7lPCubZbmkYeNHUgyuZPTihx UiP8= X-Gm-Gg: ASbGnctojq4gRt5tTr+8GoM8S5+WRwSZ8+U8vZJLiTpp9Z75PlBKW8Em3eWakPbt+go fTxETfBEzTJwX9MskbFwkUjB5BpN/Y+zsG5a+kVFSHVybwMMElAgkSZqMW9AQSumQ8pdVL0QwBG kWrQnzq/wht7Uy5AnlRoPYxIUEizdkPIwCRDVqLwz8kyAkFmMhsV+TNBNHKFCaz4k7VZPzXaRb0 DUZ0BNllPKhczGEY4MNaNQ7I4T/+lQMKY1mj5VrXTAJhcxLw35FVsSVhF8K4SpIbvZ/FCLXAdk/ MfBiaGZ85yraGiKk1+ivAUgbA6JzT6XhKl5NkmDu1pFSsBPaEBXAEDl7h5IRBCp5c1CIzpf8Eex byw2HMi/l03JjAtQrq87QoLkh0k0WtG6dB0kgLBITHnQwNRM1+z/7e1k+yN7Of1mfXOZtMRJhLX 7/8gcmY5EKcJx2qaYQvYydhEvNz3s/X2/YfBrtLQ== X-Google-Smtp-Source: AGHT+IG+yguO1disAD/JQ0zlAyAj18riMp39UhXpIxpBSHKNWxq2FhtLY1c2LTuTdCBM1/cNGOr7sg== X-Received: by 2002:a5d:5d0e:0:b0:3cf:3f1:acd8 with SMTP id ffacd0b85a97d-3e75e10651amr3273815f8f.28.1757582375474; Thu, 11 Sep 2025 02:19:35 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 25/31] ada: Perform predicate check before, not after, parameter copy back. Date: Thu, 11 Sep 2025 11:18:57 +0200 Message-ID: <20250911091904.1505690-25-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Steve Baird In the case of a call to a subprogram that has an out (or in-out) parameter that is passed by copy, the caller performs copy-back after the call returns. If the actual parameter is a view conversion to a subtype that has an enabled predicate, then the predicate check performed at that point should be performed before, not after, the operand of the view conversion is updated. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_Actuals): After building the tree for a predicate check, call Prepend_To instead of Append_To so that the check is performed before, instead of after, the corresponding parameter copy-back. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 18551d4899e3..1a9002ce3a8b 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2946,7 +2946,11 @@ package body Exp_Ch6 is and then Predicate_Tests_On_Arguments (Subp) then - Append_To (Post_Call, + -- If Actual is a view conversion to a by-copy subtype + -- that is subject to a predicate, then the predicate + -- check must precede copy-back. So Prepend. + + Prepend_To (Post_Call, Make_Predicate_Check (Atyp, Actual)); end if; end By_Ref_Predicate_Check; From patchwork Thu Sep 11 09:18:58 2025 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: 120045 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 162683858D35 for ; Thu, 11 Sep 2025 09:35:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 162683858D35 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=LW1eD1Sl X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 353B83858D26 for ; Thu, 11 Sep 2025 09:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 353B83858D26 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 353B83858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582378; cv=none; b=cilwg4D3imxsg6k97hMHnx1SO826lLGsx8sOl97lLbKNlwy/IaAOCOE2GX1dJRAplyRmAvO2r++s588M3IbmPxKmH1QHp66v/f2Gibzm3O7eqR0zwgqNW+Fl/jZE9LNzHNXhK4+A2ujQKeFmkB6RLj2YKodxnt/hMFJvzkpG/04= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582378; c=relaxed/simple; bh=umsD82I7sVU5ENO2qS6XxpWSSGoMW6qxixR6mHKZGm4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=P22s5SufAyS9ibvO9KDiMImL3EhT90DCa8fX14jD1r0D4eH9egn/tT71YLnHc6iAXCpJEWS1Z4Sp5BLpkoLqAfM/EhOHGokP7cH/X8It9jlyvsmMINBWp/K3OqI85lyvDVPVA7PvXiu/9peJCFw6gzFijcLgT5z7Jz4sK2rV4eA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 353B83858D26 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45dec1ae562so4372035e9.1 for ; Thu, 11 Sep 2025 02:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582376; x=1758187176; 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=NfcLEfBL+DtCL3o6m7MKZE1fjoj6/EgedaNwLS9mbpo=; b=LW1eD1SlDhc05NEgYkN568lfo+PFv+eUj16Wt2/9HLFqHmKjPj5FWOrzls4+MGhiF/ bfCrDqFVXNr4PqX6ylrRTK1zgy9XyGHJk0cfJuDQs8Ai/0YR7yAEAlOJ/9KYGWQ8eO8S j4HwsZgrgCIh2jQjDclXoGUFR8OblznVh/N4lXV0hFISg4GSCl9eq8D7gV88y03XVlKE TDQdLEuSJHAZh9TF0S01Uq6xA15vgQOHniI/M0Dqq9RzqIQws4Ux9Y7ccg5uv00FcloE WRrqA+pbNC8X07Y7326WdWvPDeaWJfGbTlyfwEatk1c5kp7EdAOeJMKe7xAAVC1YF26C YHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582376; x=1758187176; 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=NfcLEfBL+DtCL3o6m7MKZE1fjoj6/EgedaNwLS9mbpo=; b=LZEC5ORGf9pr0+lkv3LcHc68enPWStFer106LoHPhof48HVFpHnNZk2lKM0LpYq3Z2 karNMVxzFR9YiAww+zDNqlCFgKRlWkChjiYf8iSAxc5nokpSn5HF1UUBJzA/2jsUlm9t 2Vq8xpLiVecjEk0T56WX3DBdx2ZRf+TYwYekzbdGV3UZiH0pjdDZGmvRwgdC4enf6ma+ LGW27eOsdZ3IOPl1EJ3d8cTr/nWijM8lUXsaLF30mvqC+YWxG7xT7Gmw10K8O0gJGDpS 9lEar9zi/jbUn47f1EqIMDztgR2rbGjeb3HYYQa6V4MeF5Q0Bq5NeaVYFKlxE8IPeLjZ Xs6A== X-Gm-Message-State: AOJu0YzFvaD3a83i2z0KU8ssZ9s7KybEraRoqJzpHW5LwrRPLzHCEwMq viGwJWJ2LsIkBDL3NAWsoi6kc6Hu+ZXwa5AEHDqA2HANX/WPMSFVDIdo0KSgIl6lk0lqiC19uSc IwHw= X-Gm-Gg: ASbGncsxLG8sJreBVUhL8StReOYXprGooO533mrCWSYSLzDvQ/6tmJx6v8A9Q30csP5 XBcQRHKqwCFiRNmQOPKLLn0H7rbrQwRc44Az5Vybnc9/qQEnr927U0dZ3xQMwvWxPfoBbUzg9WE X5WGMJZgvX0J0qTUpVl/9e+wfMARngKV86mEsk26Blzj1sukkLbrlg0Aj6FZnvhxotTYjPSD08u TGGgYzj83y/KNa4Zc4WbY037WTGd4e3i/DxbF0x7cfmFbTatOXdljXFTdh1TmRaiP+D70bO+sZ2 fsJ2Cho2ZaixzFvx+nzTwy896KshxbrZ+oUh849D9p7iFVoUlABmug3Pwv7d4GO0eO/JTnFwa23 EkfHBGk3Oz8aBRFa865lr/WPFf/sX0fSQc8AXkaUfFFm+9RCOdEyXAOKOVWhDH+mVrS90I4dHHi Oe9QEXVaHJwI4b4TsnT6O84ajUn5sKZagJYeLV4INkxj++FgWU X-Google-Smtp-Source: AGHT+IGpJHTPAJ6MoraGAiXjCTtUPe9LznOkI6mxFbhgzFwL97UmWMit/mBGzOKMfM76D8ClUNCjjA== X-Received: by 2002:a05:6000:40c9:b0:3da:d015:bf84 with SMTP id ffacd0b85a97d-3e64196afd4mr18385764f8f.25.1757582376318; Thu, 11 Sep 2025 02:19:36 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 26/31] ada: Implement overflow checking for unsigned types Date: Thu, 11 Sep 2025 11:18:58 +0200 Message-ID: <20250911091904.1505690-26-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Eric Botcazou The implementation is essentially mirrored from the one for signed types. gcc/ada/ChangeLog: * gcc-interface/gigi.h (standard_datatypes): Add ADT_uns_mulv64_decl and ADT_uns_mulv128_decl. (uns_mulv64_decl): New macro. (uns_mulv128_decl): Likewise. * gcc-interface/trans.cc (gigi): Create the uns_mulv64_decl and uns_mulv128_decl declarations. (gnat_to_gnu) : Perform an overflow check for unsigned integer addition, subtraction and multiplication if required. : Perform an overflow check for unsigned integer negation if required. (build_unary_op_trapv): Add support for unsigned types. (build_binary_op_trapv): Likewise. : Perform the check if the LHS is zero in the signed case as well. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/gigi.h | 8 ++- gcc/ada/gcc-interface/trans.cc | 103 +++++++++++++++++++++++---------- 2 files changed, 79 insertions(+), 32 deletions(-) diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 0345111fb85f..45b1bfd23e3a 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -388,11 +388,13 @@ enum standard_datatypes /* Function declaration node for run-time reallocation function. */ ADT_realloc_decl, - /* Function decl node for 64-bit multiplication with overflow checking. */ + /* Function decl nodes for 64-bit multiplication with overflow checking. */ ADT_mulv64_decl, + ADT_uns_mulv64_decl, - /* Function decl node for 128-bit multiplication with overflow checking. */ + /* Function decl nodes for 128-bit multiplication with overflow checking. */ ADT_mulv128_decl, + ADT_uns_mulv128_decl, /* Identifier for the name of the _Parent field in tagged record types. */ ADT_parent_name_id, @@ -455,7 +457,9 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1]; #define free_decl gnat_std_decls[(int) ADT_free_decl] #define realloc_decl gnat_std_decls[(int) ADT_realloc_decl] #define mulv64_decl gnat_std_decls[(int) ADT_mulv64_decl] +#define uns_mulv64_decl gnat_std_decls[(int) ADT_uns_mulv64_decl] #define mulv128_decl gnat_std_decls[(int) ADT_mulv128_decl] +#define uns_mulv128_decl gnat_std_decls[(int) ADT_uns_mulv128_decl] #define parent_name_id gnat_std_decls[(int) ADT_parent_name_id] #define not_handled_by_others_name_id \ gnat_std_decls[(int) ADT_not_handled_by_others_name_id] diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index fd1d39cd0f55..3c6e87e52c0a 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -319,7 +319,7 @@ gigi (Node_Id gnat_root, { Node_Id gnat_iter; Entity_Id gnat_literal; - tree t, ftype, int64_type; + tree t, ftype; struct elab_info *info; int i; @@ -466,7 +466,7 @@ gigi (Node_Id gnat_root, false, NULL, Empty); /* This is used for 64-bit multiplication with overflow checking. */ - int64_type = gnat_type_for_size (64, 0); + tree int64_type = gnat_type_for_size (64, 0); mulv64_decl = create_subprog_decl (get_identifier ("__gnat_mulv64"), NULL_TREE, build_function_type_list (int64_type, int64_type, @@ -475,6 +475,15 @@ gigi (Node_Id gnat_root, false, NULL, Empty); strub_make_callable (mulv64_decl); + tree uint64_type = gnat_type_for_size (64, 1); + uns_mulv64_decl + = create_subprog_decl (get_identifier ("__gnat_uns_mulv64"), NULL_TREE, + build_function_type_list (uint64_type, uint64_type, + uint64_type, NULL_TREE), + NULL_TREE, is_default, true, true, true, false, + false, NULL, Empty); + strub_make_callable (uns_mulv64_decl); + if (Enable_128bit_Types) { tree int128_type = gnat_type_for_size (128, 0); @@ -487,6 +496,17 @@ gigi (Node_Id gnat_root, NULL_TREE, is_default, true, true, true, false, false, NULL, Empty); strub_make_callable (mulv128_decl); + + tree uint128_type = gnat_type_for_size (128, 1); + uns_mulv128_decl + = create_subprog_decl (get_identifier ("__gnat_uns_mulv128"), NULL_TREE, + build_function_type_list (uint128_type, + uint128_type, + uint128_type, + NULL_TREE), + NULL_TREE, is_default, true, true, true, false, + false, NULL, Empty); + strub_make_callable (uns_mulv128_decl); } /* Name of the _Parent field in tagged record types. */ @@ -7504,12 +7524,11 @@ gnat_to_gnu (Node_Id gnat_node) gnu_max_shift = convert (gnu_type, gnu_max_shift); } - /* For signed integer addition, subtraction and multiplication, do an + /* For integer addition, subtraction and multiplication, perform an overflow check if required. */ - if (Do_Overflow_Check (gnat_node) - && (code == PLUS_EXPR || code == MINUS_EXPR || code == MULT_EXPR) - && !TYPE_UNSIGNED (gnu_type) - && !FLOAT_TYPE_P (gnu_type)) + if ((code == PLUS_EXPR || code == MINUS_EXPR || code == MULT_EXPR) + && !FLOAT_TYPE_P (gnu_type) + && Do_Overflow_Check (gnat_node)) gnu_result = build_binary_op_trapv (code, gnu_type, gnu_lhs, gnu_rhs, gnat_node); @@ -7590,11 +7609,11 @@ gnat_to_gnu (Node_Id gnat_node) gnu_expr = gnat_to_gnu (Right_Opnd (gnat_node)); gnu_result_type = get_unpadded_type (Etype (gnat_node)); - /* For signed integer negation and absolute value, do an overflow check + /* For integer negation and absolute value, perform an overflow check if required. */ - if (Do_Overflow_Check (gnat_node) - && !TYPE_UNSIGNED (gnu_result_type) - && !FLOAT_TYPE_P (gnu_result_type)) + if ((gnu_codes[kind] == NEGATE_EXPR || gnu_codes[kind] == ABS_EXPR) + && !FLOAT_TYPE_P (gnu_result_type) + && Do_Overflow_Check (gnat_node)) gnu_result = build_unary_op_trapv (gnu_codes[kind], gnu_result_type, gnu_expr, gnat_node); @@ -9959,12 +9978,25 @@ build_unary_op_trapv (enum tree_code code, tree gnu_type, tree operand, { gcc_assert (code == NEGATE_EXPR || code == ABS_EXPR); + tree gnu_expr, check; + operand = gnat_protect_expr (operand); - return emit_check (build_binary_op (EQ_EXPR, boolean_type_node, - operand, TYPE_MIN_VALUE (gnu_type)), - build_unary_op (code, gnu_type, operand), - CE_Overflow_Check_Failed, gnat_node); + gnu_expr = build_unary_op (code, gnu_type, operand); + + if (TYPE_UNSIGNED (gnu_type)) + { + if (code == ABS_EXPR) + return gnu_expr; + else + check = build_binary_op (NE_EXPR, boolean_type_node, + operand, TYPE_MIN_VALUE (gnu_type)); + } + else + check = build_binary_op (EQ_EXPR, boolean_type_node, + operand, TYPE_MIN_VALUE (gnu_type)); + + return emit_check (check, gnu_expr, CE_Overflow_Check_Failed, gnat_node); } /* Make a binary operation of kind CODE using build_binary_op, but guard @@ -10017,21 +10049,29 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left, /* Never inline a 64-bit mult for a 32-bit target, it's way too long. */ if (code == MULT_EXPR && precision == 64 && BITS_PER_WORD < 64) { - tree int64 = gnat_type_for_size (64, 0); + tree int64 = gnat_type_for_size (64, TYPE_UNSIGNED (gnu_type)); Check_Restriction_No_Dependence_On_System (Name_Arith_64, gnat_node); - return convert (gnu_type, build_call_n_expr (mulv64_decl, 2, - convert (int64, lhs), - convert (int64, rhs))); + return + convert (gnu_type, build_call_n_expr (TYPE_UNSIGNED (gnu_type) + ? uns_mulv64_decl + : mulv64_decl, + 2, + convert (int64, lhs), + convert (int64, rhs))); } /* Likewise for a 128-bit mult and a 64-bit target. */ else if (code == MULT_EXPR && precision == 128 && BITS_PER_WORD < 128) { - tree int128 = gnat_type_for_size (128, 0); + tree int128 = gnat_type_for_size (128, TYPE_UNSIGNED (gnu_type)); Check_Restriction_No_Dependence_On_System (Name_Arith_128, gnat_node); - return convert (gnu_type, build_call_n_expr (mulv128_decl, 2, - convert (int128, lhs), - convert (int128, rhs))); + return + convert (gnu_type, build_call_n_expr (TYPE_UNSIGNED (gnu_type) + ? uns_mulv128_decl + : mulv128_decl, + 2, + convert (int128, lhs), + convert (int128, rhs))); } enum internal_fn icode; @@ -10065,7 +10105,7 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left, } /* If one operand is a constant, we expose the overflow condition to enable - a subsequent simplication or even elimination. */ + a subsequent simplification or even elimination. */ switch (code) { case PLUS_EXPR: @@ -10085,21 +10125,24 @@ build_binary_op_trapv (enum tree_code code, tree gnu_type, tree left, break; case MINUS_EXPR: - if (TREE_CODE (lhs) == INTEGER_CST) + if (TREE_CODE (lhs) == INTEGER_CST && TYPE_UNSIGNED (gnu_type)) + /* In the unsigned case, overflow when rhs > lhs - type_min. */ + check = build_binary_op (GT_EXPR, boolean_type_node, rhs, + build_binary_op (MINUS_EXPR, gnu_type, + lhs, type_min)); + else if (TREE_CODE (lhs) == INTEGER_CST) { sgn = tree_int_cst_sgn (lhs); - if (sgn > 0) - /* When lhs > 0, overflow when rhs < lhs - type_max. */ + if (sgn >= 0) + /* When lhs >= 0, overflow when rhs < lhs - type_max. */ check = build_binary_op (LT_EXPR, boolean_type_node, rhs, build_binary_op (MINUS_EXPR, gnu_type, lhs, type_max)); - else if (sgn < 0) + else /* When lhs < 0, overflow when rhs > lhs - type_min. */ check = build_binary_op (GT_EXPR, boolean_type_node, rhs, build_binary_op (MINUS_EXPR, gnu_type, lhs, type_min)); - else - return gnu_expr; } else { From patchwork Thu Sep 11 09:18:59 2025 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: 120056 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 866403858419 for ; Thu, 11 Sep 2025 09:49:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 866403858419 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=fkkoHolP X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6912E3858436 for ; Thu, 11 Sep 2025 09:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6912E3858436 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 6912E3858436 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582378; cv=none; b=JeoHicy8omCuckPGYFQIpFbnBasMw81BjLr2vJhkQVirPr8RRgknN4fv0Japn97bTgUkrtLBFheERIKt7t1Cy5VS3YUWEPinoMGJexMcL7+1sS3tec6BE7VuQXKIc6ZLY170fswZ3yZsfGqtexBG1s/t+EPNzonxtCby00wLIFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582378; c=relaxed/simple; bh=iQqBg7KF/n23Zcpd2sq6LopHDyXkgCSpOpNkEqz3ukg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kV9DpcAazqFGGBscb2riJiGfkFZMY15rsR2kKMr1Nvs8LmdoBb+N0b/sbcOWLBH4E7/uw3WVycJjCgBUbMt8CLeMkU6NhPHelZyTHDRS0XqP0PwjoA5sFSbCnUXqqjDyqlrPihXZVSm+Ji9PmMTLLaBhAHOHYBh0NwcwgI8XHkU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6912E3858436 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3e751508f21so348971f8f.0 for ; Thu, 11 Sep 2025 02:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582377; x=1758187177; 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=w/HegwyxrHba9p4S8cejR2IGmjAaNyMkwqUEhyEw494=; b=fkkoHolPvr1Sa76GDAqEuW+xuqDwjzsKiUh5kGFsEaJhIY0n3BKCc831WtFeODwyKp 60vc/KEwhaArECkf+eFYqONH1gN0Ky8yD/ANhZZc7D5+HZu9a/MDpqUo/gQfiQxo4YtW k1fW/XpNY+rHnlSQ677UQTSRmEyyWKyNtHYIxhU+3gOxhZ2mCGqt5q4l5pPbOaR4a+ee ndv9Tp/QW7bjz1fbhHZhifUwYwKVAHKJ0zMhfn465NtNvp2H38K6YjHOmI3OfiJaOz0e nEhRR9MaudqCUbrnTAeS2QN8oi4v0gK5S49+Pn/1BhFRm7jqbz3p7QFV5h6hX9N+4TDe 40vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582377; x=1758187177; 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=w/HegwyxrHba9p4S8cejR2IGmjAaNyMkwqUEhyEw494=; b=fP1lDjooC/WxNSibHnMb0a4/MhqcbLXndi8lEB0Uj9kbGIY+oQFJG+VzKeq87URTBC oAaU3ga0QxvOlUMQY+K92XiK7k/yHkECXBuitS+FdESRRNE99KWun1KkPNaov4yYkZZb ofuTQuWsHPa38SAziwqUyZXhNPfmpIuBnRJWR0OUPUsncdm2zwyVht9X5JEEAZy9gYYM rtfnUpkAcFxiG83EFJkWzMSQTr17/1S1Vqst3drbWDFaW/sbOxXUWMYttgsTMoUQfkxC 8PqwK1TvB11sDQCZsqBnLPzfXw2H9NeWOxRlh3teiqLx+gMt8OYKQ+WP/oo2F+x4MhBN duFA== X-Gm-Message-State: AOJu0YzggDcy/eIR0cWo/9gGAaaPAYRLrbEP3m+bWWjVBdEn6KQtnmK+ t+swAq4qstG18Mo48Zx/9J7sqv/pS6UyQWkK1VsRNp2+JaUn6iKwg72W2Ozt+Wf0/vNjSLpxgSN eTGw= X-Gm-Gg: ASbGncvf7Za6KmV45izd9JqP6JFW+//Fnbf7hZtNtlqNi+JH72uW3/sgugmEi7SMgs+ yZGDEd2QIPQSkoQP8mlNvYVk3HiGLkf7AQL3+ELyPRFwrHcqD9508KZwsM2aH0LsyKLq5Fb8uy2 P7PymA7k4g/GzYQ3U0enonRZ9ycPMl9rQqmjk3fzDP5XrVJNq5DXZGWsYSrw8HNLRfOV+eHHut+ juDRMVjxNiXNOzbhbWBjwaw54ITj9Pvt3+an0qKq3RsVIHj+MLBsdWPWTusFNj8Qtb2R1UbHdxk d4NGK1Q2o7YDh5KUO4dLRyZRzztisIZ6eaGOY/bmbKPqMlON/e1OVrns7211Lt2wsqagqZyrSkY HfXF3c86CssEDNDPBRWkDvtURvn/JeXXuBSHXFTRSyV+Yi0QVnuBTzlvRsrCx9Ua5cD8HMQlKGL 8+lzpuAs+phAGwSyTbx/xR3Envy4F1KhYwdL25ZDKlZSy4N/w3 X-Google-Smtp-Source: AGHT+IEpDtW6xjt5hIjf6I5W7gDsq1l9YPZcKxXgWY5+1JQ2ejELKKU+hvB2QokDjzTIlorjK2pidQ== X-Received: by 2002:a05:6000:290e:b0:3e7:516d:9a7c with SMTP id ffacd0b85a97d-3e7516d9d7dmr8220598f8f.39.1757582377073; Thu, 11 Sep 2025 02:19:37 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:36 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 27/31] ada: Fix crash on reference to aliased object of packed array type with -g Date: Thu, 11 Sep 2025 11:18:59 +0200 Message-ID: <20250911091904.1505690-27-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Eric Botcazou This happens when the object is declared in another compilation unit. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_array_descr_info): In the record type case, bail out if the original array type cannot be retrieved. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/misc.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index 7711f8b0f82a..a79b87e3bdb2 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -837,6 +837,8 @@ gnat_get_array_descr_info (const_tree const_type, if (TYPE_IMPL_PACKED_ARRAY_P (array_type) && TYPE_ORIGINAL_PACKED_ARRAY (array_type)) array_type = TYPE_ORIGINAL_PACKED_ARRAY (array_type); + if (TREE_CODE (array_type) != ARRAY_TYPE) + return false; /* Shift back the address to get the address of the template. */ tree shift_amount From patchwork Thu Sep 11 09:19:00 2025 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: 120054 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 91E243858C39 for ; Thu, 11 Sep 2025 09:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91E243858C39 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=jN6ekeNx X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 447903858430 for ; Thu, 11 Sep 2025 09:19:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 447903858430 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 447903858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582379; cv=none; b=mO0eBAfVn21M9kVaR8RCBc6dCJUqUsOD0VuCftQSQen/p6SeaBk9iGTUOG0AoqN8UeT5nfCIUIyDdWDRJmY/D9TpDwqxX4WP2hhLXXev0xnUctpKmGVrcngzxwM89jBgzJ9qIYz57Mtc/zqkPypwYSIp83Q9JluZWQvFgXPNCWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582379; c=relaxed/simple; bh=M/YiUKfjXTlTcje8FkRwv9DX7cxUZ0T5j90Bedf8s4k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=N/wwa4gQoH1D7xMm4kHDa05qis9apoedXSTQWzxcG3HWyknaF1gg7Zy0mNqK6Lfg5OaMLg7DVmG6Ld9IlMW7+FgfTKyxALknErlchW/P3qomeOl7DUZbNzY6iVqVARo8aRFE80L4rs6QvJ3bVkyKIeTZdb9GYI8LwtUDE5KlQb8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 447903858430 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3df15fdf0caso420744f8f.0 for ; Thu, 11 Sep 2025 02:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582378; x=1758187178; 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=pa/F0KtXmTnyVxunhFZ5cGHmPBcauVuq6jJYLxOLqZI=; b=jN6ekeNxmJ4eGOQ6EnK9z5pN6AGch94BIi5QgnjeQ+xlBCSHYXAjdbwRnsnDobQI4i jmtv1W8HOOEDZisLHI1//2Z8s4OvjaT0sB1dtWA2WBaVDHQtg5xutjy3Qh4h8if9k6qL bagYCFUVegnLBaZ6PDawn8nRZ0XO6c6f9pFwO1ljdMhhAM+xtI3w2K/HdwoxEYLlrBig jf8qMn4G4ivh5I0PY+Mu7JRn4OdNG+hARrBvUKAisTomWB77KxIOS/dFqkTQ+Al5lqen b0kPN/v0wu36pVTRYuA6yrmlIUxKifE9C8mGyIK1Zr/OFpgu3NanBxw0b3FSG8S94wzB ig5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582378; x=1758187178; 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=pa/F0KtXmTnyVxunhFZ5cGHmPBcauVuq6jJYLxOLqZI=; b=BoCo5U1t9UQDbDrJNgE+1rbXLpIb1h7iH/+wti0WOL8D3jEQ/U9F1ToBVbQwVkYXTJ amXK3jWGjCFez12oA0ZOuWejHnCI3rEl+0pE7cMeEyKPG2QzW1NMbr/zxj41U2ffkBwE 14y9vZzmYzVoRfdlMA9k+C3K7NuNUnpuswa4VB/PzsrkDkDLFCHsEsn+uFhGwgvjpYWD 6a4+Mpwn4aLhkouLJZLtmg0zT1r9tLcZugwAfZaO6ezdecN+DEA7Zam7h4GTOHEOzJ5/ czMLgUMo+O171AehufqfcygCtrgc7/IhCXfWDn1d2bIfIYTd1Sz7NkZnAOltbKcBCdNg CB/g== X-Gm-Message-State: AOJu0YxtL8hAoTJmmi2uUE0gWUUouCx3ICRGNN0Nokjz11w1cIpxhai7 AIeZN+rr7avtKhHcTnG+Rco2v7LimWE6iaTUl/4h8V6qVJkS2nLcBwyX6O70wwe4ND6IW02JDKt IosI= X-Gm-Gg: ASbGncvZnX7g8J/BdYtupQgTTEMDbcqpdYXDFDGujFtjDdPqzTfhfeVvpooNNMrSXvt YBWybH5WjhrJa+6oymSRyQTpa5SFcf6+IQ6z8SuHgv+f57qikTuBm/9fh8mDPAIR3tnVf0YMwRm rREPEHF2pk9eV2zQdE1HP3JJm36WSKgchG/KFGN0fuzBrdhviav7BG1IdpQ3oIRD8NIRRkTzfAd 2yV4fnXC7DKucUrgIH6MYDzmbTwOkmu0aNKCvJZvp+hxsPJYAgFF+DR+JdrWrdxw08Lm6zPX3qE F3EDlHkVlCNh5Tnp8lPMAzOYi4u9tJFzEDtWTnR0r/R9Mh+ffSGy3oLKelk+5PmLk225Urb+rUa BZjErV93GHrXSc++BwwDDr0Gw4p81Yq5EJO1KcMz8siKqVBwU5eDA9GuIFHQ96fQP2fMf3co43A GsGhkfUwyvGhfzcorDsNYWQf+cGiq026A/elAsHQ4hz0Ik8ErNVB0rV70CIGE= X-Google-Smtp-Source: AGHT+IF/UK446k0+Nztxvb7B60UG0a6X+jtTXUQLXZsZurgydJQgKFfsilfwzGpkm4zAFGM990F/ow== X-Received: by 2002:a05:6000:430d:b0:3e7:4b1d:74e8 with SMTP id ffacd0b85a97d-3e74b1d750emr12595632f8f.26.1757582377911; Thu, 11 Sep 2025 02:19:37 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:37 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 28/31] ada: Get rid of TYPE_ALIGN_OK flag in gcc-interface Date: Thu, 11 Sep 2025 11:19:00 +0200 Message-ID: <20250911091904.1505690-28-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Eric Botcazou The TYPE_ALIGN_OK flag had originally been a GCC flag tested in the RTL expander and was at some point kicked out of the middle-end to become a pure Gigi flag. But it's only set for tagged types and CW-equivalent types and can be replaced by a explicit predicate without too much work. gcc/ada/ChangeLog: * gcc-interface/ada-tree.h (TYPE_ALIGN_OK): Delete. * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not set it. * gcc-interface/gigi.h (standard_datatypes): Add ADT_tag_name_id. (tag_name_id): New macro. (type_is_tagged_or_cw_equivalent): New inline predicate. * gcc-interface/trans.cc (gigi): Initialize tag_name_id. (gnat_to_gnu) : Replace tests on TYPE_ALIGN_OK with calls to type_is_tagged_or_cw_equivalent. (addressable_p): Likewise. * gcc-interface/utils.cc (convert): Likewise. * gcc-interface/utils2.cc (build_binary_op): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/ada-tree.h | 3 --- gcc/ada/gcc-interface/decl.cc | 8 -------- gcc/ada/gcc-interface/gigi.h | 26 ++++++++++++++++++++++++++ gcc/ada/gcc-interface/trans.cc | 14 +++++++++++--- gcc/ada/gcc-interface/utils.cc | 3 ++- gcc/ada/gcc-interface/utils2.cc | 6 ++---- 6 files changed, 41 insertions(+), 19 deletions(-) diff --git a/gcc/ada/gcc-interface/ada-tree.h b/gcc/ada/gcc-interface/ada-tree.h index 205136bc8ef2..8f930dd8541b 100644 --- a/gcc/ada/gcc-interface/ada-tree.h +++ b/gcc/ada/gcc-interface/ada-tree.h @@ -184,9 +184,6 @@ do { \ /* True for a dummy type if TYPE appears in a profile. */ #define TYPE_DUMMY_IN_PROFILE_P(NODE) TYPE_LANG_FLAG_6 (NODE) -/* True if objects of this type are guaranteed to be properly aligned. */ -#define TYPE_ALIGN_OK(NODE) TYPE_LANG_FLAG_7 (NODE) - /* True for types that implement a packed array and for original packed array types. */ #define TYPE_IMPL_PACKED_ARRAY_P(NODE) \ diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 86cbf5ba4fb5..771325d8ce6c 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -4821,14 +4821,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) { bool align_clause; - /* Record the property that objects of tagged types are guaranteed to - be properly aligned. This is necessary because conversions to the - class-wide type are translated into conversions to the root type, - which can be less aligned than some of its derived types. */ - if (Is_Tagged_Type (gnat_entity) - || Is_Class_Wide_Equivalent_Type (gnat_entity)) - TYPE_ALIGN_OK (gnu_type) = 1; - /* Record whether the type is passed by reference. */ if (is_by_ref && !VOID_TYPE_P (gnu_type)) TYPE_BY_REFERENCE_P (gnu_type) = 1; diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 45b1bfd23e3a..2533bd49434d 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -399,6 +399,9 @@ enum standard_datatypes /* Identifier for the name of the _Parent field in tagged record types. */ ADT_parent_name_id, + /* Identifier for the name of the _Tag field in tagged record types. */ + ADT_tag_name_id, + /* Identifier for the name of the Not_Handled_By_Others field. */ ADT_not_handled_by_others_name_id, @@ -461,6 +464,7 @@ extern GTY(()) tree gnat_raise_decls_ext[(int) LAST_REASON_CODE + 1]; #define mulv128_decl gnat_std_decls[(int) ADT_mulv128_decl] #define uns_mulv128_decl gnat_std_decls[(int) ADT_uns_mulv128_decl] #define parent_name_id gnat_std_decls[(int) ADT_parent_name_id] +#define tag_name_id gnat_std_decls[(int) ADT_tag_name_id] #define not_handled_by_others_name_id \ gnat_std_decls[(int) ADT_not_handled_by_others_name_id] #define reraise_zcx_decl gnat_std_decls[(int) ADT_reraise_zcx_decl] @@ -1124,6 +1128,28 @@ call_is_atomic_load (tree exp) return BUILT_IN_ATOMIC_LOAD_N <= code && code <= BUILT_IN_ATOMIC_LOAD_16; } +/* Return true if TYPE is a tagged type or a CW-equivalent type. */ + +static inline bool +type_is_tagged_or_cw_equivalent (tree type) +{ + if (!RECORD_OR_UNION_TYPE_P (type)) + return false; + + tree field = TYPE_FIELDS (type); + if (!field) + return false; + + /* The tag can be put into the REP part of a record type. */ + if (DECL_INTERNAL_P (field)) + return type_is_tagged_or_cw_equivalent (TREE_TYPE (field)); + + tree name = DECL_NAME (field); + + /* See Exp_Util.Make_CW_Equivalent_Type for the CW-equivalent case. */ + return name == tag_name_id || name == parent_name_id; +} + /* Return true if TYPE is padding a self-referential type. */ static inline bool diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 3c6e87e52c0a..e8baa5ca55cd 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -512,6 +512,9 @@ gigi (Node_Id gnat_root, /* Name of the _Parent field in tagged record types. */ parent_name_id = get_identifier (Get_Name_String (Name_uParent)); + /* Name of the _Tag field in tagged record types. */ + tag_name_id = get_identifier (Get_Name_String (Name_uTag)); + /* Name of the Not_Handled_By_Others field in exception record types. */ not_handled_by_others_name_id = get_identifier ("not_handled_by_others"); @@ -7304,7 +7307,12 @@ gnat_to_gnu (Node_Id gnat_node) tree gnu_obj_type = TREE_TYPE (gnu_result_type); unsigned int oalign = TYPE_ALIGN (gnu_obj_type); - if (align != 0 && align < oalign && !TYPE_ALIGN_OK (gnu_obj_type)) + /* Skip tagged types because conversions to the class-wide type are + translated into conversions to the root type, which may be less + aligned than some of its derived types. */ + if (align != 0 + && align < oalign + && !type_is_tagged_or_cw_equivalent (gnu_obj_type)) post_error_ne_tree_2 ("??source alignment (^) '< alignment of & (^)", gnat_node, Designated_Type (Etype (gnat_node)), @@ -10612,8 +10620,8 @@ addressable_p (tree gnu_expr, tree gnu_type, bool compg) && (!STRICT_ALIGNMENT || TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type) || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN_OK (type) - || TYPE_ALIGN_OK (inner_type)))) + || type_is_tagged_or_cw_equivalent (type) + || type_is_tagged_or_cw_equivalent (inner_type)))) && addressable_p (TREE_OPERAND (gnu_expr, 0), NULL_TREE, compg)); } diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index f501915e82f5..ccb0752a11f0 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -5139,7 +5139,8 @@ convert (tree type, tree expr) But don't do it if we are just annotating types since tagged types aren't fully laid out in this mode. */ else if (ecode == RECORD_TYPE && code == RECORD_TYPE - && TYPE_ALIGN_OK (etype) && TYPE_ALIGN_OK (type) + && type_is_tagged_or_cw_equivalent (etype) + && type_is_tagged_or_cw_equivalent (type) && !type_annotate_only) { tree child_etype = etype; diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 58418ea7236b..b76054c1769b 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -1041,9 +1041,7 @@ build_binary_op (enum tree_code op_code, tree result_type, } /* If a class-wide type may be involved, force use of the RHS type. */ - if ((TREE_CODE (right_type) == RECORD_TYPE - || TREE_CODE (right_type) == UNION_TYPE) - && TYPE_ALIGN_OK (right_type)) + if (type_is_tagged_or_cw_equivalent (right_type)) operation_type = right_type; /* If we are copying between padded objects with compatible types, use @@ -1118,7 +1116,7 @@ build_binary_op (enum tree_code op_code, tree result_type, == TREE_CODE (operand_type (result)) && TYPE_MODE (restype) == TYPE_MODE (operand_type (result)))) - || TYPE_ALIGN_OK (restype)))) + || type_is_tagged_or_cw_equivalent (restype)))) result = TREE_OPERAND (result, 0); else if (TREE_CODE (result) == VIEW_CONVERT_EXPR) From patchwork Thu Sep 11 09:19:01 2025 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: 120051 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 EC9E13858C2C for ; Thu, 11 Sep 2025 09:42:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC9E13858C2C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=L7+mQbln X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 1B56D3858416 for ; Thu, 11 Sep 2025 09:19:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B56D3858416 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 1B56D3858416 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582380; cv=none; b=u39Qf0xr7/yQ0pCyskxXkyPZdxTu1khbnsw8zAqKBkWSCBCVzvtPKsRAXjSCNugn3VbspJQtPsz2ZzXGfCUpRyiS1Ns1s7PfFWve+Z5vilkDupiRw5xx2plScn/d/t5+S1vHvQtieNzVcPjeGR2meUYrjkTD+nJ4xm2EbvtPa0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582380; c=relaxed/simple; bh=f89yKc39VniSwwmVpkL7vWrdMDqHPN8np5F8WySECjE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gBJZY5kdEd+72cmNQozYd/K0i0AdhDWjA6NO+VFeekbb1CapB0onb/F4f+WYVKWTLwsMtD9S4B06xjsSkJMxv4vG0tS2vhRQEs7dt0d4ho2pIIruUEH2ISwmJ+/6Kaln0tQZ6BwfIsXPZcBQq3Vu3glJA/3bi6YudAuf7G9fVa8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B56D3858416 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3e5190bca95so379280f8f.0 for ; Thu, 11 Sep 2025 02:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582379; x=1758187179; 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=Bt76UUx+jqwgjPmV0PBwG4EC06cwBAYbGDaRmvElRIA=; b=L7+mQblnE1Ld7ty9FAyIOk7pZZxdNK22Ag8hjWKKwD/7X5JDj696Vo2oyE6Dc6DNMD rvl3iOEF0TeSHliGWUHn8tWz6dJhvOXwdGUs0qZmxY9aNbHCMfUEVT0NBvYVDbyNqY57 8HJfmQISlBCAcoTFT/B+YS/xM+5Wk7FeV4NFFsMqV8I5cT50Ct3fkCIWRFzaCMUKpje4 1mIVFOE9PM4LYYIiiAaecTTx5pB0Ac/npWtqSQfF2xbiKAOoGiiXLNwATQ6q0w084jE0 83J3VEvxBql+MVYoztddyYneo01DTzopMqSGaKZKcVD5zHzs5meYlfAHVYlO/TTr0QD3 dmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582379; x=1758187179; 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=Bt76UUx+jqwgjPmV0PBwG4EC06cwBAYbGDaRmvElRIA=; b=ChxScwZmBqbNpxZxYX+NkSN/dsCXTlvuwolwVIGymo6AfIxFIBB9uy1cYDEwvFsxcZ HteMFI9vr/Xm6tzZChf4SBpuSREvCfbSI+Q4RJfBExrQCq0gnssMs0x29RuiP7wfwKAp l6DM4JVWpBo71Go/Rv0mQs+o+XrZCqfrv0BcXG+4cQzxmKQMDxohlP/gEScyvxtAD8Z3 9SosfWAo8+bMvG3LJok+C5kD12sO8ghQvLHHBj21U/Jc8E+sO8A4z6HFqf+geRJwzf/h 4oBFTJGDQ14tx/BVFTs5vkXx9JXNjjfMu7g0fgN2g8h+3oB9Zuom2ztPK/mL7emuN9fC IJ5Q== X-Gm-Message-State: AOJu0Yw78JzNLrMjQkAgzEZSrQwotTebz6AnzLKC5DDbVcVYP1NuijCy 05nse5k/P+/5WUSWNRSMehbnK3qweiulopWbei5/7mSv2h9nzuLGMRMI5NewsAlv4bXP2Lb+Hze 663M= X-Gm-Gg: ASbGncuS4SnQz1NfqNfxgitw1yCuLGsZAN7Vnb27G+Uldi2SIOMVx1g+K2dMvov5aGU 85HI/bEKu7slqh2TBadSnTEdqg5f8ZY3wSR5stwAoNDfj+gA8WeCDfm2kGJcvvt5gXikfAG5BpW AcrvUpKPBUIUgpNU12ihYHVE7iIQdlkRGmjarOceFt90fm/KMQtGjlRFsfSkj05tUjcbi9hGKLi 20aNT5C0bj+KsLfN+1cf5ZHfQzyeHMcayd49It7/6B2GISdJj6hoQWO2bBmNs2gEf4OpWo0tolb jtjhUyq/wrPT8MmwYoQTea6PbtkfU3ujgc8xy9R+2sorEuxvgFeS1CFf9vbUUkwVPhxgnGtCTDy rD73PLMdbWq5csVPMcuh3vriqhBwF2Ge7UUTNj91sc7jZHxi9V7xHjYxUnrngQpeBexg31KL2PA MSjvMw8ASxhd69+fb6zIafw+rKgEbhu09/ePcpUGyc5DdpVYDa X-Google-Smtp-Source: AGHT+IH8GaeShJOR7IolFWj1fq3qw9WQAaaUuOw5izQ9pFZMX+waFBncMBm+cZnJpQ9GWviW2lEtLA== X-Received: by 2002:a05:6000:25ca:b0:3e7:5f26:f1e8 with SMTP id ffacd0b85a97d-3e75f26f670mr1998388f8f.5.1757582378744; Thu, 11 Sep 2025 02:19:38 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:38 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 29/31] ada: Give a warning for huge imported objects Date: Thu, 11 Sep 2025 11:19:01 +0200 Message-ID: <20250911091904.1505690-29-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: Eric Botcazou This is a follow-up to a recent change, where a warning was implemented for huge library-level objects. However it is not given if the objects are imported, although an indirection is also added for them under the hood to match the export side. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity) : Give a warning for huge imported objects as well. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 61 +++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 771325d8ce6c..00ccac3978e6 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -1388,16 +1388,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } } - /* If we are at top level and this object is of variable size, - make the actual type a hidden pointer to the real type and - make the initializer be a memory allocation and initialization. - Likewise for objects we aren't defining (presumed to be - external references from other packages), but there we do - not set up an initialization. - - If the object's size overflows, make an allocator too, so that - Storage_Error gets raised. Note that we will never free - such memory, so we presume it never will get allocated. */ + /* If we are at top level and this object is of variable size, make + the actual type a reference to the real type and the initializer + be a memory allocation and initialization. Likewise for an object + that we aren't defining or is imported (presumed to be an external + reference from another package), but in this case we do not set up + an initialization. Likewise if the object's size is constant but + too large. In either case, this will also cause Storage_Error to + be raised if the size ends up overflowing. Note that we will never + free such memory, but it will be allocated only at top level. */ if (!allocatable_size_p (TYPE_SIZE_UNIT (gnu_type), global_bindings_p () || !definition @@ -1411,6 +1410,29 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) || !definition || static_flag))) { + /* Give a warning if the size is constant. */ + if ((TREE_CODE (TYPE_SIZE_UNIT (gnu_type)) == INTEGER_CST + || (gnu_size && TREE_CODE (gnu_size) == INTEGER_CST)) + && definition) + { + if (imported_p) + { + post_error + ("??too large object cannot be imported directly", + gnat_entity); + post_error ("\\??indirect import will be used instead", + gnat_entity); + } + else if (global_bindings_p () || static_flag) + { + post_error + ("??too large object cannot be allocated statically", + gnat_entity); + post_error ("\\??dynamic allocation will be used instead", + gnat_entity); + } + } + if (volatile_flag && !TYPE_VOLATILE (gnu_type)) gnu_type = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE); gnu_type = build_reference_type (gnu_type); @@ -1453,21 +1475,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } /* Give a warning if the size is constant but too large. */ - if (TREE_CODE (TYPE_SIZE_UNIT (gnu_alloc_type)) == INTEGER_CST) - { - if (valid_constant_size_p (TYPE_SIZE_UNIT (gnu_alloc_type))) - { - post_error - ("??too large object cannot be allocated statically", - gnat_entity); - post_error ("\\??dynamic allocation will be used instead", - gnat_entity); - } - - else - post_error ("??Storage_Error will be raised at run time!", - gnat_entity); - } + if (TREE_CODE (TYPE_SIZE_UNIT (gnu_alloc_type)) == INTEGER_CST + && !valid_constant_size_p (TYPE_SIZE_UNIT (gnu_alloc_type))) + post_error ("??Storage_Error will be raised at run time!", + gnat_entity); gnu_expr = build_allocator (gnu_alloc_type, gnu_expr, gnu_type, From patchwork Thu Sep 11 09:19:02 2025 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: 120050 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 D77893858CB6 for ; Thu, 11 Sep 2025 09:42:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D77893858CB6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=FptEYK+P X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id AE0F6385841E for ; Thu, 11 Sep 2025 09:19:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE0F6385841E 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 AE0F6385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582381; cv=none; b=bzUyXyTrqi07KC30cC53wpKJgq2J2sa4XQXkul3NKilZaeAyC8YlFB/fLq2szKYcvNmEyxuSncy1S7o4YMR2tifKvWTNiwCa8yaSoHGfxPak1iLuGe0oq0IJqlgR+dNhoxh8Wzj+XMP0RC4/+9VBB1wiLLC+Q6aLmq1HJuHfXuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582381; c=relaxed/simple; bh=pNjtwczJxXgs2IG4yJuM0olmtM/HXoU49/+5ZXDRSHs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EUzyOP4gbOdYYvgBGcuhyKPKuSj4dKjrKfsHAUBvoXUlgtRMOXM0E/MgRYn43claKbxySQRMSyvOKBvVQ0Mj9WDWcSZ3KVnhIcNCbk6Fctub+R/j/6LBvvZ+S1UzhSQ0GbYl/FB/9NjJObP9k/M9U3SjIP7XMmQMeSh+kmZw4nE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE0F6385841E Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3e7622483beso171389f8f.3 for ; Thu, 11 Sep 2025 02:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582379; x=1758187179; 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=EyikrI+C66Rn4w+Cy3HNFOk25MZX+/2C8y6IWCtsAq8=; b=FptEYK+PuYmlXWr4c+yFJjQaPxWl7Oc5jyr9WNj6F6dyq5tWF2K15MVCUfTaYLS006 0aHGc0MlvyueAQcxvVmxhZGQlZr2aJDD/FPDvUkmNmiD2Hk9SaMEndDAqQSAdcDJRQ+i cLjCw1D9I9oxAPuA4Eg/NWoweiHvyv6ZdPQ2nW860QOhafXoVm2PME1wEEXRPihVcjrR 3NNbJD3IiOMtj8QtU2KabnerZAC9FS2XhSOUlxjhHHo6IYJueGRum5pAY/84ERITNG+t 9/cDkQ3GgZ3Mnhtg8w51btDZvgEvv87Kgg4drwqUbek4ErIueb02n5rskwD+siEN+Ie+ Gcbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582379; x=1758187179; 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=EyikrI+C66Rn4w+Cy3HNFOk25MZX+/2C8y6IWCtsAq8=; b=M4emL51DnSE4cHoC31Cq4/fBQO/J/vkty+XT11h+tu69JWjlgiP7sJT+8WLaxeXNIV qnH93cFncK4T9kdcbBRM+mP4vJs7jlEAsIyzlRPCfAvVetxqx7Iay8Xj/3PXiIZmbwi2 6bFVkqD4+f0qfDrsl8xGJo8UI8FbWiiFKleqrjKWFTbZnfo9RKWoWzmAK6FNgXzpQQ+a 7MMcIPgAeqOFoUd5HWBjzpsLypNPCiuKh8M4suB4Ul1C5Pxe8Mtaxvq7GJksP+HZamVV uXAs2uMYl8dtBckt9TIzu3Fe+/FiH3m2X5RTnIz+mLgHnT4/8tjj30lbKOhBf8MQUioi bMqA== X-Gm-Message-State: AOJu0YxICdAUiAb7s9vatT6yuQr0tAzDnfvsHBjLexwMPYNbeeX5OnQW SoghyAfORY+zR1ULIfjcf82C1jteRY6z2KnxNGyLlGmkNzdob3z4GXrtCdSC2w3nMKR9F+ECDC6 mhMs= X-Gm-Gg: ASbGnctZHxOVXPDETlRRVLOI5fnEWfQzfRQYVv2oWLvx5OAtPg/oh6IvktkpeQc0pJk ov4aeu9baN+3bvvl0Rr7A/7/fRq0f78nh2brQDCC39IOSUnsJ/axDMlkDXUxQtNyyMLxkbFff7o Pllm+UAy0kHUg9rmu4VYG4ahAEv9UqenxJE70UL6l+jBQc+EXGxqG9URsTOWgH28p54Od2omZ0U Z9rZ1+9iZ/PPMlg8T3hcpvDHJDrD1IduYjAszQEqZg6QOprxqJrFgrXWDRFSf6bOrxXl2ImRa0E CwkxHGFaBMss4ptGGAIuc/xQKwgVPbmz6cKIX81ynXcfZjDXym3J3si5vNZ6YbMPUjykcYFIb7R NSngavRPaWryeWNlVVdmimmQWIh1gTYgCW+tsLxooxwZj9nFMtbbFN7VpvWmxdHBi1s1F/s0OZQ Z6hPgfjaFK5yfFpHcEKJ6B9/L05G58B1Sp5UTEf5Wk5f5tQESB X-Google-Smtp-Source: AGHT+IHa2zDewtLtdG1D3xtCxvtMSartxMQNFUnPMzR28E9LVtcIdwaz+sXGav+u1OzYxXUg3jQ/wg== X-Received: by 2002:a05:6000:24c8:b0:3e7:6382:b556 with SMTP id ffacd0b85a97d-3e76382b849mr123114f8f.54.1757582379398; Thu, 11 Sep 2025 02:19:39 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:39 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED 30/31] ada: Minor comment tweaks Date: Thu, 11 Sep 2025 11:19:02 +0200 Message-ID: <20250911091904.1505690-30-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 gcc/ada/ChangeLog: * env.c (__gnat_clearenv): Adjust comment. * libgnarl/a-intnam__bsd.ads: Fix copyright date. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/env.c | 3 ++- gcc/ada/libgnarl/a-intnam__bsd.ads | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/env.c b/gcc/ada/env.c index 950c2696cf67..64e9aa01ef06 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -229,7 +229,8 @@ void __gnat_clearenv (void) || defined (__CYGWIN__) \ || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__) \ || defined (__DragonFly__) || defined (__DJGPP__) - /* On Windows, FreeBSD and MacOS there is no function to clean all the + /* On several platforms (e.g. Windows, FreeBSD, MacOS...) + there is no function to clean all the environment but there is a "clean" way to unset a variable. So go through the environ table and call __gnat_unsetenv on all entries */ char **env = __gnat_environ (); diff --git a/gcc/ada/libgnarl/a-intnam__bsd.ads b/gcc/ada/libgnarl/a-intnam__bsd.ads index 767f54e64cc2..a9fbf0eec9e9 100644 --- a/gcc/ada/libgnarl/a-intnam__bsd.ads +++ b/gcc/ada/libgnarl/a-intnam__bsd.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1991-2024, Free Software Foundation, Inc. -- +-- Copyright (C) 1991-2025, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- From patchwork Thu Sep 11 09:19:03 2025 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: 120057 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 D67973858416 for ; Thu, 11 Sep 2025 09:53:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D67973858416 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=B7cU1B0s X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 9CC89385841C for ; Thu, 11 Sep 2025 09:19:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CC89385841C 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 9CC89385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582381; cv=none; b=v7t4A41Em85wjy9cYBt3J8i82JTS1K26A8H4QSexa2B74QVpisIca0gGDkeXzSlVuDHborWVSmoWKR1eBsWaK3X9HrTv9eVx42d1+L9i0+OzL8liXtC+11cxuMnjM1yUucQ2H0tgdQQ8paFgBfvqNwgkDM684kqKxVNDnfObTYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582381; c=relaxed/simple; bh=QNIbUFSbSTXFbjO3XPFgx98cVQ0CxIac0nNwpCOMQEw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oCGoQkKTUVkKG4GHVebsiHO6VzYBJlMnc2AGK5jV+jFSCRE1kegODPWsL2c0s/z2l/x0MlD7N5giYzaegQUmNl5r5pFoOs7ZkjrXnCvq9YkVrxQo9GuSOfnANEcz4zXt4VZE41ZnFWcMt4reKI/D27UTNqzF3yR/hKZ8RrI+9Nw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CC89385841C Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3da4c14a5f9so951232f8f.0 for ; Thu, 11 Sep 2025 02:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582380; x=1758187180; 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=O0+7Ovi3eOJM8Zl7WvK+yEV4NQJ+0pD0zFLE7rUzpM8=; b=B7cU1B0slpb9Iqv4R2VHufKbR+/lttfM+mBwtgdIr4eEe/91Fc5fvDM9FDieqJecF0 FmvsPa73AyivUCUPkecupYxgtgMBSrz4SfWLIE+11yA17f+ZYVbpSFWXxazWdVg6U0ru YfUvhredZOkOyHP8ccoPXwbJiidW9IveLCVCP6usHIWNfB3N7RRlGZSGXVhfml2i58MR mhj6st1c/Nz/nWZ9c5RoMzKfK/zLViuB99ZkFxVodaut+8fnIZ3Jzv5vmG8UISu8eGr4 co2zLMMB8ULQrJB3fVPoHwZAFqXJ5+P1t2QM4oBKgsE25xi6yf7/DuifqtKyJviKTZpw D3iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582380; x=1758187180; 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=O0+7Ovi3eOJM8Zl7WvK+yEV4NQJ+0pD0zFLE7rUzpM8=; b=KZM2XuXWmHP3a5gjJFe20TlT3gtMO2zm1Umn9o4DI2Tc+r2IT+n+fE+FWr0ke30nnn K4hR7N8a4OWxqMdh15AgmNNhss/ObFaolRSnJD2iBdeNxhNK5ZfeS9KIz3hWQXc7nl3y Fxw++mdKc+5Ck1N3e9utyrF3kzFjwqEp1zEqrfk3h1t36wNaL9WBocPg8WMA2gWY6HEh QrWh50TLkGg21sA5PK6EZQT7KbwDZrpezkpOePzMOkSwP5fi4vANu6FeBtlAQaoli88w MRbz6vE6XTeYoPUcA1bc+iQG9AoS1LDFoTyerzCat4za8lW41xm0y6wkmNDGikvZdns5 6dGQ== X-Gm-Message-State: AOJu0YzTPrG4j2Dr8Fy+8FF58te7KEcBPtHrtiTVghOZIC+vRJ7hJf0J KSVC4ugsE7iHkfgCMVoKzAw6rhH+NJQdJ7j6xQaCU2agnxLHY98bNW8GdyQntgPSkW2aFmlEQDc QAjM= X-Gm-Gg: ASbGncusNjh7o01DbFV0OLdYTMmI8FWxlJ5V/BuDw5oG0yoCom7NBHqISVL4i0HhACw oRR9hV5J8DGjeAU31n2t4qd01GpwX1jYMDFGiQUrTKlMmpibo0RnpCLiNVSklI/2u8al2kPyLnm Oce6coATVwqgp+COW2QUOKJ6z6CWwW2qcR+gNDTP63RTpUieXKJXVuX5Dp2QJztFng9N2yVxguf S6QEeZJ8iRVpC/nA1T2+P5XNyLTl9DwwtGwRfMj9w8yBAiuTG28biZpxUr3Sp4sVZiV9tWdjnEz OBygsykaQ+65pAJohtOMpkCPBP2VXthvCjtw7yMHYGhqgyyuqKUYxjb3nImt3yg6H/d/AMK38RX gOq2UcPQHCm4M2iuMGHna9cXDTU83N/n+gomMo5wF1Yq1DaA0/Ihmjy7KvLaidKBdBgnbo79dV5 CKa+LIY5IoUNh2ZM7Wplpe6vLwGr6ZsWQrzizt7JZYjDPysI6C X-Google-Smtp-Source: AGHT+IFuu7Bc74xNafqmfRPXuvW5ETJZqTBIYUjJJ6D5wF59RNlp7ZSuMgglBW5X3IftqJnVbCx2nA== X-Received: by 2002:a5d:5d8a:0:b0:3dc:2f0e:5e2e with SMTP id ffacd0b85a97d-3e75e0ed9admr2084628f8f.13.1757582380106; Thu, 11 Sep 2025 02:19:40 -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 ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:39 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED 31/31] ada: add BACKLOG_MAX OS constant Date: Thu, 11 Sep 2025 11:19:03 +0200 Message-ID: <20250911091904.1505690-31-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 BACKLOG_MAX represents the number of outstanding connections in the socket's listen queue. gcc/ada/ChangeLog: * libgnat/g-socket.adb (Listen_Socket): Change default value. * libgnat/g-socket.ads (Listen_Socket): Likewise. * s-oscons-tmplt.c (BACKLOG_MAX): New. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/g-socket.adb | 2 +- gcc/ada/libgnat/g-socket.ads | 2 +- gcc/ada/s-oscons-tmplt.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb index 0fed79177544..303640f7fcca 100644 --- a/gcc/ada/libgnat/g-socket.adb +++ b/gcc/ada/libgnat/g-socket.adb @@ -1958,7 +1958,7 @@ package body GNAT.Sockets is procedure Listen_Socket (Socket : Socket_Type; - Length : Natural := 15) + Length : Natural := SOSC.BACKLOG_MAX) is Res : constant C.int := C_Listen (C.int (Socket), C.int (Length)); begin diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads index 1fe8a74ef11e..7c6534cd71c9 100644 --- a/gcc/ada/libgnat/g-socket.ads +++ b/gcc/ada/libgnat/g-socket.ads @@ -1219,7 +1219,7 @@ package GNAT.Sockets is procedure Listen_Socket (Socket : Socket_Type; - Length : Natural := 15); + Length : Natural := SOSC.BACKLOG_MAX); -- To accept connections, a socket is first created with Create_Socket, -- a willingness to accept incoming connections and a queue Length for -- incoming connections are specified. Raise Socket_Error on error. diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 7a5e987cefc4..4f9ff2aac867 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -1791,6 +1791,9 @@ struct sockaddr_un { #define SIZEOF_sockaddr_un (sizeof (struct sockaddr_un)) CND(SIZEOF_sockaddr_un, "struct sockaddr_un") +#define BACKLOG_MAX 15 +CND(BACKLOG_MAX, "number of outstanding connections in the socket's listen queue") + #define SIZEOF_fd_set (sizeof (fd_set)) CND(SIZEOF_fd_set, "fd_set") CND(FD_SETSIZE, "Max fd value")