From patchwork Tue Jul 2 13:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=XV0CHrkY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3VX3msnz1xpc for ; Tue, 2 Jul 2024 23:22:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B88453882111 for ; Tue, 2 Jul 2024 13:22:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 22E833882074 for ; Tue, 2 Jul 2024 13:21:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22E833882074 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 22E833882074 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926503; cv=none; b=pweorzz9oVknL/MXUT6y8EmlfF0aUd99wplIxN+S99acVFDBO2XDpTNHNKRyWil1BHR0RH2O4ZuRct1BJFd3aoraW4pqpWLHaZtqMXVdi0hcDStKzYcDXImctXq90SAvA6PpzoOA9tD1dJTjMwKt5zGCvId4ddpBacynILqtgTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926503; c=relaxed/simple; bh=twfwcYlIpy4aP1RFOajlD0gM7zGT0eKk/tTl0ePOOQk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E2+ywtMrF9xw6Popi43P6As5TiCFCywVYDPJgEvxVN9QS1D7VOtcMQsmsldhJ+X9MxENGeTlnKaFdeptSi99touh/Do4AcZWNtLYbqa1JdgeMuU2GpyikEY1nlcNV5kdeLvZLDV9HRf9/RlpTXrvBXBX/yECZp+OreiO0PA2hXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso37047205e9.3 for ; Tue, 02 Jul 2024 06:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926501; x=1720531301; 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=G7eWM5lSPzHakJAAaglHhZJ/jUHfHZhyJ4Sl7xjS2Do=; b=XV0CHrkYJt/tbneTIVGqBiv4AQd88jUDdAHzD0fdVYrhty3Dr0lheRxUEEKA3MNAwR 2NFktDSRz0W/DKYkQgQZUnb14CBManXSGwAVjEXaNANxPWJDVRll39H1EJc4SNnV2GQK /mOvYUe3WVd3F+TpTvhbanv2NIxkMvKgIpJWa/Ru1YNVTCNYtPyCFNsAk/JNKV94uI0p eqqmShd/CRE1Z8DZdPEr2dPljmKQjTfS4+gjJxD59OvO9hDcHFZyP5rYvDEd6cvFeKil 0wvi8gRbm/ft0Dyi8AC1V8vhVffGLfxGeC5tweE1hJumjVRMazYTyalztptf3VMJygup Xpgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926501; x=1720531301; 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=G7eWM5lSPzHakJAAaglHhZJ/jUHfHZhyJ4Sl7xjS2Do=; b=ULcbt6cQEQGMd3rd5NDtr+bWXxFqW032TkFFE+JeLMsHxuGJcn8qw1Zl83tweuHkPI rG1rEK9S+SVjQ2Lr19wBcSTbZFpFCqw82pfskw1VpREZxpA47QZ078WrMV87jhBB28Yy d56uIk/THWyX7yIRw1qtAr42AQkrtI3Gx4kCzVrnvOLXHfqL7yI7IgTbi428efIGh59m U5L78vpzB/6TxztzlZ1PGXv9UVK5Kw4BCgXoBpeeNHscwg6ZgPuOuXiBIehDpIKb1Rxg uzAT5lwDQ3Os9+2Ab06t8rKREMEb68xoIoqrfl0cTiiSn+ZthWqauJYmSkaesqYvSA8L f6MQ== X-Gm-Message-State: AOJu0Yz69JTHbpY064gMR/TxRpwPDi4BhC1RB/nxeZjhDucZj5OVOhFO sZMTliRej0gSRKWOhueOlPAMUV007zqq7gQvrWibaxzKaI0pgfLzFk9zadr5d9Vtlw5V44WNhvc = X-Google-Smtp-Source: AGHT+IHu2deZ47Q8t/WLSqeDok0hXMm1Ng8tlSSBCw7abWUx8TQO3K6xjR30gTXLu74H5f8wekr3YA== X-Received: by 2002:a05:600c:4804:b0:425:7784:56e6 with SMTP id 5b1f17b1804b1-4257a007729mr74943135e9.11.1719926500825; Tue, 02 Jul 2024 06:21:40 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:40 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 01/13] ada: Document that -gnatdJ is unused Date: Tue, 2 Jul 2024 15:21:17 +0200 Message-ID: <20240702132130.523603-1-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 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~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou gcc/ada/ * debug.adb (dJ): Add back as unused. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/debug.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index f7fcd399769..3313c4a408f 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -67,6 +67,7 @@ package body Debug is -- dG Generate all warnings including those normally suppressed -- dH Hold (kill) call to gigi -- dI Inhibit internal name numbering in gnatG listing + -- dJ -- dK Kill all error messages -- dL Ignore external calls from instances for elaboration -- dM Assume all variables are modified (no current values) From patchwork Tue Jul 2 13:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=hMr5CRnG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3VN2FDpz1xpc for ; Tue, 2 Jul 2024 23:22:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C6393882076 for ; Tue, 2 Jul 2024 13:22:18 +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 17F17388215D for ; Tue, 2 Jul 2024 13:21:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17F17388215D 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 17F17388215D 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=1719926505; cv=none; b=IGZZW4dfRBM/Aa6wN7CuIzgCifY0PNjpjwcG00slawt2I+1QgzDpM1yLqrBs/DHpjerZGOaI9NNEUjyIgMxv4POfcfrCh/Al+x0qW9tc5dKfCloqOIZ80eve56oRd1Z92QOH2nRH+rU513/12cj0/df/H4Lva79YKp6Odl5iW9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926505; c=relaxed/simple; bh=etnKT2ntk/ME/lFeMk971ahTKcyTOEL7UHKJzF57UeI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CEqn42bkX0O2WTRq0RUdsOoEeDz4oODmYUFekhtqMmyuY96Z+m6jQsBACRwxLkCbuUeG5v55Uiu8UxPvWSUG+lUUY5Vq4JtveIe6zlwwm47YElqo2G/acnG+JNU+4Xirx/QQjcIfSIuiBGsbd7Jvne9u/ErEc7/kB0am3MYQ0fI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42573d3f7e4so27343725e9.0 for ; Tue, 02 Jul 2024 06:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926502; x=1720531302; 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=YgoxcePkGEKlh43izrGTC/U6sW037fAkSILcDdQVJQQ=; b=hMr5CRnGlR/0hj6eqqJvPp+Xp6ckPqdNuFipYH5u/SdKhIHX1+m2kLeX1a/PsGOiek nxGi4DJOdaM2x0d/P6LvqZ/5pBi+djuOKCSQOwJz27cXmXu+Zebqs1Nqr4PyTR98E671 gZaCXXns34SiiNAI1L1dFFFEtv+U46XDji2qb8+BD1q+mZ1XHh3wfr0Wl20EiLEAG0iR syteY++urUP1EJ+E1faX6UYpbJbbKXFb3DFMtiQ89GlpsbHb1hk8I+Tc4CLLEdO0LQrH DTJDCTjpsBWl9/0/8Pq7LsZSk9Vljwf061pYDhzJ6YnMEkVfCSnWR8O+kME83yfWwzl3 +Ezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926502; x=1720531302; 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=YgoxcePkGEKlh43izrGTC/U6sW037fAkSILcDdQVJQQ=; b=rZNarfvwEyoMg8CaVIm58fCblzGvDiEuipdPlXg2dSHxP9FTRFLvf7nxV+6GEyqiZe 4aDjziAgCMUuadAdz21mOSehgAR4gaKkvPBxeR9I0jVoS2fXkx51MabD4sLekpVMrLMY 6rSZ7/XkhZWq138pOORJTI6dOQ6hUuYMCqs2FctgStC60Mt5xdlGJNwH9OJidlbq3nhM QTYixC/YbmfYzDMjEsiv04HrxUuflmSnSRwqc1gBk6k8Jm38v5dX4oCn/I26sfk08gD2 VA9ifuG+RZWId8z7aJq2gM0zuEKTb23PLU9RWqxTJOfhRPVNZZ//5FK4mlGmhpCQft5W +VPg== X-Gm-Message-State: AOJu0YyLbaPnFX5LFMPZPD0xpqmOIQwWrPVO0PFfgdte/Qry7fQL58XS 6zdqQXW5fY79c/l6aIdLl5AiwTy0xlY97rdJhZaU57WbCIbdoAHb+64yyWAsFHHqH5OQZ0hIMsM = X-Google-Smtp-Source: AGHT+IExSiCDHV0gbnWfPWqNcmbwInwivFi0x74Hj7oXJMbbpROMaCp272Km8jK/K9e4zd6US+hMng== X-Received: by 2002:a05:600c:3594:b0:424:9f28:22fc with SMTP id 5b1f17b1804b1-4257a02c888mr60055635e9.2.1719926501721; Tue, 02 Jul 2024 06:21:41 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:41 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 02/13] ada: Fix crash on box-initialized component with No_Default_Initialization Date: Tue, 2 Jul 2024 15:21:18 +0200 Message-ID: <20240702132130.523603-2-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-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~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou The problem is that the implementation of the No_Default_Initialization restriction assumes that no type initialization routines are needed and, therefore, builds a dummy version of them, which goes against their use for box-initialized components in aggregates. Therefore this use needs to be flagged as violating the restriction too. gcc/ada/ * doc/gnat_rm/standard_and_implementation_defined_restrictions.rst (No_Default_Initialization): Mention components alongside variables. * exp_aggr.adb (Build_Array_Aggr_Code.Gen_Assign): Check that the restriction No_Default_Initialization is not in effect for default initialized component. (Build_Record_Aggr_Code): Likewise. * gnat_rm.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- ...nd_implementation_defined_restrictions.rst | 4 +- gcc/ada/exp_aggr.adb | 41 +++++++++++-------- gcc/ada/gnat_rm.texi | 6 +-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst index cf4657b7050..0e9162a1906 100644 --- a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst +++ b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst @@ -163,8 +163,8 @@ No_Default_Initialization .. index:: No_Default_Initialization [GNAT] This restriction prohibits any instance of default initialization -of variables. The binder implements a consistency rule which prevents -any unit compiled without the restriction from with'ing a unit with the +of variables or components. The binder implements a consistency check that +prevents any unit without the restriction from with'ing a unit with the restriction (this allows the generation of initialization procedures to be skipped, since you can be sure that no call is ever generated to an initialization procedure in a unit with the restriction active). If used diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 01ad1dcd437..df228713a28 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1486,14 +1486,16 @@ package body Exp_Aggr is -- object creation that will invoke it otherwise. else - if Present (Base_Init_Proc (Base_Type (Ctype))) - or else Has_Task (Base_Type (Ctype)) - then - Append_List_To (Stmts, - Build_Initialization_Call (N, - Id_Ref => Indexed_Comp, - Typ => Ctype, - With_Default_Init => True)); + if Present (Base_Init_Proc (Ctype)) then + Check_Restriction (No_Default_Initialization, N); + + if not Restriction_Active (No_Default_Initialization) then + Append_List_To (Stmts, + Build_Initialization_Call (N, + Id_Ref => Indexed_Comp, + Typ => Ctype, + With_Default_Init => True)); + end if; -- If the component type has invariants, add an invariant -- check after the component is default-initialized. It will @@ -3185,6 +3187,8 @@ package body Exp_Aggr is elsif Box_Present (Comp) and then Has_Non_Null_Base_Init_Proc (Etype (Selector)) then + Check_Restriction (No_Default_Initialization, N); + if Ekind (Selector) /= E_Discriminant then Generate_Finalization_Actions; end if; @@ -3216,15 +3220,18 @@ package body Exp_Aggr is end if; end; - Append_List_To (L, - Build_Initialization_Call (N, - Id_Ref => Make_Selected_Component (Loc, - Prefix => New_Copy_Tree (Target), - Selector_Name => - New_Occurrence_Of (Selector, Loc)), - Typ => Etype (Selector), - Enclos_Type => Typ, - With_Default_Init => True)); + if not Restriction_Active (No_Default_Initialization) then + Append_List_To (L, + Build_Initialization_Call (N, + Id_Ref => Make_Selected_Component (Loc, + Prefix => + New_Copy_Tree (Target), + Selector_Name => + New_Occurrence_Of (Selector, Loc)), + Typ => Etype (Selector), + Enclos_Type => Typ, + With_Default_Init => True)); + end if; -- Prepare for component assignment diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index dc5721689cb..4feef7e1f9f 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT Reference Manual , Jun 24, 2024 +GNAT Reference Manual , Jun 27, 2024 AdaCore @@ -12594,8 +12594,8 @@ coextensions. See 3.10.2. @geindex No_Default_Initialization [GNAT] This restriction prohibits any instance of default initialization -of variables. The binder implements a consistency rule which prevents -any unit compiled without the restriction from with’ing a unit with the +of variables or components. The binder implements a consistency check that +prevents any unit without the restriction from with’ing a unit with the restriction (this allows the generation of initialization procedures to be skipped, since you can be sure that no call is ever generated to an initialization procedure in a unit with the restriction active). If used From patchwork Tue Jul 2 13:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=MHRQWPLw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Vc2kChz1xpc for ; Tue, 2 Jul 2024 23:22:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E56C388217D for ; Tue, 2 Jul 2024 13:22:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id F38893882071 for ; Tue, 2 Jul 2024 13:21:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F38893882071 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 F38893882071 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926508; cv=none; b=cEDs70eDuO5jIZOSRlfWJC+SPklttkV6ZxRrTzgvgMx2rf8MzlzoE1TRswOElV9wdCCWTq61ZWne317GnKrDX3Of7b+OVEj60vt+p3Sm8ujg+G/oxXDz5UvpTqXWYL0xmzBIsuMw/Sl+THxCDxWTyOzc4LiwTTr0iV7UJpLazIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926508; c=relaxed/simple; bh=1Bh6NALlbyb4IhNY+AYCvCq1Nn/0FQdsPq8zZRJ8ueU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IZ53GAJKxofcpiwSH/mMFQd+58n/WjiybFU7HhfYggBe+WIdcMUDqc8fhW4OOPImp5rxWlnawdHnMw3fn1+FWUrhu0e9AqSGmzrcCym9fI1zNc6yQaTwyQaj5F0QyrBbm8RIwuw+TH4m/BWZcGB3b9jajzLYibbHXz9D4FpCoMw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42565697036so31265185e9.1 for ; Tue, 02 Jul 2024 06:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926502; x=1720531302; 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=rvOcb3Ms+1S8RGPai8tyYhUYnnuuH01VN756OgxHOow=; b=MHRQWPLw/kNA9Ldd2pCp5YqmbbYjE7gNukBql5ZJ+7acvJUvf26Jr7qj977XC5Eu8e YHozWz6MDa8pnEG7Vm8If8ZiKH7Lr6i/tCVJfb021Cs4DmIt9xMheNbDuVWoJpJxZw2s uLsg5wSALply7saZ4kZHwJVz9RMJn2T06tKNLdBy3OXryVfZh8oFKpnuSJHOa48Ztq3y U/97aIK5+g52Wyrje93+5RDc2G5JY3DPXRrK6tUiUha3F/g3eItjHEDTXJbcFvKmHYvv hhD3VCa8+h83pBT845fuA1iUrtNch078k2QlEkSv4bNyDN4KNxX2LwQLs8jrgC1kfYfa BeBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926502; x=1720531302; 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=rvOcb3Ms+1S8RGPai8tyYhUYnnuuH01VN756OgxHOow=; b=Jske40J7vM39Z4Q6DHkvT54I+mcccXhkw3CO2160V+7EBMQXyY1AreB3MWXr6lqZ3l Sb8lg/vdIiI/3jHjP6rn9mEWm6vwJ/pcIOTN7LuKLIMNzrurrvw8i0KvY2UxNOOMHZIj iYYxbo4odY33nsbfXobkUYm2/j3zyTz7ICGJmRNwd/7FihI1QXnh6F5LHk1ybH4R2PX9 197ca25RPF1Yla/eCR8vn51wygOkUxd+e/K2lnBaIjo7g0V5laZFdcMb8YMlxbrRmrKe 2Hh5yMi1zU9XBfHEfZfvdq0o6tLTbWKZg1wO0VGwj0yPsFoOkP2N+b+I2xyyY1aiNU8z FtnQ== X-Gm-Message-State: AOJu0YzVsKZzPNCxrVJJ9LJL+rOg3B1VtAEjC2elrOliO6FqklusnbPp XY0YVle7M9UZvdVQJBRPES32HBYuHx0CAtoshEFNLBfFeQmAH2UZFIJFqz1lqoJ1gTeObi/T018 = X-Google-Smtp-Source: AGHT+IHrnEp7+u95DUQet8rovfXbKI4oBZAt3thg026IzL+4a42H8Prd9jV7u4dHPeju5jYLOz1Jjw== X-Received: by 2002:a05:600c:3510:b0:421:805f:ab3c with SMTP id 5b1f17b1804b1-4256d569dbcmr113029665e9.14.1719926502597; Tue, 02 Jul 2024 06:21:42 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:42 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 03/13] ada: Miscomputed bounds for inner null array aggregates Date: Tue, 2 Jul 2024 15:21:19 +0200 Message-ID: <20240702132130.523603-3-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Javier Miranda When an array has several dimensions, and inner dimmensions are initialized using Ada 2022 null array aggregates, the compiler crashes or reports spurious errors computing the bounds of the null array aggregates. This patch fixes the problem and adds new warnings reported when the index of null array aggregates is an enumeration type or a modular type and it is known at compile time that the program will raise Constraint_Error computing the bounds of the aggregate. gcc/ada/ * sem_aggr.adb (Cannot_Compute_High_Bound): New subprogram. (Report_Null_Array_Constraint_Error): New subprogram. (Collect_Aggr_Bounds): For null aggregates, build the bounds of the inner dimensions. (Has_Null_Aggregate_Raising_Constraint_Error): New subprogram. (Subtract): New subprogram. (Resolve_Array_Aggregate): Report a warning when the index of null array aggregates is an enumeration type or a modular type at we can statically determine that the program will raise CE at runtime computing its high bound. (Resolve_Null_Array_Aggregate): ditto. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 415 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 384 insertions(+), 31 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 1dbde1fae31..bc53ea904a3 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -102,6 +102,11 @@ package body Sem_Aggr is -- simple insertion sort is used since the choices in a case statement will -- usually be in near sorted order. + function Cannot_Compute_High_Bound (Index : Entity_Id) return Boolean; + -- Determines if the type of the given array aggregate index is a modular + -- type or an enumeration type that will raise CE at runtime when computing + -- the high bound of a null aggregate. + procedure Check_Can_Never_Be_Null (Typ : Entity_Id; Expr : Node_Id); -- Ada 2005 (AI-231): Check bad usage of null for a component for which -- null exclusion (NOT NULL) is specified. Typ can be an E_Array_Type for @@ -121,6 +126,13 @@ package body Sem_Aggr is -- Expression is also OK in an instance or inlining context, because we -- have already preanalyzed and it is known to be type correct. + procedure Report_Null_Array_Constraint_Error + (N : Node_Id; + Index_Typ : Entity_Id); + -- N is a null array aggregate indexed by the given enumeration type or + -- modular type. Report a warning notifying that CE will be raised at + -- runtime. Under SPARK mode an error is reported instead of a warning. + ------------------------------------------------------ -- Subprograms used for RECORD AGGREGATE Processing -- ------------------------------------------------------ @@ -513,27 +525,108 @@ package body Sem_Aggr is if Dim < Aggr_Dimension then - -- Process positional components + if not Is_Null_Aggregate (N) then - if Present (Expressions (N)) then - Expr := First (Expressions (N)); - while Present (Expr) loop - Collect_Aggr_Bounds (Expr, Dim + 1); - Next (Expr); - end loop; - end if; + -- Process positional components + + if Present (Expressions (N)) then + Expr := First (Expressions (N)); + while Present (Expr) loop + Collect_Aggr_Bounds (Expr, Dim + 1); + Next (Expr); + end loop; + end if; - -- Process component associations + -- Process component associations - if Present (Component_Associations (N)) then - Is_Fully_Positional := False; + if Present (Component_Associations (N)) then + Is_Fully_Positional := False; - Assoc := First (Component_Associations (N)); - while Present (Assoc) loop - Expr := Expression (Assoc); - Collect_Aggr_Bounds (Expr, Dim + 1); - Next (Assoc); - end loop; + Assoc := First (Component_Associations (N)); + while Present (Assoc) loop + Expr := Expression (Assoc); + Collect_Aggr_Bounds (Expr, Dim + 1); + + -- Propagate the error; it is not done in other cases to + -- avoid replacing this aggregate by a CE node (required + -- to report complementary warnings when the expression + -- is resolved). + + if Is_Null_Aggregate (Expr) + and then Raises_Constraint_Error (Expr) + then + Set_Raises_Constraint_Error (N); + end if; + + Next (Assoc); + end loop; + end if; + + -- For null aggregates, build the bounds of their inner dimensions + -- (if not previously done). They are required for building the + -- aggregate itype. + + elsif No (Aggr_Range (Dim + 1)) then + declare + Loc : constant Source_Ptr := Sloc (N); + Typ : constant Entity_Id := Etype (N); + Index : Node_Id; + Index_Typ : Entity_Id; + Lo, Hi : Node_Id; + Null_Range : Node_Id; + Num_Dim : Pos := 1; + + begin + -- Move the index to the first dimension implicitly included + -- in this null aggregate. + + Index := First_Index (Typ); + while Num_Dim <= Dim loop + Next_Index (Index); + Num_Dim := Num_Dim + 1; + end loop; + + while Present (Index) loop + Get_Index_Bounds (Index, L => Lo, H => Hi); + Index_Typ := Etype (Index); + + if Cannot_Compute_High_Bound (Index) then + -- To avoid reporting spurious errors we use the upper + -- bound as the higger bound of this index; this value + -- will not be used to generate code because this + -- aggregate will be replaced by a raise CE node. + + Hi := New_Copy_Tree (Lo); + + 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. + + Hi := Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Index_Typ, Loc), + Attribute_Name => Name_Pred, + Expressions => New_List (New_Copy_Tree (Lo))); + end if; + + Null_Range := Make_Range (Loc, New_Copy_Tree (Lo), Hi); + Analyze_And_Resolve (Null_Range, Index_Typ); + + pragma Assert (No (Aggr_Range (Num_Dim))); + Aggr_Low (Num_Dim) := Low_Bound (Null_Range); + Aggr_High (Num_Dim) := High_Bound (Null_Range); + Aggr_Range (Num_Dim) := Null_Range; + + Num_Dim := Num_Dim + 1; + Next_Index (Index); + end loop; + + pragma Assert (Num_Dim = Aggr_Dimension + 1); + end; end if; end if; end Collect_Aggr_Bounds; @@ -552,7 +645,7 @@ package body Sem_Aggr is -- Make sure that the list of index constraints is properly attached to -- the tree, and then collect the aggregate bounds. - -- If no aggregaate bounds have been set, this is an aggregate with + -- If no aggregate bounds have been set, this is an aggregate with -- iterator specifications and a dynamic size to be determined by -- first pass of expanded code. @@ -685,6 +778,41 @@ package body Sem_Aggr is return Itype; end Array_Aggr_Subtype; + ------------------------------- + -- Cannot_Compute_High_Bound -- + ------------------------------- + + function Cannot_Compute_High_Bound (Index : Entity_Id) return Boolean is + Index_Type : constant Entity_Id := Etype (Index); + Lo, Hi : Node_Id; + + begin + if not Is_Modular_Integer_Type (Index_Type) + and then not Is_Enumeration_Type (Index_Type) + then + return False; + + elsif Index_Type = Base_Type (Index_Type) then + return True; + + else + Get_Index_Bounds (Index, L => Lo, H => Hi); + + if Compile_Time_Known_Value (Lo) then + if Is_Enumeration_Type (Index_Type) + and then not Is_Character_Type (Index_Type) + then + return Enumeration_Pos (Entity (Lo)) + = Enumeration_Pos (First_Literal (Base_Type (Index_Type))); + else + return Expr_Value (Lo) = Uint_0; + end if; + end if; + end if; + + return False; + end Cannot_Compute_High_Bound; + -------------------------------- -- Check_Misspelled_Component -- -------------------------------- @@ -979,6 +1107,27 @@ package body Sem_Aggr is Rewrite (N, New_N); end Make_String_Into_Aggregate; + ---------------------------------------- + -- Report_Null_Array_Constraint_Error -- + ---------------------------------------- + + procedure Report_Null_Array_Constraint_Error + (N : Node_Id; + Index_Typ : Entity_Id) is + begin + Error_Msg_Warn := SPARK_Mode /= On; + + if Is_Modular_Integer_Type (Index_Typ) then + Error_Msg_N + ("null array aggregate indexed by a modular type<<", N); + else + Error_Msg_N + ("null array aggregate indexed by an enumeration type<<", N); + end if; + + Error_Msg_N ("\Constraint_Error [<<", N); + end Report_Null_Array_Constraint_Error; + ----------------------- -- Resolve_Aggregate -- ----------------------- @@ -1459,6 +1608,11 @@ package body Sem_Aggr is -- cannot statically evaluate From. Otherwise it stores this static -- value into Value. + function Has_Null_Aggregate_Raising_Constraint_Error + (Expr : Node_Id) return Boolean; + -- Determines if the given expression has some null aggregate that will + -- cause raising CE at runtime. + function Resolve_Aggr_Expr (Expr : Node_Id; Single_Elmt : Boolean) return Boolean; @@ -1478,6 +1632,11 @@ package body Sem_Aggr is Index_Typ : Entity_Id); -- For AI12-061 + function Subtract (Val : Uint; To : Node_Id) return Node_Id; + -- Creates a new expression node where Val is subtracted to expression + -- To. Tries to constant fold whenever possible. To must be an already + -- analyzed expression. + procedure Warn_On_Null_Component_Association (Expr : Node_Id); -- Expr is either a conditional expression or a case expression of an -- iterated component association initializing the aggregate N with @@ -1747,6 +1906,41 @@ package body Sem_Aggr is end if; end Get; + ------------------------------------------------- + -- Has_Null_Aggregate_Raising_Constraint_Error -- + ------------------------------------------------- + + function Has_Null_Aggregate_Raising_Constraint_Error + (Expr : Node_Id) return Boolean + is + function Process (N : Node_Id) return Traverse_Result; + -- Process one node in search for generic formal type + + ------------- + -- Process -- + ------------- + + function Process (N : Node_Id) return Traverse_Result is + begin + if Nkind (N) = N_Aggregate + and then Is_Null_Aggregate (N) + and then Raises_Constraint_Error (N) + then + return Abandon; + end if; + + return OK; + end Process; + + function Traverse is new Traverse_Func (Process); + -- Traverse tree to look for null aggregates that will raise CE + + -- Start of processing for Has_Null_Aggregate_Raising_Constraint_Error + + begin + return Traverse (Expr) = Abandon; + end Has_Null_Aggregate_Raising_Constraint_Error; + ----------------------- -- Resolve_Aggr_Expr -- ----------------------- @@ -1871,7 +2065,8 @@ package body Sem_Aggr is end if; if Raises_Constraint_Error (Expr) - and then Nkind (Parent (Expr)) /= N_Component_Association + and then (Nkind (Parent (Expr)) /= N_Component_Association + or else Is_Null_Aggregate (Expr)) then Set_Raises_Constraint_Error (N); end if; @@ -2017,6 +2212,108 @@ package body Sem_Aggr is End_Scope; end Resolve_Iterated_Component_Association; + -------------- + -- Subtract -- + -------------- + + function Subtract (Val : Uint; To : Node_Id) return Node_Id is + Expr_Pos : Node_Id; + Expr : Node_Id; + To_Pos : Node_Id; + + begin + if Raises_Constraint_Error (To) then + return To; + end if; + + -- First test if we can do constant folding + + if Compile_Time_Known_Value (To) + or else Nkind (To) = N_Integer_Literal + then + Expr_Pos := Make_Integer_Literal (Loc, Expr_Value (To) - Val); + Set_Is_Static_Expression (Expr_Pos); + Set_Etype (Expr_Pos, Etype (To)); + Set_Analyzed (Expr_Pos, Analyzed (To)); + + if not Is_Enumeration_Type (Index_Typ) then + Expr := Expr_Pos; + + -- If we are dealing with enumeration return + -- Index_Typ'Val (Expr_Pos) + + else + Expr := + Make_Attribute_Reference + (Loc, + Prefix => New_Occurrence_Of (Index_Typ, Loc), + Attribute_Name => Name_Val, + Expressions => New_List (Expr_Pos)); + end if; + + return Expr; + end if; + + -- If we are here no constant folding possible + + if not Is_Enumeration_Type (Index_Base) then + Expr := + Make_Op_Subtract (Loc, + Left_Opnd => Duplicate_Subexpr (To), + Right_Opnd => Make_Integer_Literal (Loc, Val)); + + -- If we are dealing with enumeration return + -- Index_Typ'Val (Index_Typ'Pos (To) - Val) + + else + To_Pos := + Make_Attribute_Reference + (Loc, + Prefix => New_Occurrence_Of (Index_Typ, Loc), + Attribute_Name => Name_Pos, + Expressions => New_List (Duplicate_Subexpr (To))); + + Expr_Pos := + Make_Op_Subtract (Loc, + Left_Opnd => To_Pos, + Right_Opnd => Make_Integer_Literal (Loc, Val)); + + Expr := + Make_Attribute_Reference + (Loc, + Prefix => New_Occurrence_Of (Index_Typ, Loc), + Attribute_Name => Name_Val, + Expressions => New_List (Expr_Pos)); + + -- If the index type has a non standard representation, the + -- attributes 'Val and 'Pos expand into function calls and the + -- resulting expression is considered non-safe for reevaluation + -- by the backend. Relocate it into a constant temporary in order + -- to make it safe for reevaluation. + + if Has_Non_Standard_Rep (Etype (N)) then + declare + Def_Id : Entity_Id; + + begin + Def_Id := Make_Temporary (Loc, 'R', Expr); + Set_Etype (Def_Id, Index_Typ); + Insert_Action (N, + Make_Object_Declaration (Loc, + Defining_Identifier => Def_Id, + Object_Definition => + New_Occurrence_Of (Index_Typ, Loc), + Constant_Present => True, + Expression => Relocate_Node (Expr))); + + Expr := New_Occurrence_Of (Def_Id, Loc); + end; + end if; + end if; + + return Expr; + end Subtract; + ---------------------------------------- -- Warn_On_Null_Component_Association -- ---------------------------------------- @@ -2726,6 +3023,19 @@ package body Sem_Aggr is Related_Nod => N); end if; + -- Propagate the attribute Raises_CE when it was reported on a + -- null aggregate. This will cause replacing the aggregate by a + -- raise CE node; it is not done in other cases to avoid such + -- replacement and report complementary warnings when the + -- expression is resolved. + + if Present (Expression (Assoc)) + and then Has_Null_Aggregate_Raising_Constraint_Error + (Expression (Assoc)) + then + Set_Raises_Constraint_Error (N); + end if; + Next (Assoc); end loop; @@ -3208,8 +3518,32 @@ package body Sem_Aggr is Aggr_Low := Index_Typ_Low; end if; - Aggr_High := Add (Nb_Elements - 1, To => Aggr_Low); - Check_Bound (Index_Base_High, Aggr_High); + -- Report a warning when the index type of a null array aggregate + -- is a modular type or an enumeration type, and we know that + -- we will not be able to compute its high bound at runtime + -- (AI22-0100-2). + + if Nb_Elements = Uint_0 + and then Cannot_Compute_High_Bound (Index_Constr) + then + -- Use the low bound value for the high-bound value to avoid + -- reporting spurious errors; this value will not be used at + -- runtime because this aggregate will be replaced by a raise + -- CE node. + + Aggr_High := Aggr_Low; + + Report_Null_Array_Constraint_Error (N, Index_Typ); + Set_Raises_Constraint_Error (N); + + elsif Nb_Elements = Uint_0 then + Aggr_High := Subtract (Uint_1, To => Aggr_Low); + Check_Bound (Index_Base_High, Aggr_High); + + else + Aggr_High := Add (Nb_Elements - 1, To => Aggr_Low); + Check_Bound (Index_Base_High, Aggr_High); + end if; end if; end if; @@ -4726,9 +5060,11 @@ package body Sem_Aggr is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); - Index : Node_Id; - Lo, Hi : Node_Id; - Constr : constant List_Id := New_List; + Constr : constant List_Id := New_List; + Index : Node_Id; + Index_Typ : Node_Id; + Known_Bounds : Boolean := True; + Lo, Hi : Node_Id; begin -- Attach the list of constraints at the location of the aggregate, so @@ -4742,14 +5078,31 @@ package body Sem_Aggr is Index := First_Index (Typ); while Present (Index) loop Get_Index_Bounds (Index, L => Lo, H => Hi); + Index_Typ := Etype (Index); + + Known_Bounds := Known_Bounds + and Compile_Time_Known_Value (Lo) + and Compile_Time_Known_Value (Hi); - -- The upper bound is the predecessor of the lower bound + if Cannot_Compute_High_Bound (Index) then + -- The upper bound is the higger bound to avoid reporting + -- spurious errors; this value will not be used at runtime + -- because this aggregate will be replaced by a raise CE node, + -- or the index type is formal of a generic unit. - Hi := Make_Attribute_Reference - (Loc, - Prefix => New_Occurrence_Of (Etype (Index), Loc), - Attribute_Name => Name_Pred, - Expressions => New_List (New_Copy_Tree (Lo))); + Hi := New_Copy_Tree (Lo); + + Report_Null_Array_Constraint_Error (N, Index_Typ); + Set_Raises_Constraint_Error (N); + + else + -- The upper bound is the predecessor of the lower bound + + Hi := Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Etype (Index), Loc), + Attribute_Name => Name_Pred, + Expressions => New_List (New_Copy_Tree (Lo))); + end if; Append (Make_Range (Loc, New_Copy_Tree (Lo), Hi), Constr); Analyze_And_Resolve (Last (Constr), Etype (Index)); @@ -4757,7 +5110,7 @@ package body Sem_Aggr is Next_Index (Index); end loop; - Set_Compile_Time_Known_Aggregate (N); + Set_Compile_Time_Known_Aggregate (N, Known_Bounds); Set_Aggregate_Bounds (N, First (Constr)); return True; From patchwork Tue Jul 2 13:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=MjGuSS4r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Vb0vfyz1xpc for ; Tue, 2 Jul 2024 23:22:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62D47383E518 for ; Tue, 2 Jul 2024 13:22:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 21FE5388211E for ; Tue, 2 Jul 2024 13:21:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21FE5388211E 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 21FE5388211E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926508; cv=none; b=ihhtBA55AkL88hu2tiJTyIo2LhkFlebgV9CoJG3uiecaj6t3fhu6r/ro4QFKCzSNI33IG7HYnOUMrjJTumbfB0m5KJExkgV9YwMppgGUyakj1Owiay+5XFMIVKbT6NSKJ4obETiVxvNaOuOBCSvuf0VKeaeJJ+IxTdYRpz2rb8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926508; c=relaxed/simple; bh=fADX8NV+LcP6rQB+GMlf32WZ9zC8ZwFQNA0IJSMpcv4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JL4mTQEUNZIwOHa6KPHhH4V4aWULvyadM2380G4TXGvBxEXrckw3Kdo6qlLCUoAopwgFJxv32jW2mtWMmMtC4owXLGM1PcGzbYNNo5dTyu5pW1eUdsYtKkvw0fpRafQGRGXy8PUQ8GTgCb0oRlaLzN3/Ds2rFySDhOIQP5pFKZE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ec52fbb50cso41084591fa.2 for ; Tue, 02 Jul 2024 06:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926503; x=1720531303; 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=5wxdZvst16FvqTHkv6qyBdr1tUQQxhySvF7tykbJ28o=; b=MjGuSS4rTn+zcgXZRzCoHmpUEqi0y5+B7QU9PFu1crEUke2wh+XYXpLW3GXi8Z7/ym egHvs/ErNQKX72Q9tFoLW3XOjVxesprsa3B5WqjxSywDzcjIS/adDpj6V69rHb20G9+m oEPISgS+uXC1XGbWHKzx6/NTWKDr5ai3kMIPWc0WpSOaamLwSujI+9m/9usf55I614x8 YkxlvS+68hAEtlR9EzIu09BD/YCt4COzocnc3Rqfrq/La9B5UJbFj2sOCgHdqFexfNWW BUGpSP6GwQJgYGA+qzveDD+uSFVs2H7V+CrWPFHstHXhWALzxDxN9687sVvwswYLocKS uPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926503; x=1720531303; 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=5wxdZvst16FvqTHkv6qyBdr1tUQQxhySvF7tykbJ28o=; b=DizttG3IwDjgdkdu4vfsOaMrsuCIFSCUT8rOvUyr0QQB/gI6lkYEQCyd/EYm7ACUak JMwDRuZN5a27qia1sKgH40KXIOSgc5za5fGeq0gzSf/2xoPwosP0skAcQis24gPnMqII BH5NURdSTOptZs0lWA6PIWFRPEVIcjovlF67AbCDkFanFch0ddhXOghBXHn/9aT4nyRY nVREUn6IgArZtybcMLWYm+u1pZA1LQ4tAwjY9UVMu8dZ/Jj9B/WG7oHp8LwdDgpooZDr vLbsYXw3saPuLTTNt7X0/S5+cQrcBt36aQwrQYU/7REu8CeECIt/91RX172/yl78ljb6 Ggdg== X-Gm-Message-State: AOJu0YxGzD2vdVh+xrX3vaQzOt2+viEMW1NMb3vwhQgsmlcbYI0XVUjB c2T70o28amy8mdpA7QJcBQxpRALQ3e5mp7ePsmSvwjqNylKo0h2Jso2Y1QQMBsap2iMGrFHjmXQ = X-Google-Smtp-Source: AGHT+IEoPasMqZcaykeWY83WMYTLuBferaRzTOWOUM7NW/h3jyfzBcCs7tURkFIBuhUT6FGHCRv7HQ== X-Received: by 2002:a2e:b8c8:0:b0:2ee:7a7e:8ebb with SMTP id 38308e7fff4ca-2ee7a7e903bmr3393621fa.52.1719926503476; Tue, 02 Jul 2024 06:21:43 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:42 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 04/13] ada: Fix bogus error on allocator in instantiation with private derived types Date: Tue, 2 Jul 2024 15:21:20 +0200 Message-ID: <20240702132130.523603-4-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-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~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou The problem is that the call to Convert_View made from Make_Init_Call does nothing because the Etype is not set on the second argument. gcc/ada/ * exp_ch7.adb (Convert_View): Add third parameter Typ and use it if the second parameter does not have an Etype. (Make_Adjust_Call): Remove obsolete setting of Etype and pass Typ in call to Convert_View. (Make_Final_Call): Likewise. (Make_Init_Call): Pass Typ in call to Convert_View. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch7.adb | 51 +++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 149715f94da..f4a707034c1 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -563,12 +563,16 @@ package body Exp_Ch7 is -- Check recursively whether a loop or block contains a subprogram that -- may need an activation record. - function Convert_View (Proc : Entity_Id; Arg : Node_Id) return Node_Id; - -- Proc is one of the Initialize/Adjust/Finalize operations, and Arg is the - -- argument being passed to it. This function will, if necessary, generate - -- a conversion between the partial and full view of Arg to match the type - -- of the formal of Proc, or force a conversion to the class-wide type in - -- the case where the operation is abstract. + function Convert_View + (Proc : Entity_Id; + Arg : Node_Id; + Typ : Entity_Id) return Node_Id; + -- Proc is one of the Initialize/Adjust/Finalize operations, Arg is the one + -- argument being passed to it, and Typ is its expected type. This function + -- will, if necessary, generate a conversion between the partial and full + -- views of Arg to match the type of the formal of Proc, or else force a + -- conversion to the class-wide type in the case where the operation is + -- abstract. function Make_Call (Loc : Source_Ptr; @@ -4023,7 +4027,11 @@ package body Exp_Ch7 is -- Convert_View -- ------------------ - function Convert_View (Proc : Entity_Id; Arg : Node_Id) return Node_Id is + function Convert_View + (Proc : Entity_Id; + Arg : Node_Id; + Typ : Entity_Id) return Node_Id + is Ftyp : constant Entity_Id := Etype (First_Formal (Proc)); Atyp : Entity_Id; @@ -4031,8 +4039,10 @@ package body Exp_Ch7 is begin if Nkind (Arg) in N_Type_Conversion | N_Unchecked_Type_Conversion then Atyp := Entity (Subtype_Mark (Arg)); - else + elsif Present (Etype (Arg)) then Atyp := Etype (Arg); + else + Atyp := Typ; end if; if Is_Abstract_Subprogram (Proc) and then Is_Tagged_Type (Ftyp) then @@ -5452,21 +5462,11 @@ package body Exp_Ch7 is end if; if Present (Adj_Id) then - - -- If the object is unanalyzed, set its expected type for use in - -- Convert_View in case an additional conversion is needed. - - if No (Etype (Ref)) - and then Nkind (Ref) /= N_Unchecked_Type_Conversion - then - Set_Etype (Ref, Typ); - end if; - -- The object reference may need another conversion depending on the -- type of the formal and that of the actual. if not Is_Class_Wide_Type (Typ) then - Ref := Convert_View (Adj_Id, Ref); + Ref := Convert_View (Adj_Id, Ref, Typ); end if; return @@ -7849,16 +7849,7 @@ package body Exp_Ch7 is end if; end; - -- If the object is unanalyzed, set its expected type for use in - -- Convert_View in case an additional conversion is needed. - - if No (Etype (Ref)) - and then Nkind (Ref) /= N_Unchecked_Type_Conversion - then - Set_Etype (Ref, Typ); - end if; - - Ref := Convert_View (Fin_Id, Ref); + Ref := Convert_View (Fin_Id, Ref, Typ); end if; return @@ -8314,7 +8305,7 @@ package body Exp_Ch7 is -- The object reference may need another conversion depending on the -- type of the formal and that of the actual. - Ref := Convert_View (Proc, Ref); + Ref := Convert_View (Proc, Ref, Typ); -- Generate: -- [Deep_]Initialize (Ref); From patchwork Tue Jul 2 13:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=MZ4RrQsq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3X23fcYz1xpc for ; Tue, 2 Jul 2024 23:23:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8F0C3882174 for ; Tue, 2 Jul 2024 13:23:44 +0000 (GMT) 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 A061D384602A for ; Tue, 2 Jul 2024 13:21:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A061D384602A 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 A061D384602A 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=1719926508; cv=none; b=X6mh6Q+VmvpTW9U4/joL4KzD9Qn0dz6ArJSw+0Ub/uHpUPCrG8stBdBVLV5eB0uCtGEoheVaGUhJPOe1oL+vIIMB2GFnc7TfzJB6HNB/DWfkLT6lcq3LTnw7H+dSqfo0wFDJs4L2ZpHPrpzulJqgP6m1SIYSPZFf3n3uvxhF/mI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926508; c=relaxed/simple; bh=RyXGgLGcQhScXclJTlykonobKO1dKa+SjmcbYddGH0U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Zq2QcURkbQgSL/33RQhYyDOgyBXpQAFTM8d7FGfzbv5h9yiqbDQu+XZD5dgq4Ss2f0qEtMjYGCjYUlmP27Sgb0U9zTjfssrZZkgbZMSBZuAEr6Ro1E+TDs9Ce1az15rMoGpUK9ad7dUR5jIkVYltRL+WzyPDp2TdnbiuP2f6eCM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42573d3f7e4so27344015e9.0 for ; Tue, 02 Jul 2024 06:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926504; x=1720531304; 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=9p4BMNqMSOnTWdjhNaC/F7LqH8imIZWBWCY3i1nExqM=; b=MZ4RrQsq6GoUjqm4vr9IHDviiOBXyy5JMbEFb8785Xq5EFRcJh3OByYBp4m+3n4/Ep saUiFGt7FYdLx1/5sHgAuW15yr+k0AOUC7z2aHsV8j7hAvGNKapMt34kOmgRW7uiqc7C U2HyeLHMMv6eb23tOYjtrzQa8AZpj7W0fRm2tIEqMLUjkAT9qGwRfaKYM+78wCcJV7Lf gamurl9l/BcDXtuCC9RGmpR39QPYh4i/ayeL9S/X/j/bc05Tz/78Rdt3uYLSKpc8Vhup p9lOVPxlzkVuqn9PR8OIiO8Q8padUWyfEX10xtMKG3fVM9wfIzkqVb5UV/RaVHNyOyY+ b26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926504; x=1720531304; 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=9p4BMNqMSOnTWdjhNaC/F7LqH8imIZWBWCY3i1nExqM=; b=SRZRs5qJeza0DwPaWz7Nsf51SWQ6m3BUngUtl3t13eWNMShycRHdj1pO/6gVDdgIC+ laqJsoKlP2sspsrZDZd3B9AAV17xtV8cZqBX+HEm/v91Rh2aFPnYMF47Hpfu36iKH+g9 8XMcsjVQKc+jeSFJb0IRvm/fIcNJLe7WqCmDywN6+mxsLW2EYwxzeGJe3xrEMhZaL33u y8/PeRVDuW1ta3dX+xJngQDnzawdcqnOKTnDwyXdoY126PQlDt9eS8E7flyspNxpWv21 NE6rg5+lSJAuplhz1SmxgX9R8vYCQb5wGQKenS4vPzXtGjHgwhzmCZIvMSAkAAmXLT4H 6gdA== X-Gm-Message-State: AOJu0YwT/2WlyXWXt7PwS3wPLdDITq/TLyqStn+VpeQfduv81DbtWZ5T UmlPa2+hxXs0x7X2DBispIUP3dKtwLU9mwj7B5Y1h7gKPYxdxCiXvMNTw7RpyqUpMQpltJWbvOk = X-Google-Smtp-Source: AGHT+IHQCKEGRBz/OWEGBIorzJIX0r9pBDXD3n3os8bDJV8v+iMGbWec8GzCQj168OgXjjihnvw/Lg== X-Received: by 2002:a7b:c3d9:0:b0:425:66fa:c7cc with SMTP id 5b1f17b1804b1-4257a0793acmr60937605e9.37.1719926504462; Tue, 02 Jul 2024 06:21:44 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:43 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED 05/13] ada: Fix analysis of Extensions_Visible Date: Tue, 2 Jul 2024 15:21:21 +0200 Message-ID: <20240702132130.523603-5-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Yannick Moy Pragma/aspect Extensions_Visible should be analyzed before any pre/post contracts on a subprogram, as the legality of conversions of formal parameters to classwide type depends on the value of Extensions_Visible. Now fixed. gcc/ada/ * contracts.adb (Analyze_Pragmas_In_Declarations): Analyze pragmas in two iterations over the list of declarations in order to analyze some pragmas before others. * einfo-utils.ads (Get_Pragma): Fix comment. * sem_prag.ads (Pragma_Significant_To_Subprograms): Fix. (Pragma_Significant_To_Subprograms_Analyzed_First): Add new global array to identify these pragmas which should be analyzed first, which concerns only Extensions_Visible for now. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/contracts.adb | 46 ++++++++++++++++++++++++----------------- gcc/ada/einfo-utils.ads | 1 + gcc/ada/sem_prag.ads | 10 +++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 9fc9e05db68..a93bf622aa1 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -546,33 +546,41 @@ package body Contracts is begin -- Move through the body's declarations analyzing all pragmas which - -- appear at the top of the declarations. + -- appear at the top of the declarations. Go over the list twice, so + -- that pragmas which should be analyzed first are analyzed in the + -- first pass. - Curr_Decl := First (Declarations (Unit_Declaration_Node (Body_Id))); - while Present (Curr_Decl) loop + for Pragmas_Analyzed_First in reverse False .. True loop - if Nkind (Curr_Decl) = N_Pragma then + Curr_Decl := First (Declarations (Unit_Declaration_Node (Body_Id))); + while Present (Curr_Decl) loop - if Pragma_Significant_To_Subprograms - (Get_Pragma_Id (Curr_Decl)) - then - Analyze (Curr_Decl); - end if; + if Nkind (Curr_Decl) = N_Pragma then - -- Skip the renamings of discriminants and protection fields + if Pragma_Significant_To_Subprograms + (Get_Pragma_Id (Curr_Decl)) + and then Pragmas_Analyzed_First = + Pragma_Significant_To_Subprograms_Analyzed_First + (Get_Pragma_Id (Curr_Decl)) + then + Analyze (Curr_Decl); + end if; - elsif Is_Prologue_Renaming (Curr_Decl) then - null; + -- Skip the renamings of discriminants and protection fields - -- We have reached something which is not a pragma so we can be sure - -- there are no more contracts or pragmas which need to be taken into - -- account. + elsif Is_Prologue_Renaming (Curr_Decl) then + null; - else - exit; - end if; + -- We have reached something which is not a pragma so we can be + -- sure there are no more contracts or pragmas which need to be + -- taken into account. + + else + exit; + end if; - Next (Curr_Decl); + Next (Curr_Decl); + end loop; end loop; end Analyze_Pragmas_In_Declarations; diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads index 01953c35bc3..8207576fb89 100644 --- a/gcc/ada/einfo-utils.ads +++ b/gcc/ada/einfo-utils.ads @@ -448,6 +448,7 @@ package Einfo.Utils is -- Effective_Reads -- Effective_Writes -- Exceptional_Cases + -- Extensions_Visible -- Global -- Initial_Condition -- Initializes diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads index 59220ea890c..557e0454870 100644 --- a/gcc/ada/sem_prag.ads +++ b/gcc/ada/sem_prag.ads @@ -216,6 +216,7 @@ package Sem_Prag is Pragma_Contract_Cases => True, Pragma_Depends => True, Pragma_Exceptional_Cases => True, + Pragma_Extensions_Visible => True, Pragma_Ghost => True, Pragma_Global => True, Pragma_Inline => True, @@ -238,6 +239,15 @@ package Sem_Prag is Pragma_Volatile_Function => True, others => False); + -- The following table lists all pragmas which are relevant to the analysis + -- of subprogram bodies and should be analyzed first, because the analysis + -- of other pragmas relevant to subprogram bodies depend on them. + + Pragma_Significant_To_Subprograms_Analyzed_First : + constant array (Pragma_Id) of Boolean := + (Pragma_Extensions_Visible => True, + others => False); + ----------------- -- Subprograms -- ----------------- From patchwork Tue Jul 2 13:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=YO/fRO3h; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3WH5tsHz1xpc for ; Tue, 2 Jul 2024 23:23:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF16A3882110 for ; Tue, 2 Jul 2024 13:23:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 94BBC38708D1 for ; Tue, 2 Jul 2024 13:21:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94BBC38708D1 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 94BBC38708D1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926511; cv=none; b=xO7azQ4rvnoQXdnoG5Ldd0ogL2GocIobQOHMkBg7h+46w32TqIIZZXswRdKbkfxM+Qwq2XuGAwpbY2kISvLFngEV/hdjhOL6gUI0rX4kUGloXvAavOySDVh1gjDrW9CvGVNjtuoDzEB3cMfztDov4pWa9dCFH4/ZOGUoWe52wMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926511; c=relaxed/simple; bh=1aLUNPZqSFUjR22zttHGaZVXxtNSrD2SW3E4xNBgjfs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cUmz7bbt2D4NlJ2LOtybHyFqDPLSci7JeWweMWTpgRoU3uENjiFjvtr/qtYMPDtmVKmoYIU/n6hyaZPHzLeIlJ+B6gjTMhSak5XK3cMrPJZYN7GcvIJRQxSAnMJ40hfXWkQ1ZFLjgmsofScXd7N89Qcu5CZGngq/OrxZeoxXhlU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so29629095e9.0 for ; Tue, 02 Jul 2024 06:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926505; x=1720531305; 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=2/v9jbjYtOwQosplBa2fryeM9BqKzxV4sYQo8V5DneM=; b=YO/fRO3hGge67wt3C4KX2do6+8MKjT+6A6BcZD8UGu6EBqlabDgLdLJgL09h+jwS71 0fG1A8Tm4DtMAFs55RMGoVBpl3Uw9F9Em7RmfkPbozZ5Irbs97aq8JfWLIQyggYqcvR9 ++vMtJiij3t6kLg8rrPAwv1+qLUPoyiWqV9jGag21HSnTY5aPo8X4zTJkbquwLWjvQyQ SY01cUk6MvE4o4p7ZQsvZCuU8P/taim+Q/vBo5awYvuaQaj4YTQ8OtdCZ+Jw57VnOjbP iesGgGxrPjdOcYZYXsTPYep+FWS7/YfMdCWp27Tj5QrADsI9COAYBLEyjqcoydSB+fMN ufnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926505; x=1720531305; 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=2/v9jbjYtOwQosplBa2fryeM9BqKzxV4sYQo8V5DneM=; b=XZ+oANBsQrzEJ9hotAdus8p0MFf0h52XHSeEjrm8DJFzsvxpP08NYujTxWcKAYSx+L U5WgYU/yfLSDDQ+Wo2nMhDE5Wu9l1vmD0x8FKVYgtaIIBR74Zeh72biHHnWuPY5sgVCC lP5Y5oD012/2a7S0VE4Ho7DmW9NGvAyw2e7wrW961po0uq1QQ8tJjGY7zBPddaNLFduZ ym179Ph6KzeEnKAUIMeo9s9YXc33EXFvX2VYv54TZWm2mPfWUW80lbgt/soSv6IjP/4C VnoO87T0nSAYCOddL5B9Gxja1RQqunynRv5xJREsMjrBmqfW2NiztGG8jLGELjXLdIu+ KkJA== X-Gm-Message-State: AOJu0YybIa5AkE4bJMf/DSIcZz8o8o1sx38IO9rp9F/RD261wlS+VsqQ r5XQCTL0uUxDXILn87yUldp4y5Pa/gO1cy+WUEnqVWtw6iS/UKjkTNC6vaMkNm8NQVg6Lg9uPGA = X-Google-Smtp-Source: AGHT+IEWfYrilMj9wBPM825UXqsTEZjV+6hoqi36yDEcm2nO+ZMp2TFhl0dlxQ5s6FQRByuTowqLiA== X-Received: by 2002:a05:600c:1992:b0:424:a403:565f with SMTP id 5b1f17b1804b1-4257a00da7bmr58430965e9.11.1719926505267; Tue, 02 Jul 2024 06:21:45 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:44 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 06/13] ada: Call memcmp instead of Compare_Array_Unsigned_8 and... Date: Tue, 2 Jul 2024 15:21:22 +0200 Message-ID: <20240702132130.523603-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou ... implement support for ordering comparisons of discrete array types. This extends the Support_Composite_Compare_On_Target feature to ordering comparisons of discrete array types as specified by RM 4.5.2(26/3), when the component type is a byte (unsigned). Implement support for ordering comparisons of discrete array types with a two-pronged approach: for types with a size known at compile time, this lets the gimplifier generate the call to memcmp (or else an optimize version of it); otherwise, this directly generates the call to memcmp. gcc/ada/ * exp_ch4.adb (Expand_Array_Comparison): Remove the obsolete byte addressibility test. If Support_Composite_Compare_On_Target is true, immediately return for a component size of 8, an unsigned component type and aligned operands. Disable when Unnest_Subprogram_Mode is true (for LLVM). (Expand_N_Op_Eq): Adjust comment. * targparm.ads (Support_Composite_Compare_On_Target): Replace bit by byte in description and document support for ordering comparisons. * gcc-interface/utils2.cc (compare_arrays): Rename into... (compare_arrays_for_equality): ...this. Remove redundant lines. (compare_arrays_for_ordering): New function. (build_binary_op) : Call compare_arrays_for_ordering to implement ordering comparisons for arrays. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 41 ++++++----- gcc/ada/gcc-interface/utils2.cc | 122 ++++++++++++++++++++++++++++---- gcc/ada/targparm.ads | 11 +-- 3 files changed, 138 insertions(+), 36 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 6a33734c443..e4c9de474ad 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -1162,9 +1162,6 @@ package body Exp_Ch4 is Comp : RE_Id; - Byte_Addressable : constant Boolean := System_Storage_Unit = Byte'Size; - -- True for byte addressable target - function Length_Less_Than_4 (Opnd : Node_Id) return Boolean; -- Returns True if the length of the given operand is known to be less -- than 4. Returns False if this length is known to be four or greater @@ -1198,11 +1195,12 @@ package body Exp_Ch4 is -- Start of processing for Expand_Array_Comparison begin - -- Deal first with unpacked case, where we can call a runtime routine - -- except that we avoid this for targets for which are not addressable - -- by bytes. + -- Deal first with unpacked case, where we can call a runtime routine, + -- except if the component type is a byte (unsigned) where we can use + -- a byte-wise comparison if supported on the target (this is disabled + -- for now in Unnest_Subprogram_Mode for LLVM). - if not Is_Bit_Packed_Array (Typ1) and then Byte_Addressable then + if not Is_Bit_Packed_Array (Typ1) then -- The call we generate is: -- Compare_Array_xn[_Unaligned] @@ -1214,9 +1212,18 @@ package body Exp_Ch4 is -- is the standard comparison operator if Component_Size (Typ1) = 8 then - if Length_Less_Than_4 (Op1) - or else - Length_Less_Than_4 (Op2) + if Is_Unsigned_Type (Ctyp) + and then not Is_Possibly_Unaligned_Object (Op1) + and then not Is_Possibly_Unaligned_Slice (Op1) + and then not Is_Possibly_Unaligned_Object (Op2) + and then not Is_Possibly_Unaligned_Slice (Op2) + and then Support_Composite_Compare_On_Target + and then not Unnest_Subprogram_Mode + then + return; + + elsif Length_Less_Than_4 (Op1) + or else Length_Less_Than_4 (Op2) then if Is_Unsigned_Type (Ctyp) then Comp := RE_Compare_Array_U8_Unaligned; @@ -1261,11 +1268,10 @@ package body Exp_Ch4 is end if; end if; - if RTE_Available (Comp) then - - -- Expand to a call only if the runtime function is available, - -- otherwise fall back to inline code. + -- Expand to a call only if the runtime function is available, + -- otherwise fall back to inline code. + if RTE_Available (Comp) then Remove_Side_Effects (Op1, Name_Req => True); Remove_Side_Effects (Op2, Name_Req => True); @@ -1292,8 +1298,7 @@ package body Exp_Ch4 is Attribute_Name => Name_Length))); Zero : constant Node_Id := - Make_Integer_Literal (Loc, - Intval => Uint_0); + Make_Integer_Literal (Loc, Intval => Uint_0); Comp_Op : Node_Id; @@ -8230,8 +8235,8 @@ package body Exp_Ch4 is then Expand_Packed_Eq (N); - -- Where the component type is elementary we can use a block bit - -- comparison (if supported on the target) exception in the case + -- When the component type is elementary, we can use a byte-wise + -- comparison if supported on the target, except in the cases -- of floating-point (negative zero issues require element by -- element comparison), and full access types (where we must be sure -- to load elements independently) and possibly unaligned arrays. diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index d101d7729bf..0d7e03ec6b0 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -283,7 +283,7 @@ find_common_type (tree t1, tree t2) tests in as efficient a manner as possible. */ static tree -compare_arrays (location_t loc, tree result_type, tree a1, tree a2) +compare_arrays_for_equality (location_t loc, tree result_type, tree a1, tree a2) { tree result = convert (result_type, boolean_true_node); tree a1_is_null = convert (result_type, boolean_false_node); @@ -357,8 +357,6 @@ compare_arrays (location_t loc, tree result_type, tree a1, tree a2) ub1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (ub1, a1); comparison = fold_build2_loc (loc, LT_EXPR, result_type, ub1, lb1); - if (EXPR_P (comparison)) - SET_EXPR_LOCATION (comparison, loc); this_a1_is_null = comparison; this_a2_is_null = convert (result_type, boolean_true_node); @@ -380,9 +378,6 @@ compare_arrays (location_t loc, tree result_type, tree a1, tree a2) ub1, lb1), build_binary_op (MINUS_EXPR, base_type, ub2, lb2)); - if (EXPR_P (comparison)) - SET_EXPR_LOCATION (comparison, loc); - this_a1_is_null = fold_build2_loc (loc, LT_EXPR, result_type, ub1, lb1); @@ -397,8 +392,6 @@ compare_arrays (location_t loc, tree result_type, tree a1, tree a2) comparison = fold_build2_loc (loc, EQ_EXPR, result_type, length1, length2); - if (EXPR_P (comparison)) - SET_EXPR_LOCATION (comparison, loc); lb1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (lb1, a1); ub1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (ub1, a1); @@ -464,6 +457,89 @@ compare_arrays (location_t loc, tree result_type, tree a1, tree a2) return result; } +/* Return an expression tree representing an ordering comparison of A1 and A2, + two objects of type ARRAY_TYPE. The result should be of type RESULT_TYPE. + + A1 is less than A2 according to the following alternative: + - when A1's length is less than A2'length: if every element of A1 is equal + to its counterpart in A2 or the first differing is lesser in A1 than A2, + - otherwise: if not every element of A2 is equal to its counterpart in A1 + and the first differing is lesser in A1 than A2. + + The other 3 ordering comparisons can be easily deduced from this one. */ + +static tree +compare_arrays_for_ordering (location_t loc, tree result_type, tree a1, tree a2) +{ + const bool a1_side_effects_p = TREE_SIDE_EFFECTS (a1); + const bool a2_side_effects_p = TREE_SIDE_EFFECTS (a2); + tree t1 = TREE_TYPE (a1); + tree t2 = TREE_TYPE (a2); + tree dom1 = TYPE_DOMAIN (t1); + tree dom2 = TYPE_DOMAIN (t2); + tree length1 = size_binop (PLUS_EXPR, + size_binop (MINUS_EXPR, + TYPE_MAX_VALUE (dom1), + TYPE_MIN_VALUE (dom1)), + size_one_node); + tree length2 = size_binop (PLUS_EXPR, + size_binop (MINUS_EXPR, + TYPE_MAX_VALUE (dom2), + TYPE_MIN_VALUE (dom2)), + size_one_node); + tree addr1, addr2, fndecl, result; + + /* If the lengths are known at compile time, fold the alternative and let the + gimplifier optimize the case of power-of-two lengths. */ + if (TREE_CODE (length1) == INTEGER_CST && TREE_CODE (length2) == INTEGER_CST) + return tree_int_cst_compare (length1, length2) < 0 + ? fold_build2_loc (loc, LE_EXPR, result_type, a1, convert (t1, a2)) + : fold_build2_loc (loc, LT_EXPR, result_type, convert (t2, a1), a2); + + /* If the operands have side-effects, they need to be evaluated only once + in spite of the multiple references in the comparison. */ + if (a1_side_effects_p) + a1 = gnat_protect_expr (a1); + + if (a2_side_effects_p) + a2 = gnat_protect_expr (a2); + + length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); + length2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length2, a2); + + /* If the lengths are not known at compile time, call memcmp directly with + the actual lengths since a1 and a2 may have the same nominal subtype. */ + addr1 = build_fold_addr_expr_loc (loc, a1); + addr2 = build_fold_addr_expr_loc (loc, a2); + fndecl = builtin_decl_implicit (BUILT_IN_MEMCMP); + + result + = fold_build3_loc (loc, COND_EXPR, result_type, + fold_build2_loc (loc, LT_EXPR, boolean_type_node, + length1, length2), + fold_build2_loc (loc, LE_EXPR, result_type, + build_call_expr_loc (loc, fndecl, 3, + addr1, addr2, + length1), + integer_zero_node), + fold_build2_loc (loc, LT_EXPR, result_type, + build_call_expr_loc (loc, fndecl, 3, + addr1, addr2, + length2), + integer_zero_node)); + + /* If the operands have side-effects, they need to be evaluated before + doing the tests above since the place they otherwise would end up + being evaluated at run time could be wrong. */ + if (a1_side_effects_p) + result = build2 (COMPOUND_EXPR, result_type, a1, result); + + if (a2_side_effects_p) + result = build2 (COMPOUND_EXPR, result_type, a2, result); + + return result; +} + /* Return an expression tree representing an equality comparison of P1 and P2, two objects of fat pointer type. The result should be of type RESULT_TYPE. @@ -1176,12 +1252,32 @@ build_binary_op (enum tree_code op_code, tree result_type, || (TREE_CODE (right_type) == INTEGER_TYPE && TYPE_HAS_ACTUAL_BOUNDS_P (right_type)))) { - result = compare_arrays (input_location, - result_type, left_operand, right_operand); - if (op_code == NE_EXPR) - result = invert_truthvalue_loc (EXPR_LOCATION (result), result); + if (op_code == EQ_EXPR || op_code == NE_EXPR) + { + result + = compare_arrays_for_equality (input_location, result_type, + left_operand, right_operand); + if (op_code == NE_EXPR) + result = invert_truthvalue_loc (input_location, result); + } + else - gcc_assert (op_code == EQ_EXPR); + { + /* Swap the operands to canonicalize to LT_EXPR or GE_EXPR. */ + if (op_code == GT_EXPR || op_code == LE_EXPR) + result + = compare_arrays_for_ordering (input_location, result_type, + right_operand, left_operand); + + else + result + = compare_arrays_for_ordering (input_location, result_type, + left_operand, right_operand); + + /* GE_EXPR is (not LT_EXPR) for discrete array types. */ + if (op_code == GE_EXPR || op_code == LE_EXPR) + result = invert_truthvalue_loc (input_location, result); + } return result; } diff --git a/gcc/ada/targparm.ads b/gcc/ada/targparm.ads index 050eb25c12c..323a41dcc8b 100644 --- a/gcc/ada/targparm.ads +++ b/gcc/ada/targparm.ads @@ -359,11 +359,12 @@ package Targparm is -- the flag is set False, and composite assignments are not allowed. Support_Composite_Compare_On_Target : Boolean := True; - -- If this flag is True, then the back end supports bit-wise comparison - -- of composite objects for equality, either generating inline code or - -- calling appropriate (and available) run-time routines. If this flag - -- is False, then the back end does not provide this support, and the - -- front end uses component by component comparison for composites. + -- If this flag is True, then the back end supports byte-wise comparison + -- of arrays for equality operations and lexicographic comparison of 1- + -- dimensional arrays of bytes for ordering operations, either by means + -- of generating inline code or calling appropriate routines like memcmp. + -- If this flag is False, then the back end does not provide this support, + -- and the front end uses component by component comparison for arrays. Support_Long_Shifts_On_Target : Boolean := True; -- If True, the back end supports 64-bit shift operations. If False, then From patchwork Tue Jul 2 13:21:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=kxGBojtR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3XL69X0z1xpc for ; Tue, 2 Jul 2024 23:24:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C53C384602A for ; Tue, 2 Jul 2024 13:24:01 +0000 (GMT) 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 4E8163882123 for ; Tue, 2 Jul 2024 13:21:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E8163882123 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 4E8163882123 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=1719926510; cv=none; b=WjigNxUOEIlpTKz825172jQS/IvmRRYQpC4rw1djXm//DKJfgpUAjnj/smp5FQiY6i3EJkv3uGGmOrryFNOrqAb57refRwfrhfBmxJJH+sEsRLDG4TgHU0Z0r1fQjYjpRlD2+zFFVNIfsuR0L+d5POLITWbbCRa8g9oLTN6INh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926510; c=relaxed/simple; bh=YM+g8Oh4IJ+CS7K6YiHe1753VC/VfPQDKviPpI2D5Y4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RvGLTrDMc/28Qk4DUIVPhy/oC07BW4/GD27HrLchIhoeQ96awD6i95bhDLdE8gQrEF928NmOkqqhi0t2pogHD0WeP3v/lPLPQcQ7QXcP7TGfOZemEkzRfL9iZNJft/ZFwAF2KZvmTc+v/3/EL/QenXOpWr2i30jmStNDxNWEnMo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-424aa70fbc4so29100805e9.1 for ; Tue, 02 Jul 2024 06:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926506; x=1720531306; 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=sJT2AMkJTGlleRmathZBaYZ5nkydnB6BvVZiZBknaqw=; b=kxGBojtRvwGNBiejtZvn9QI8CnfRJfMmyO+QGB+D7w4K1RMXe8fqJLBB+nqURNWcK7 vmkjpRgPnaJRoPrjMRZEW5xESJsIWo4tIZWAXC/r/KyIHf98PmfuBGXHiPVaoQoJnXi3 lfsDlt7C5zSChcu0GZzzgp3nGHhmtNoGJ1+S52B/E/YeQCzebo2sCej+Xtqjpddidj/5 BZcJlKjMt5Sw4hA3f8aQ2VUvisXo9gIYzm0RLPOrRvSDw5LJnA40YCrHmwiron/YtHH9 mKxRRwHFftJ+kA7ZSIYSnM4TaTV/WRMntXWmHJ37Ni4YEibF0BxC+8PinrHMR4ZJK74Z QZOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926506; x=1720531306; 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=sJT2AMkJTGlleRmathZBaYZ5nkydnB6BvVZiZBknaqw=; b=chudwndcpx2nJjbdX3VJGXUWDZ4tbfVNfqAsuqWEVCDXsLEPSds5CJb3tuclCd3E8O RzNYDuRM2GRtbDydFxIn3LA8PF33zm6LqF1uOj1qgDKsgeE/Ae/+4HXCXEJ15mB0sxlu COm1yT7rS/lnWuGzFXBgREPqWEAj+IcpAW8DvdkY4SWfosj+MW5o+qWRMtUlQLkDxXLg j+zSiHx+MMEDlBKqXZ1rRAcN/ie4AhZbfuTngRNFN0wvZPPs+VOTpt3E0EZMGKfXDPtt Po/tO9s2Z3ShPe1nfg/QKPfDzQvaS5tWEwl7VOiUZHVER5/lWOaEr5miKx6q3tubpsmm odzg== X-Gm-Message-State: AOJu0Yy+PWtqiT2+/J/sWRb0pSIEva3CPoS68dD25DTtqEiYjIDqh4kO PxN4Z3yDyLy5tuuaZu6YMdn6r0Kia+sz8Ij3WvRA6JCVWXTBkja5KlVxHbJFD5gdJgVELZ2ag4A = X-Google-Smtp-Source: AGHT+IF02TEAgzJg7S+xuQMt7MjNJZLE2Uba4oLaZpRWgGyq7WVTB72sHZWEHVMkZnFFXt0SRGXCNQ== X-Received: by 2002:a05:600c:1989:b0:425:6bc4:977b with SMTP id 5b1f17b1804b1-4257a06df09mr74491885e9.26.1719926506201; Tue, 02 Jul 2024 06:21:46 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:45 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 07/13] ada: Bug box for expression function with list comprehension Date: Tue, 2 Jul 2024 15:21:23 +0200 Message-ID: <20240702132130.523603-7-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Bob Duff GNAT crashes on an iterator with a filter inside an expression function that is the completion of an earlier spec. gcc/ada/ * freeze.adb (Freeze_Type_Refs): If Node is in N_Has_Etype, check that it has had its Etype set, because this can be called early for expression functions that are completions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 757c16e6839..7cf7e847677 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -9137,6 +9137,7 @@ package body Freeze is -- that type is not attached to an entity in the construct. elsif Nkind (Node) in N_Has_Etype + and then Present (Etype (Node)) and then Nkind (Parent (Node)) = N_Iterator_Specification and then Node = Name (Parent (Node)) then From patchwork Tue Jul 2 13:21:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SvSIc0hi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Yb6YqXz1xqb for ; Tue, 2 Jul 2024 23:25:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E5123861878 for ; Tue, 2 Jul 2024 13:25:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id D9CAA3882654 for ; Tue, 2 Jul 2024 13:21:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9CAA3882654 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 D9CAA3882654 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926511; cv=none; b=XnJSL0W285QsZ8SIgAGf2f4638cQ2NFpWIc0QXeeIiYmU1rT0y1+nEdkGz53JKxX8c6XKPEhGW4aHxGLwQfrBxucMUJBmrW+8HZW9xWwI6BwZ93EMMKM06uF8TJQaQHBMEgAOxmHbiA333SSEMpI1A1+C58Y12lGCAs6CKn3Utc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926511; c=relaxed/simple; bh=Ch2OLozQoqsWEruRwRv9s4OwdMxaOHaoOHdygPFhG3E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YRs90x0E9sikzB1gmfCd37XnEn2lsUL1ubcdA1kpnKCriFCgo1/rxl9UQBasYlr+gL3kLXXh3vTWKVrG5YY4p+Et5q9VBTZxfs8hw8xF/8Zkf3aMLM+AtUJ3k3X/3Ghe1KvcOR0nl2eOdd9PdnqRkMoPFK4FN/dlegI0NI4lTWg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cdfb69724so5217696e87.1 for ; Tue, 02 Jul 2024 06:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926507; x=1720531307; 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=jLtVUC/AOIm6QvQEpa80bMzWg+j89I61RsATLu2LLPg=; b=SvSIc0higRhpIGXaugc3Uax77kQKxtt2J9jeeO32QJfhEUomW1FuglttHpRuSRDBmB H5GiYZgkidbgBjXm7BeGEMJztMTy5gIQWXs74L2PWlHmhCrXa0m+PuHeDJ/+osButFkT lo3RbOmh9bNbpHBQDrlSNAbI+SdJMetpMlazPrJSzuUyAmnamJGC03owVDppBj2rieiJ 652NmmAgpIpoW5bdmg8jzvNq9szPGbPwq0JMV2n19ZtzEGFXWgiWaZK+XTWA+hLMv8Ws QTpAsOGQWUxgk3gEiWi08eD50p/Rw+zJgBlcA+3eJiB41OwavkXPAV5nhTwKF9F7M8cQ bH2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926507; x=1720531307; 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=jLtVUC/AOIm6QvQEpa80bMzWg+j89I61RsATLu2LLPg=; b=vGOX6PP4O3a9nBysaUubNvaeomhp8GgDQllf9bGD/K+eHo2qy9rhMPZLe0D+Sw1AOw GwU0YKzGY4+aoynSHB9DsVjAAJnAeqWn8kG0Kt3f0JFO4LGd1dGQY9LJYkMSaGnOrNJU yBaDBxX72KKB6tkLMYnCOgklxTFFzUNyEJz8/a+25T2BfnaU2SrRYcv3+knLp0s9E+dL ZlMP5hluaUBXelPgRWDVHFIK3SbPm0RJS95G8qNZB5bySpnVTgs57z/cbWDIl4yEI/0w 2KFosky+TbXIh3OFFqIZPIJaQ+LRMzxkSp84FQXxOzUQ4VOrcSOKwoAqbMb578OkRo9t bWfg== X-Gm-Message-State: AOJu0YyyA3sxrgSR9pOWZm2NIR5JFw8AWrNTrIsKv7cAqt4nj8Dq/PZX NL+TLQJHNlKeW7xXruiBkDoUVHYchIxiGusaKPfmlwA1SxS2Ok6tkc1q7Ll71aiCLrcAWOf7ysw = X-Google-Smtp-Source: AGHT+IEMd/xqEbVdicvS1GZHuEq/NvMuDD02GWCh+WHHyZe4Effs79p7dpJFHZhWKg1Fg6ZcZja35Q== X-Received: by 2002:a05:6512:224f:b0:52d:8356:f6b9 with SMTP id 2adb3069b0e04-52e8268e062mr5584372e87.38.1719926507214; Tue, 02 Jul 2024 06:21:47 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:46 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [COMMITTED 08/13] ada: Allow mutably tagged types to work with qualified expressions Date: Tue, 2 Jul 2024 15:21:24 +0200 Message-ID: <20240702132130.523603-8-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Justin Squirek This patch modifies the experimental 'Size'Class feature such that objects of mutably tagged types can be assigned qualified expressions featuring a definite type (e.g. Mutable_Obj := Root_Child_T'(Root_T with others => <>)). gcc/ada/ * sem_ch5.adb: (Analyze_Assignment): Add special expansion for qualified expressions in certain cases dealing with mutably tagged types. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch5.adb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 644bd21ce93..5739fe06ea2 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -697,6 +697,19 @@ package body Sem_Ch5 is then Resolve (Rhs, Base_Type (T1)); + -- When the right hand side is a qualified expression and the left hand + -- side is mutably tagged we force the right hand side to be class-wide + -- so that they are compatible both for the purposes of checking + -- legality rules as well as assignment expansion. + + elsif Is_Mutably_Tagged_Type (T1) + and then Nkind (Rhs) = N_Qualified_Expression + then + Make_Mutably_Tagged_Conversion (Rhs, T1); + Resolve (Rhs, T1); + + -- Otherwise, resolve the right hand side normally + else Resolve (Rhs, T1); end if; @@ -765,6 +778,7 @@ package body Sem_Ch5 is and then not Is_Class_Wide_Type (T2) and then not Is_Tag_Indeterminate (Rhs) and then not Is_Dynamically_Tagged (Rhs) + and then not Is_Mutably_Tagged_Type (T1) then Error_Msg_N ("dynamically tagged expression required!", Rhs); end if; From patchwork Tue Jul 2 13:21:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=RMzoHb2H; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Xf4d7zz1xpc for ; Tue, 2 Jul 2024 23:24:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBB44383E518 for ; Tue, 2 Jul 2024 13:24:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 077773882170 for ; Tue, 2 Jul 2024 13:21:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 077773882170 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 077773882170 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926512; cv=none; b=FoOL5gLapchmCyi2bSo694z5wdwxW7h0ONIWRJHT9dZW/uSfpV5wleO1wDJxJaYN7HiOlUGzDnP2ysE5F3NsQTw92cJmBvwyFVsTrHGrCOUShd4vn4cHMGiNMX8nvJK4/hc6pfovsgR26XZpV7/RkeGelRTc87obQBqR4s5U+9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926512; c=relaxed/simple; bh=Yk1yg5gwviznjMzHG689ibybL3FYLvt6AvneMaU8wWM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KynEHb5puiX/wMhD9uEJFtiqRIGSgt8R679TGKnwQICykeuHA85yf1V4o4yJZhs3oPFYM/XjL25VvOAaxjwaajkht1oiIxrFiJcYMlDzpeUBj7OBLxkLJWUU/Yer6sJY+yMQjsK0SnbrSxBWyxZRQji0HpbQvmA1KzwcpRoUiAw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so29629675e9.0 for ; Tue, 02 Jul 2024 06:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926509; x=1720531309; 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=yef6pscfrYh+jFwiboaADYCUODoP0gTHVFnbsXN8oHE=; b=RMzoHb2HHCfqR2OFci7qfMrfaCuSZac2pM07tpE3nYoDOFLOSOQAG8Y9iEKk7w/sf2 K/IZOv3YjvQSzvAnDC0k8D1ZAIWA8IcbgN1RD52wDZhBHPXfJxxNpcmALlzJAA4cARty kATxPK2DlKeLuFS2ABB3xwnImAaT2TPJd5DKi+LzUmd2UexspuwwAq65qaWWtPSUcFAY hWymYuZiFBb92ZW/HzTkxQDXWXnIK3RWMfXVEMXKwYVIubsy5kt32wMQvATFb8cNIbGg G06qyCCIUNge62Vk4QI/ervLJtQRmmdxoGpnOd06x3qdppLNe+9lTyuLpZwgnZz1GrIu 1L1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926509; x=1720531309; 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=yef6pscfrYh+jFwiboaADYCUODoP0gTHVFnbsXN8oHE=; b=SdiBmFMVG8oL0ZCufvEDvCoCU1RWASkJoA6r4DlZ9E/zzYWccR1Ymxhjczx6DjwnQX uGCdyeLbPFG+g4899lZl7ILz8n+32QWWm5o+vurlyg2zDifno3y9psST9pwfmeJc2R91 xjn91QcuPMdYjHVTLBL0Fg2gWKab7imidgB5Vf2dNhLuxVsoJtK4qKAQaJcpMF7qG8Se 6gWaSJdaNDfc6ACSqdmv0JOJs9mecsBcpO7Fn8mvXaolOzi26251leY8II/yHzrwnqfg Yretl/nd7Nmikdk8ZrvJ3fYxpP72XUKNxLk32vMcI8yvdewBY7bFGNgD/laQ/7Kd4S5l PUJg== X-Gm-Message-State: AOJu0YzLsFCl3Rm7xQATwJaE7ONh0B1EN5glogen/Oetqni6NB6SSg/P vVONjnkzzjlP2MU+7kQfBylur5w1uAtuRDn0WFT38bfqITyv5qgfocVU0TwZmuCFJSZt0zy/Teo = X-Google-Smtp-Source: AGHT+IH+ANV69g5qk1M1au3ViurvvOU52rFvaUhPES8aYDhi6W+HsTeehimn3zxDuVRGni5Ldi/AQA== X-Received: by 2002:a05:600c:310c:b0:425:6171:5d26 with SMTP id 5b1f17b1804b1-4257a0347d4mr61795625e9.36.1719926508828; Tue, 02 Jul 2024 06:21:48 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:47 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 09/13] ada: Put_Image aspect spec ignored for null extension. Date: Tue, 2 Jul 2024 15:21:25 +0200 Message-ID: <20240702132130.523603-9-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Steve Baird If type T1 is is a tagged null record with a Put_Image aspect specification and type T2 is a null extension of T1 (with no aspect specifications), then evaluation of a T2'Image call should include a call to the specified procedure (as opposed to yielding "(NULL RECORD)"). gcc/ada/ * exp_put_image.adb (Build_Record_Put_Image_Procedure): Declare new Boolean-valued function Null_Record_Default_Implementation_OK; call it as part of deciding whether to generate "(NULL RECORD)" text. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_put_image.adb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_put_image.adb b/gcc/ada/exp_put_image.adb index 94299e39661..bf14eded93e 100644 --- a/gcc/ada/exp_put_image.adb +++ b/gcc/ada/exp_put_image.adb @@ -580,6 +580,18 @@ package body Exp_Put_Image is function Make_Component_Name (C : Entity_Id) return Node_Id; -- Create a call that prints "Comp_Name => " + function Null_Record_Default_Implementation_OK + (Null_Record_Type : Entity_Id) return Boolean + is + (if Has_Aspect (Null_Record_Type, Aspect_Put_Image) + then False + elsif not Is_Derived_Type + (Implementation_Base_Type (Null_Record_Type)) + then True + else Null_Record_Default_Implementation_OK + (Implementation_Base_Type (Etype (Null_Record_Type)))); + -- return True iff ok to emit "(NULL RECORD)" for given null record type + ------------------------------------ -- Make_Component_List_Attributes -- ------------------------------------ @@ -852,7 +864,10 @@ package body Exp_Put_Image is Type_Name)))); end; end if; - elsif Is_Null_Record_Type (Btyp, Ignore_Privacy => True) then + + elsif Is_Null_Record_Type (Btyp, Ignore_Privacy => True) + and then Null_Record_Default_Implementation_OK (Btyp) + then -- Interface types take this path. From patchwork Tue Jul 2 13:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=jHfx2KOi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Yk0qj7z1xpN for ; Tue, 2 Jul 2024 23:25:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C6813882641 for ; Tue, 2 Jul 2024 13:25:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id B9367388216C for ; Tue, 2 Jul 2024 13:21:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9367388216C 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 B9367388216C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926514; cv=none; b=WCIx/btq0LXD+ROalguQLOanZIyZYxIOhsW0+VCTgEIii+32cTOteMd2wz82qalzWqo4JO0P2GJaHBsGsdFizUNiWBzpM4yde+LnfR/MPrKC/A29AyHgo/vA49THRVeC2xir93U1NFCVVRApEMwPEYTe4MWRgyRZ1xTWBV6QfdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926514; c=relaxed/simple; bh=/GxHsv+jg/uNpVUlWo4C8qgCTn2XAywxH5uiAU/z194=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=svrs592JSoYqqBkj5oVsGozbhmFx6UxR2dnjZLxUyKPIonVRhpxdEX0Zs5mYkvXZu2JVedTchpki77sRgfX7qEk+VrAvQwYLuEr9Pchs4Wmytne5FTLCPZf/egVqId0+hQVCnF3g4lA0U5QWIymhXPZ2MvIN4KKMDLRwHJ21oUQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec58040f39so40419671fa.2 for ; Tue, 02 Jul 2024 06:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926510; x=1720531310; 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=2hB970Xj3uFG7x1pYRL22JrNBFDkGID6VynyzsvQ3f0=; b=jHfx2KOirORAzucQOWXM1qgd52i8xVPJeve8xL04N9V1TjJ4es2J/uq7Vt/zXzlHrl 6oW7Ll2NtB+AsRCxAH3N/t8nt/V307qqmMPf5FvK1PzxTizHYZgTdEqzDcQFiMNjBhxt 2jo7dWOtNLPBVcAz3zdsmZBUXkouJc1p5mKdBC0MceqmD4Z8IxLHhOOLdA1fYH7dui6N CzZA/ZyUPN0gMEOkzIBH6/MhZ+h6HSEHjNtRFBPUXpfX37m66EulgFDv0hQk+j6v4iGG U4jGNcmZUJLX2mdFvcoUPtSV+wxYcYmGwjDt7GYFmUc25nRsCzoK8r3zbVGdA8aajDwf 8AWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926510; x=1720531310; 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=2hB970Xj3uFG7x1pYRL22JrNBFDkGID6VynyzsvQ3f0=; b=qaHrOAk/sJge7fKy0LRyahPpqSxlaDDa1KcXpQg5BsD9O83O7qNLmVf6ERgI4XE3tN 4SKgYtHbL1WaSe4iAEM0R4knuqB+fboO4s4l7f0HhnVDQurJnHTn8f9ca1dcAO+bOT6R qcqvt+YmfY85s4MYwCw/qDyM3aA7YCgI2OrN/Zpmp0WsmEFbhQ9MwJ6W6+428axsTRet SOkeTpOqYZQeRD+k/NalYmwev0Jz96iQbjPacv0BhdRfByY+MR8q86l+D/EaazaX8qy1 2Wbw8lRAbSeZeVfnRFJdUDYeZEflVnwmPq0YKd/uubpnD1hOP2nm9/866igKUa16plLE I5bw== X-Gm-Message-State: AOJu0YyPmL8BRd8CtGGv6sKiSK1pw5LG/v3lgESBtscHL+uKwC7dXPy+ pdN4QvKeB/m+dyRqM8vvQwbDsENrRH6s1v/T6PzcAUCJDiGb2+Q40/RbcYD4BNHeghKBr5V5TF0 = X-Google-Smtp-Source: AGHT+IEGM6rOORl+SAIfFhGbjb1gYje1Uj1eC3yILpfsu3reRTK3ulnZM2shcrvmtjgV69etSsW4ZA== X-Received: by 2002:a2e:a4a2:0:b0:2ec:40ab:694d with SMTP id 38308e7fff4ca-2ee5e3594e5mr52672991fa.1.1719926510173; Tue, 02 Jul 2024 06:21:50 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:49 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 10/13] ada: Use clause (or use type clause) in a protected operation sometimes ignored. Date: Tue, 2 Jul 2024 15:21:26 +0200 Message-ID: <20240702132130.523603-10-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Steve Baird In some cases, a use clause (or a use type clause) occurring within a protected operation is incorrectly ignored. gcc/ada/ * exp_ch9.adb (Expand_N_Protected_Body): Declare new procedure Unanalyze_Use_Clauses and call it before analyzing the newly constructed subprogram body. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch9.adb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index a8c70598fa5..939a8e25d5a 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -8316,6 +8316,11 @@ package body Exp_Ch9 is -- P (Param1 .. ParamN); -- end + procedure Unanalyze_Use_Clauses (Op_Body : Node_Id); + -- Use and Use_Type clauses in the tree rooted at Op_Body + -- that have already been analyzed need to be marked as unanalyzed + -- because otherwise they will be ineffective in their new context. + --------------------------------------- -- Build_Dispatching_Subprogram_Body -- --------------------------------------- @@ -8377,6 +8382,31 @@ package body Exp_Ch9 is Make_Handled_Sequence_Of_Statements (Loc, Stmts)); end Build_Dispatching_Subprogram_Body; + --------------------------- + -- Unanalyze_Use_Clauses -- + --------------------------- + + procedure Unanalyze_Use_Clauses (Op_Body : Node_Id) is + + function Process_One_Node (N : Node_Id) return Traverse_Result; + -- If N is a use or use type node then unanalyze it. + + procedure Process_Tree is new Traverse_Proc (Process_One_Node); + + function Process_One_Node (N : Node_Id) return Traverse_Result is + begin + if Nkind (N) in N_Use_Package_Clause | N_Use_Type_Clause then + Set_Analyzed (N, False); + end if; + return OK; -- return Skip if Is_Analyzed (N) ? + end Process_One_Node; + + -- Start of processing for Analyze_Use_Clauses + + begin + Process_Tree (Op_Body); + end Unanalyze_Use_Clauses; + -- Start of processing for Expand_N_Protected_Body begin @@ -8426,6 +8456,17 @@ package body Exp_Ch9 is Build_Unprotected_Subprogram_Body (Op_Body, Pid); end if; + -- Ugly. + -- We are going to perform name resolution in analysis of + -- this new body, but any already-analyzed use clauses + -- will be ineffective in this new context unless we take + -- action to "reactivate" them. So that's what we do here. + -- We arguably shouldn't be performing name resolution + -- here (just like we shouldn't perform name resolution in + -- an expanded instance body), but that's a larger issue. + + Unanalyze_Use_Clauses (New_Op_Body); + Insert_After (Current_Node, New_Op_Body); Current_Node := New_Op_Body; Analyze (New_Op_Body); From patchwork Tue Jul 2 13:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=gEhlrPNz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Zj5wKXz1xpN for ; Tue, 2 Jul 2024 23:26:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1669F3882126 for ; Tue, 2 Jul 2024 13:26:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id DC93F3882073 for ; Tue, 2 Jul 2024 13:21:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC93F3882073 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 DC93F3882073 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926515; cv=none; b=kppYZP0l1hdmt8y6mfpJ6JGvrxh72LFg2esxmZ8vD1e7TYSkTlBFMid2j3tCal2Xf6qhYFgYqx9IpTeDtK88hSWCj4HTR2o7RztXx5VaTRCz1LBxLu7+QwAYlcbpXYnuFON4fke1zjpvyaCDFmljsQyqAXA4FjDQP+M/iLyweH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926515; c=relaxed/simple; bh=wUDfO6a1BzqUOq7YGWgq1msHs+lBArG11ERciAkoXDo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ChFtGdHCgxo3ijtA/2xhkNc/hgczoB6RTAaDlgzFplztBmSC/YCj46RYuAqoaeOvvmybIDoWtJ9m4iJX+1jj50VJI5jdoLqfGEI8GvGcCf6vjkSFjmhr4fmFi2ZSevV6g4musJ8befB4u89y+0aOwrpejbeq6of3xx2biAyJRw8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52cd628f21cso4364616e87.3 for ; Tue, 02 Jul 2024 06:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926511; x=1720531311; 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=dJ2rMI0TSHRDo+bfesaPBFAqGyrvqALIQhOnMBElujo=; b=gEhlrPNz7PXNb2DYLDWJOVgtwfuRLXSUsaFLrIAIJWMRUUCsAcMeSyJ8bhWrlJbFyA a5182GFNvjiHxR4Z1Ikxr75gchPqdnVIgPzIIXm2tApHd7ZDNeG3XXTGYiMRB7BAFs/4 NiSWfGZmDgqpoS/EcPx9NZ1OIodUSJCShx4DA6dh2aXYbeom4oLBATvH4FcTE61fUS0t e+FAmCcwOXKAD6AwCI3VmRzSjjkB9HaxVJ9yxpMp6iWthL7tonrxGR4ShORMNaXCDkem PZ5bgYeghs57EhJH42igugbB556xmuLHN52f/FbJemNrTlyeayeJtnp8WK5ToMpeRhtG pIKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926511; x=1720531311; 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=dJ2rMI0TSHRDo+bfesaPBFAqGyrvqALIQhOnMBElujo=; b=IetFMufhAHH4mqo5twp45ffufZp+E+ILlGyg6q1NLsVzMhXN0NYnSzQsgG3LSk8Sf7 apDKyzLMsTyySr3zrGGpyDgwdUO3LiPmwE6cdvIEN4draUcTRDjojqRxgcNmHJ2cU8NU MirbakeI1QM/JkkX5bTpaFKYT+SR2hoBQPJNmh7tfeERq22h+or7zWeq8Svx9wVxs7hG zzka7LQJOZiI/TCzA3KbQe3X3wBS7/VBgCroQkVsEZTrOvws2+h3Xb5+aoUno4Xls1ov jdB9pZNGI5mKa+fg56EpeRlrvqOVqctuSxFj1DZ6UVlikJ9XKykgAuufJrptZDb/7gX2 sgUw== X-Gm-Message-State: AOJu0YxzbAZA5ejHDFTws/HA5fVyy0YFCzVIOab72y2Zi57JKsuODGa0 n64OnA7UJjK0LWsmy3YTIeaaVgRTNa3q8a8NlfQVXFTuswsbR9s01PIZ8T6nXTpqeDSmwoGvvmc = X-Google-Smtp-Source: AGHT+IH/xlljohlO21aqbpbz7LUgM15WgS0S13goV3K0tzYvuzFOObPe8WvgI6ojUBYJb41FuATG7g== X-Received: by 2002:a05:6512:1251:b0:52c:cda0:18bf with SMTP id 2adb3069b0e04-52e8264e643mr6755301e87.4.1719926511458; Tue, 02 Jul 2024 06:21:51 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:50 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 11/13] ada: Compiler accepts an illegal Unchecked_Access attribute reference Date: Tue, 2 Jul 2024 15:21:27 +0200 Message-ID: <20240702132130.523603-11-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Steve Baird The compiler incorrectly accepts Some_Object'Unchecked_Access'Image. gcc/ada/ * sem_attr.adb (Analyze_Image_Attribute.Check_Image_Type): Check for E_Access_Attribute_Type prefix type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_attr.adb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index d56c25a79cc..0b0adac1126 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1582,6 +1582,13 @@ package body Sem_Attr is then Error_Msg_Ada_2022_Feature ("nonscalar ''Image", Sloc (P)); Error_Attr; + + elsif Present (Image_Type) + and then Ekind (Image_Type) = E_Access_Attribute_Type + then + -- reject Some_Object'[Unchecked_]Access'[Wide_[Wide_]]Image + Error_Msg_N ("illegal Image attribute prefix", N); + Error_Attr; end if; end Check_Image_Type; From patchwork Tue Jul 2 13:21:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AGVApxiI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Xm2w5hz1xpc for ; Tue, 2 Jul 2024 23:24:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6EAF388216C for ; Tue, 2 Jul 2024 13:24:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id E3BEB3882657 for ; Tue, 2 Jul 2024 13:21:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3BEB3882657 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 E3BEB3882657 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926519; cv=none; b=qhmLPgGH4qSYDwOPr86g41DploE8UYmXwnoyDGyLF4hfX7itY+wOoU6N2CP2fQxzJhxyI2Mvc6L5qg+aUP1gBTU9FsiPrXKu01n3rgpTBTm+E4MZqpG8Wjb0myoCZu31hP6J8AB8kloTyoadi1w5spimTHt1Ih4tGpU6sizhco4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926519; c=relaxed/simple; bh=1gJgDBbYZTd5I20HIle/maNv49HQlcSh76Dj+FGlUxY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XVs/3CDbAwVQzqgxXRSvedFHy4VtTdgaOxVffMDuxXVpuhm3adY1CJ2EHt2wjKIBV/ZZrLi6PghooN7I00Lp9Igs/w7Kvy3q/d51WMF6//MDGODfVCD+ur1CT27FwsmZLtmcOBdjtSkDWQJ7BDyEDGR+OoHj5NjTvaeAWaFzwDU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52ce01403f6so4784189e87.0 for ; Tue, 02 Jul 2024 06:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926514; x=1720531314; 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=ZTxGRLJGM8GHxNIlQTW2Bw0TAPtNvvYtFzacI5itk6A=; b=AGVApxiILfYehK7zYxsMc6zdUYELf2LM+/dTZUEEGhxBulOTIypVo0XEze34j9vm1V zWh6JlIAo4rwwM/umkVjcPoxw3EbGBBvPYgsdLHI+pvGv2iXmoqT0DbuyN8gwm3TFP/g g7ATeQw+IIfdlQaDnNZA/bNde/QQcGkQh6GyyfssHaAkYo4M7/0AIEUwdZNCVemaVDPQ enXdTx8pRGtuuvf6dOy/FbizXffc548+yg+nT5sGVJno2/V9lrUCOfBzpbAfivGWJkJF I4+I9wYfeQzW42f/Bqh9iSFyy9NOXI0JRSSnFeIwFg6TmWNnDxtJORVy871MaDQO7xiQ qnjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926514; x=1720531314; 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=ZTxGRLJGM8GHxNIlQTW2Bw0TAPtNvvYtFzacI5itk6A=; b=S1WanmwtmCnmMxV09X4xy/NKhNKGyXFiX67ozKYKuauaMPm2mmpD72Fmo9M0Db1Fzi YLhTU3bvVmHqkEyTBk6XiRlNdOy0xLi0cwtFExdYVw5sqrbKRLlaeZBYTPGWo63kLOZs IuTkF3Tmu7g8emdSoi1VuZS7w1HuKjW0c+oZx2Qexhzyrzil0HbXvR9SHghzYPxuwAix cWVKBCGbTU/36c0C3NS4h6hbOidDLG2FnbaRnekyv5tTaCF+fJKWluqkJBW6oDjtXhP4 uZX4ODfV8SEA+wEHXLOouvmxtfFhw60wZtiBtYovaE2ZGXlPsSomnJw3ucuXDgIFIUkP yu+A== X-Gm-Message-State: AOJu0YwwXNzCD7YczyCe0w1qQETVgsYpA8Gz5HsHus0p98zOTjkDhXBC w0VgwWlerPhf4DLkyA08AdWFSHIPHWgO+YoGwpb3rHKDfIShxS9dZNmqQef89im6Z0I56KVV8x0 = X-Google-Smtp-Source: AGHT+IFHE4EtbeEMNxBtx9ckS+m+VnU5NzwIFOoH3YTP2LgCQIojmXl22gi2IThIYrth0AkAR95sqQ== X-Received: by 2002:a05:6512:31c4:b0:52d:582e:8093 with SMTP id 2adb3069b0e04-52e82672444mr6272840e87.23.1719926512371; Tue, 02 Jul 2024 06:21:52 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:51 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 12/13] ada: Fix generic renaming table low bound on reset Date: Tue, 2 Jul 2024 15:21:28 +0200 Message-ID: <20240702132130.523603-12-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Ronan Desplanques gcc/ada/ * sem_ch12.adb (Save_And_Reset): Fix value of low bound used to reset table. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index b93e8231c84..127b521e0a5 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -18095,7 +18095,7 @@ package body Sem_Ch12 is end loop; Generic_Renamings.Init; - Generic_Renamings.Set_Last (0); + Generic_Renamings.Set_Last (-1); Generic_Renamings_HTable.Reset; end return; end Save_And_Reset; From patchwork Tue Jul 2 13:21:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1955289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=h6uvMnUe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WD3Z371psz1xpN for ; Tue, 2 Jul 2024 23:25:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BC493882671 for ; Tue, 2 Jul 2024 13:25:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id F08A13882064 for ; Tue, 2 Jul 2024 13:21:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F08A13882064 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 F08A13882064 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926519; cv=none; b=e85RPtX+/j0IJjgyIP3DmP6YcK38x6ERV30cQN4Q/Y66gLu02ZXW034/5SYaCMNKzRlHVd3DABRo0hc0exxOrCA8qjgcztFrpYX3ozn7HStGAq0oqp84t4n3Xp+vIBcSxMiuAmSgwXrOAz7FEbgUGTCXPOGqPcy9mirrGBOvuOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719926519; c=relaxed/simple; bh=st09M3Y9Cp11c7Hva3EFO4YgrE2i0z58yKnx/r275Tc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=h7TZNTp8o5cmd0KAWqAV253c6EJVRHsW4LHVrn1Qk0mbscOPfxFx1r908Y1R+l1IiTfTd/yrUp0MpIt3eW6uvpLH1xIuiw1NcOheEt2KJbM4TTlVeorxAU0k7gKCqyVlfdCc0GQnMuKuTHWgblwC84jJbVmkyhRjt2W5rmyTBKg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52cecba8d11so5064746e87.1 for ; Tue, 02 Jul 2024 06:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1719926515; x=1720531315; 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=193wqb0ZQTFIvWDRKe79zVZu81pjPx8LwvEf62SLLww=; b=h6uvMnUe2pn2O0LqWjpx4z7MHH6ULa/uuxtUoRMpw2LC7sOTGKaPkOgSuLbBOc+zY7 ANC3Q3B4HVDPszb/b3EMhioLl3zDjB7gK2PAIhzGZozr2OckYDpM81Cy4sCgsVADgPxg ijHAnJSh4dPiiVeJjYBoHC36V3gbqrDTw/AOEPeiUaSmM+pRVNgJMRwh66g1Fk0sqKYs wEVkWslAv1DlncTHqiXSm+NRGQFDN6XyVE9AZz+GahwwzqFU24xFR3Qw1Tvf1X/+Bwu1 MQD5LETE2ifam+ZQUUL0Ou3xNPhmWtwXi8bWdxIaOT5YwMqr0ldfKVo8GiEaUtB0r2l7 DR3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719926515; x=1720531315; 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=193wqb0ZQTFIvWDRKe79zVZu81pjPx8LwvEf62SLLww=; b=bDy/B9BLRicVcs4x90ejziODmvLrWAkGNYEI3hLa2/oFRNSakKQcW4tO3vnSAaFc2A oknPZjUHEQdoT+oO8qZoOKzMhLC8KazlnsWP3uiDoAJ2fvxVG/ti81uukh02F6JJT7Sp GRWrW37yk7heoFCoT5aT9+USqBmtv4QpAnDtNUqtbW6RED59LNfrI+lcQKrypYfmJKrb JomkM8Mxa34uksWqcUdvpKxcWsMFMfz9u/P7kUFnoAxEhp3XSg5ak54OnU0b0PyQf/++ R7I+66SImTcqZNtUgamIz9ivd1e300U+D/IOt66agY1QOowM9Bm+z5DPzbpGF1vBiPG9 jxAA== X-Gm-Message-State: AOJu0YzjcIjW/PkoZ73q8L/pNsPe+DKiN5tzyGWOAejBccR7uo4ZJ9iC +esTW7L18XR8HCn/hoCnCHQAjVz1fgLytzmYiEE2UPFH048A54vLe52KC9uwdgXED6I5gfkGnIE = X-Google-Smtp-Source: AGHT+IFQgN4HYSJPorvGjnCnLSxRkcftJJ66DHTceMu/4CQ+L2+W4+Y9AZckjsudwCWdgz7ikg8Tfw== X-Received: by 2002:a05:6512:3dab:b0:52c:d085:9978 with SMTP id 2adb3069b0e04-52e82733e8amr6204158e87.62.1719926515467; Tue, 02 Jul 2024 06:21:55 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:53cf:a5ff:fb60:5a70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm197319895e9.35.2024.07.02.06.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 06:21:54 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 13/13] ada: Use static allocation for small dynamic string concatenations in more cases Date: Tue, 2 Jul 2024 15:21:29 +0200 Message-ID: <20240702132130.523603-13-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702132130.523603-1-poulhies@adacore.com> References: <20240702132130.523603-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Eric Botcazou This lifts the limitation of the original implementation whereby the first operand of the concatenation needs to have a length known at compiled time in order for the static allocation to be used. gcc/ada/ * exp_ch4.adb (Expand_Concatenate): In the case where an operand does not have both bounds known at compile time, use nevertheless the low bound directly if it is known at compile time. Fold the conditional expression giving the low bound of the result in the general case if the low bound of all the operands are equal. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch4.adb | 91 +++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index e4c9de474ad..abe76c8767e 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -2837,13 +2837,32 @@ package body Exp_Ch4 is if not Set then NN := NN + 1; - -- Capture operand bounds + -- Set low bound of operand and check first the constrained + -- case with known bound - Opnd_Low_Bound (NN) := - Make_Attribute_Reference (Loc, - Prefix => - Duplicate_Subexpr (Opnd, Name_Req => True), - Attribute_Name => Name_First); + if Is_Constrained (Opnd_Typ) then + declare + Low_Bound : constant Node_Id + := Type_Low_Bound + (Underlying_Type (Etype (First_Index (Opnd_Typ)))); + + begin + if Compile_Time_Known_Value (Low_Bound) then + Opnd_Low_Bound (NN) := New_Copy_Tree (Low_Bound); + Set := True; + end if; + end; + end if; + + -- Otherwise fall back to the general expression + + if not Set then + Opnd_Low_Bound (NN) := + Make_Attribute_Reference (Loc, + Prefix => + Duplicate_Subexpr (Opnd, Name_Req => True), + Attribute_Name => Name_First); + end if; -- Capture last operand bounds if result could be null @@ -3018,6 +3037,8 @@ package body Exp_Ch4 is -- take unconditionally whether or not it is null. It's easiest to do -- this with a recursive procedure: + -- We fold the common case where all the low bounds are the same + else declare function Get_Known_Bound (J : Nat) return Node_Id; @@ -3033,32 +3054,54 @@ package body Exp_Ch4 is return New_Copy_Tree (Opnd_Low_Bound (J)); else - return - Make_If_Expression (Loc, - Expressions => New_List ( + declare + Known_Bound : constant Node_Id := Get_Known_Bound (J + 1); + Comparison : constant Compare_Result + := Compile_Time_Compare + (Opnd_Low_Bound (J), + Known_Bound, + Assume_Valid => True); - Make_Op_Ne (Loc, - Left_Opnd => - New_Occurrence_Of (Var_Length (J), Loc), - Right_Opnd => - Make_Integer_Literal (Loc, 0)), + begin + if Comparison = EQ then + return Known_Bound; - New_Copy_Tree (Opnd_Low_Bound (J)), - Get_Known_Bound (J + 1))); + else + return + Make_If_Expression (Loc, + Expressions => New_List ( + + Make_Op_Ne (Loc, + Left_Opnd => + New_Occurrence_Of (Var_Length (J), Loc), + Right_Opnd => + Make_Integer_Literal (Loc, 0)), + + New_Copy_Tree (Opnd_Low_Bound (J)), + Known_Bound)); + end if; + end; end if; end Get_Known_Bound; + Known_Bound : constant Node_Id := Get_Known_Bound (1); + begin - Ent := Make_Temporary (Loc, 'L'); + if Nkind (Known_Bound) /= N_If_Expression then + Low_Bound := Known_Bound; - Append_To (Actions, - Make_Object_Declaration (Loc, - Defining_Identifier => Ent, - Constant_Present => True, - Object_Definition => New_Occurrence_Of (Ityp, Loc), - Expression => Get_Known_Bound (1))); + else + Ent := Make_Temporary (Loc, 'L'); - Low_Bound := New_Occurrence_Of (Ent, Loc); + Append_To (Actions, + Make_Object_Declaration (Loc, + Defining_Identifier => Ent, + Constant_Present => True, + Object_Definition => New_Occurrence_Of (Ityp, Loc), + Expression => Known_Bound)); + + Low_Bound := New_Occurrence_Of (Ent, Loc); + end if; end; end if;