From patchwork Thu Mar 7 14:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1909288 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=YrEkPhxs; 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 4TrBVF1zd1z1yX4 for ; Fri, 8 Mar 2024 01:28:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F0083857700 for ; Thu, 7 Mar 2024 14:28:03 +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 DBDCB3857733 for ; Thu, 7 Mar 2024 14:27:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBDCB3857733 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 DBDCB3857733 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=1709821658; cv=none; b=Dxa5t1ADutS5/welNjEmVW3S7z1icyf2caECPKO5KVqssEX43j9gmJQ1uKz0J+fegH+jOsV/5Bgisi9WhxFAoltB4f8GL7cgbqCXydsL9tUHL1fJU/N0sRxzjtpDTkDtl9iEw1RgckRx/YqLpIiTvTsjbZkap7qwedJ9IHezhOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709821658; c=relaxed/simple; bh=8DO8UfZwXL+naju0JsKirokqunEVYr6sZrEk9bT5ffg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jp1De2UpHESfqj0Pcrqw/eMIk6UpLDg48EHDYJdmTcGCx31j/nki8HIbTjZmOBxJ6j2ZnKpcJDvA0hc/qQC6b/Iq8wg7oyPzyXR8XYGmH8yjAlO6HdTnKXe19vJxN+2RM6HwCp+boUdEnHVAFU4IsdIffnKnkydkCrHJiKK+ees= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-412ea23a750so6225065e9.0 for ; Thu, 07 Mar 2024 06:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1709821654; x=1710426454; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=L82kreWkx8/g+RbLppBxE9B9WL5zE5Hd/vreBJjqEDA=; b=YrEkPhxsSg+4ryICS9k9iBCY9uGG73olwj71iq8CXQoCaU0XOiZo++NAJSSc5Cebrp N+iDcL2pYJnDtjTtugcEB99EGjexBq4PEgibABPQV9bXt585pBm5FTffFoYnPFpQ7vkU Mb7EdOGt14BaMsQV97SEA2NcCboYDNJA9tm/9TygtoXEDXBKVWPjyFJeDC5QS6HeMF4A Bgo2K824CH4ZVkWpXxW/PgJucHSIFn6cH6SDZpzWzlf3mFidzQTPI/8wisjWuq9P1foo gDuQZsw4vSZD+gGd8U2qXZxJkn8R0jGIVNp2neKbRW9O6zpra/NE8nCFPXtPqpioclBF C8QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709821654; x=1710426454; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L82kreWkx8/g+RbLppBxE9B9WL5zE5Hd/vreBJjqEDA=; b=oPHzDVInvDOSDryv4pDE5nuDF4BjoZ8m6pOrsHN13yLQgKx9P/l0pssSzSLKRx+G5Z kzNGG9QcvY/TsH2J4ZU1qIlvQd6sY+YkjR/Q1D9CotM8V9AxftSEV7oanUouzD2/j+nw udoQnAx33YoO4HNrCwM8Z+djLHhf5bzk0Rx0pNrZo+CHvmWp7Y9uVN8gKJ8Biw6/Payt 32NvjQMc9pAHz/46oCayrVBnMOQgBHeyS9M4mfxBupCITbwF9rko4Mdwm979v+dhbAL2 S7cXFhxwDDovyPnun11fwLy32KfZbTwnviPYB6xwv0W5VwWG+7Jw/AzqzdBTy4QUxj39 715g== X-Gm-Message-State: AOJu0YzGJXAExgnABBW+kZgyJexYrfx8+tdh2itaevnKBA+7svbqr/+A oeb9e8CLqC9RLMQeikyhll4ygbfT+3Lxe3HYB2PqYeDVA49IydPfTKp6mfVj84c1yISRx06+sDA = X-Google-Smtp-Source: AGHT+IHTnvVIgZbB4K+B8RopXgyVWDbZ0NmLkgyfXHSv81P8kJ5wUVdfN6dODCR3Kd9NkbrvNgsKfg== X-Received: by 2002:a05:600c:4f52:b0:410:78fb:bed2 with SMTP id m18-20020a05600c4f5200b0041078fbbed2mr406623wmq.19.1709821654484; Thu, 07 Mar 2024 06:27:34 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id he11-20020a05600c540b00b00412ea93220asm2810382wmb.12.2024.03.07.06.27.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 06:27:34 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix PR ada/113979 Date: Thu, 07 Mar 2024 15:27:33 +0100 Message-ID: <4551393.LvFx2qVVIh@localhost.localdomain> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This is a regression present on all active branches: the compiler gives a bogus error on an allocator for an unconstrained array type declared with a Dynamic_Predicate because Apply_Predicate_Check is invoked directly on a subtype reference, which it cannot handle. This moves the check to the resulting access value (after dereference) like in Expand_Allocator_Expression. Tested on x86-64/Linux, applied on all active branches. 2024-03-07 Eric Botcazou PR ada/113979 * exp_ch4.adb (Expand_N_Allocator): In the subtype indication case, call Apply_Predicate_Check on the resulting access value if needed. 2024-03-07 Eric Botcazou * testsuite/gnat.dg/predicate15.adb: New test. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 4f83cd4737a..e4a40414872 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -4657,8 +4657,6 @@ package body Exp_Ch4 is if Is_Array_Type (Dtyp) and then not No_Initialization (N) then Apply_Constraint_Check (Expression (N), Dtyp, No_Sliding => True); - Apply_Predicate_Check (Expression (N), Dtyp); - if Nkind (Expression (N)) = N_Raise_Constraint_Error then Rewrite (N, New_Copy (Expression (N))); Set_Etype (N, PtrT); @@ -4752,6 +4750,8 @@ package body Exp_Ch4 is Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); + Apply_Predicate_Check (N, Dtyp, Deref => True); + -- Case of no initialization procedure present elsif not Has_Non_Null_Base_Init_Proc (T) then @@ -5119,6 +5119,8 @@ package body Exp_Ch4 is Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); + Apply_Predicate_Check (N, Dtyp, Deref => True); + -- When designated type has Default_Initial_Condition aspects, -- make a call to the type's DIC procedure to perform the -- checks. Theoretically this might also be needed for cases