From patchwork Tue May 21 07:30: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: 90553 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAA333858C53 for ; Tue, 21 May 2024 07:42:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 17937385B529 for ; Tue, 21 May 2024 07:31:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17937385B529 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 17937385B529 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276669; cv=none; b=kdh48NkaZ/InTZVcndr89oQLVosAwB+qRedleHR7D/WCsUJ7OrhtJfqn1709vFRBiuBmMJKYWI+bkPTWpjYxZ1W/S5myhtx4fjcW37w625u64HKK0LvJBybHPF5HLJFzxfvQdBeprPN9xjVOd3YQyB4/7aceW1C2vv3MeXDYWtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716276669; c=relaxed/simple; bh=4nOVYnkFEZdHvv5wPi4BaTbn5rchArcNnsN4N96NERY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CskaXl8cK551YmgRY6ZaJUOnmesspkel0gMdsE08cjvTZ36cx42ZvYKtIK3p7m+W8zX+i8bofY+2PojKsI0fJ+vQ1B42tjZ114ozJB654dicIJ+0x4ggGI+p4QU9ZihaO8vMoSZps4L0GQ4fO27a7PUeqaFpSHb2BBZzkv60jAI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so39080825e9.1 for ; Tue, 21 May 2024 00:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1716276667; x=1716881467; 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=UPyXHXE4bxvM9mMk6j8Hnamf3T5TRSULCgvNXfS2EMM=; b=fPuWAId3YqiQYIZFHIq6ZKqIg3yTlF2HlTE+YqMPI6pSnRFJ3bt9RSmn82Kb6l3/vp IzeK8GUBjOq5lsLrTVAHIHwZNi3nutCO7+E6r237i+OTWKdVac88UgyQhtHBhJkNBzZG a6Ut3BDy2v3mfWEPwudqjEcT5nizrNaHSbgyCysANNqK28nyq+2ZjrR3t/QVO31SnY+W exeoOLc029EJYbAA4pCcRwiSVziLWcxf2CQg5IHlcHSTXhp52U7P3k4hMxB17WZpPPER sWEydvqncPJQTmHE56M3/+OH0OzujiaZbAYyUwyfxEzp61/EVHtaXLlFZBBuRb0U0uKv /z4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716276667; x=1716881467; 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=UPyXHXE4bxvM9mMk6j8Hnamf3T5TRSULCgvNXfS2EMM=; b=m4W8BySWAG6mclE9jXyqmoeyxjfDBzQ8tX6dudEWAoT4XrGsKYoLAVyoLnTz0Jmfiq pXR3yDa3YcS+Wo0FXBDJOqS6v+6oc8yWU6FiYC+qKDHRYv8siUM7j/edna84pVyKMIGH g+JxPS6LJC5afUZyfXr7C2xhDjh23Iu9vjjYjH+7vtYpZhaS9VBoqdlqShq/pX5LbCVd 8G+D57tCvDI/aIOYxsJYE2cazNm+cHNomVxM6EoBbtG+kX3kV/gbhRSm8JOqucWFG7tt 62POCLik6ZBMNinPF2mUrj3sU053EZxCclx2RNlR1rIplmnslUSEcDdknWUUy97sxPQR D3+A== X-Gm-Message-State: AOJu0YzDbLasj8N1XJwBcsi9g7olkQULLJWz1qteGbES8HlE+2c07jg1 LLSjBPfG7XNWiMINZ9lXHKl74+atXApWblEF4jq93qlqT/b1vJ0XnAKxT7rLcQy61WPUu+Nd2Dk = X-Google-Smtp-Source: AGHT+IE6nTArwqT2hRYBv0BI6sMUELEgT9qvOMg1WamV8dP6vZXXwYlKombYR7hdaXzezeXA5J1rCw== X-Received: by 2002:adf:f60d:0:b0:34d:8fac:9540 with SMTP id ffacd0b85a97d-3504aa631cbmr27894709f8f.59.1716276666806; Tue, 21 May 2024 00:31:06 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:de37:8b1c:1f33:2610]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9292sm453333645e9.37.2024.05.21.00.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 00:31:06 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 25/31] ada: Fix crash with aliased array and if expression Date: Tue, 21 May 2024 09:30:28 +0200 Message-ID: <20240521073035.314024-25-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240521073035.314024-1-poulhies@adacore.com> References: <20240521073035.314024-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org From: Ronan Desplanques The way if expressions were translated led the gimplifying phase to attempt to create a temporary of a variable-sized type in some cases. This patch fixes this by adding an address indirection layer in those cases. gcc/ada/ * gcc-interface/utils2.cc (build_cond_expr): Also apply an indirection when the result type is variable-sized. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/utils2.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 64712cb9962..161f0f11e5c 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -1711,11 +1711,13 @@ build_cond_expr (tree result_type, tree condition_operand, true_operand = convert (result_type, true_operand); false_operand = convert (result_type, false_operand); - /* If the result type is unconstrained, take the address of the operands and - then dereference the result. Likewise if the result type is passed by - reference, because creating a temporary of this type is not allowed. */ + /* If the result type is unconstrained or variable-sized, take the address + of the operands and then dereference the result. Likewise if the result + type is passed by reference, because creating a temporary of this type is + not allowed. */ if (TREE_CODE (result_type) == UNCONSTRAINED_ARRAY_TYPE || type_contains_placeholder_p (result_type) + || !TREE_CONSTANT (TYPE_SIZE (result_type)) || TYPE_IS_BY_REFERENCE_P (result_type)) { result_type = build_pointer_type (result_type);