Message ID | 20240829130750.1651060-16-poulhies@adacore.com |
---|---|
State | New |
Headers | show
Return-Path: <gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org> 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=k4o8fjZX; 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 4WvhXb6hZhz1yfy for <incoming@patchwork.ozlabs.org>; Thu, 29 Aug 2024 23:12:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2B383860C2D for <incoming@patchwork.ozlabs.org>; Thu, 29 Aug 2024 13:12:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 4FF123860C2D for <gcc-patches@gcc.gnu.org>; Thu, 29 Aug 2024 13:08:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FF123860C2D 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 4FF123860C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724936904; cv=none; b=NVlrCUuxjnB64RiSAa4v/lak50fSSMmUyN2ojOVMfoJnMkvS4vJIf8hzX2jOucbf10p87nuDFDbyudNXDu5/KXrzcsnQxrgcrHA+j5zZY3pJyHyPIOtPZ2iDDJgFeDtwlx0uK7U5h8ouF69X07/lN84QyXf0f6pST2yUfxt6zG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724936904; c=relaxed/simple; bh=3yjAWW2eocGbajofkdM/fAIopYgXCax1z0cRg6o6yjU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bPNQqoaINYVxYkO2wupKE8p5aVkuFlZp3HMHoX200TSaBSJOU7QHEovp416sHKbVEkw6w3zCjL4XOSbg2BUzW1himh9hMXsBev2eixdJrFMXWdBRkobEss6cMoVaWGo6II6riQYv+Gd2C0Xa+V1dsR7jQlyfcTZkVdtalIEzSGE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-428e0d18666so5692925e9.3 for <gcc-patches@gcc.gnu.org>; Thu, 29 Aug 2024 06:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1724936899; x=1725541699; 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=iT0F+lul6aJM7481txcmgNwwzdCFadNxzRbgHfspAUM=; b=k4o8fjZXwd2CeKvpEmG8MhH0WMEEDa9vL/2gW5f9LBX39WC3jiuF3k8MJPDflp3GFn 40s+YT9XBY1Et9KYR+jh7g4rsBv4WwcA+cYlaXzHTjXrTcJ3plZ3EpafHV+62Wo2wQFK /CbZkjeSN9fPdCZPI8mLfPHpq6ozmN7EkevPB95dI/tqOLNLKEvNELcHLvu8KiAuN0oZ YWDpBjdgsjbHooZMPbMYFqxW40EhBQRtXc5r1QKUyU4J9JVpLTxwLOccKuyCQzT/js11 2YFxrc9U7V7eM5F88vJcDVESbnlXudjIo1twtkfCur/A4HhrHSYPKK6eJojwi6hbhm2L N0uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724936899; x=1725541699; 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=iT0F+lul6aJM7481txcmgNwwzdCFadNxzRbgHfspAUM=; b=kTgF2Esz4ApnpKcZo9UZ08S2g9ssd1C1vfHCvZfCAnDF5R2EH8Mpu2DsSLb+erbQG7 +3nZ3qXgxVbPCIUMAlHjA01TAHOQo3Hp5wwQlgzUzmDLbkILqhdN5/dWbbw+LHpDUTG6 FYe1+JBXWMWv0P/uLV/P3HSZsBNsndw68yReb5WNLSbDxU/1ovrRj2FySREOcLFnThgY lSDACiR3JQdEw+lMV+dREhTFVi7UzXS+IUd2dqZqMDwYySyc/l9n8j9mQIBcYhIybOzc EngJX8OO/S9dqn+QV9aQLhqn3s1/zTFJziCpHeQ+uFW6VzvspuXDv85F6CZrc1RgFJOy fQxw== X-Gm-Message-State: AOJu0Yyv/eARb7njKgxGrS5JDyJEWj+6zbVIP4lV0IxPLyPHHbl4D4vK FfvVmvVoc+VmlNCh1TBvYsMy273SYUSpMVY+vZlfLsF1QZDEKcFnQtuPX1ySAa0DLgSZwVvPCTY = X-Google-Smtp-Source: AGHT+IHt2cddhuiPZ0rpH3CoHCSJXQv0uQUqf+AqaS78NOUBOJ4FcRwqdrXJqD2UW2vQ48NRCI01ZA== X-Received: by 2002:a05:600c:4f07:b0:428:1fa1:7b92 with SMTP id 5b1f17b1804b1-42bb01c1584mr23350325e9.19.1724936898331; Thu, 29 Aug 2024 06:08:18 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:5e2c:51b0:ac4a:92ca]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb2f5sm17074605e9.2.2024.08.29.06.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 06:08:17 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou <ebotcazou@adacore.com> Subject: [COMMITTED 16/17] ada: Fix internal error on concatenation of discriminant-dependent component Date: Thu, 29 Aug 2024 15:07:46 +0200 Message-ID: <20240829130750.1651060-16-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240829130750.1651060-1-poulhies@adacore.com> References: <20240829130750.1651060-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org |
Series |
[COMMITTED,01/17] ada: Update documentation for conditional when constructs
|
expand
|
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 2fb750c3ba4..5d7f4cca70a 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -9861,7 +9861,15 @@ package body Checks is if Ekind (Scope (E)) = E_Record_Type and then Has_Discriminants (Scope (E)) then - N := Build_Discriminal_Subtype_Of_Component (E); + -- If the expression is a selected component, in other words, + -- has a prefix, then build an actual subtype from the prefix. + -- Otherwise, build an actual subtype from the discriminal. + + if Nkind (Expr) = N_Selected_Component then + N := Build_Actual_Subtype_Of_Component (E, Expr); + else + N := Build_Discriminal_Subtype_Of_Component (E); + end if; if Present (N) then Insert_Action (Expr, N);
From: Eric Botcazou <ebotcazou@adacore.com> This only occurs with optimization enabled, but the expanded code is always wrong because it reuses the formal parameter of an initialization procedure associated with a discriminant (a discriminal in GNAT parlance) outside of the initialization procedure. gcc/ada/ * checks.adb (Selected_Length_Checks.Get_E_Length): For a component of a record with discriminants and if the expression is a selected component, try to build an actual subtype from its prefix instead of from the discriminal. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/checks.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)