From patchwork Fri Jun 14 07:36: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: 1947707 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=ZoR6tt/B; 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 4W0rmH3CXpz20X9 for ; Fri, 14 Jun 2024 17:40:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62C0D3882AE7 for ; Fri, 14 Jun 2024 07:40:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 2F7973882657 for ; Fri, 14 Jun 2024 07:36:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F7973882657 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 2F7973882657 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718350616; cv=none; b=Lg/jP9iVkxxKhxUMWGg3DDTiW2ISYeX1r+szYskKFBYRcIK/YV1s3Tk+Yt5k7bc3P2IWXq/7GYkX9WPOdNjlTZSH1vGxGqk7J2r2X5JV5fbBGQH1CGBMCICGHhoEH85mv+1uibJ2D3d3lcvohhFMKkwW/lAeNIABsfrs5t5ozJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718350616; c=relaxed/simple; bh=VQpkeKfSwu7lGHx9c+nWrJc82VrGE2bMgNe1Kp+MQ3s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TBEBUnF5wnNTOxce4H5CTq4PDnPqUFSRe6AXCn0w3QVsGZUuZFxEWVcRuwPZ8jsyFHsJ1YJgBiLpCXMmt2/IJNRtnQkMpAS7kBdJfDrowOevvNBDZjSdK2EkqmUcVT+92TPJlbMSRJitH5TJOpPq7d9Kn/f1C2cDBg//VCb1Qkk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-35f0d6255bdso1709437f8f.1 for ; Fri, 14 Jun 2024 00:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718350613; x=1718955413; 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=yuAxBYsTgxaJ7qIx4gs+mpI+dxXeOAeth56rHPrnbjw=; b=ZoR6tt/BWrnWX6cw2C84e7AK2zYGX8TqmNgEZunubyNWIcwKTw7GkE7KmE3bKrIZEx g0pEq1Qpub6hzMS4qF8mEHMZpn6n09CZWIuOs4/ntFCaMDHtFfcHNcayAtt9i8V+SUD0 taYgfhSx64mjCqbU6kMnyY09h37PJjJfkUbUAcTGB3aFZtZqnhWyvkNoLOU9bYQIV+VH /bG8aYhQorCmnv3z/VrzjrG68ov90hlpq0ug+yyrOf9c5aawaGkjitYGP0GzPb/Li/Sd JbcxdC3VwmTFYTxY5iQer1xD5NmOjMbhg2VdA7lC6oAAy3WZhD20x4hZcK99VAA2hDXg mAnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718350613; x=1718955413; 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=yuAxBYsTgxaJ7qIx4gs+mpI+dxXeOAeth56rHPrnbjw=; b=QvMgOKaEbALmzDTtZa7/GOp+Ln2ulmCgFLBqijoe3H4pIXzJHk1w80732w3mpsR5ML Ppa8H+pmThhlB+5iibguBtJuC9UNHQlSNph4gn8kmC1LHJN0MTne+bFRYMnKEvIxqXfM ZwB92wnKp8IsnL+KDl7y8lxOD3cmsRduIFrgmGT+IZt/z30QNqLulXftaLJaPU8fgrD0 peINL1m/aVbKJAjyP0V+iEaSTWXXjWLDGTtU4PGLFacaeMqxNcZlH82esutKz5RaSqm0 7/jEqWwM7Q4eEtZBKbbtvPxA9v0GOdg5wpeQvZo5Rhh7bIA99BjjUKtrxc7V0IFzXqxf nh5w== X-Gm-Message-State: AOJu0YzKq/KHbxMos28u0G4ZiU1PO/7iTfOYW9p9sRBPydPZXT8udL25 AvE7elmJkuznrxNHYl6KHKr+OUXuApRSvPvAjBsfXR8xNlKmSkoiTQ6RZ8ykb9SuGlNlpVK0sTY = X-Google-Smtp-Source: AGHT+IEf5HzwkqL8wnRlGoWwX5eRKCReNA1Wwt/pJlPw/0z3u+5+RwRQFgGcAj35/H1UZ+s0ZI9gpQ== X-Received: by 2002:a05:6000:1564:b0:357:73ca:9c00 with SMTP id ffacd0b85a97d-3607a7660fbmr1400474f8f.32.1718350612909; Fri, 14 Jun 2024 00:36:52 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:cb5c:2e27:9d1c:5033]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36075093636sm3558191f8f.14.2024.06.14.00.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 00:36:52 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 10/16] ada: Bad tree built for Obj.Discrim_Dep_Component'Loop_Entry in assertion Date: Fri, 14 Jun 2024 09:36:26 +0200 Message-ID: <20240614073633.2089692-10-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240614073633.2089692-1-poulhies@adacore.com> References: <20240614073633.2089692-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, 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 From: Steve Baird The Etype for an N_Selected_Component node usually should not match the Etype of the referenced component if the component is subject to a discriminant-dependent constraint. Instead Build_Actual_Subtype_Of_Component should be called. Fix a case where this rule was not being followed (because B_A_S_O_C is not called during preanalysis of a component selection), resulting in a tree that confused CodePeer because the subtype was wrong. gcc/ada/ * exp_attr.adb (Expand_Loop_Entry_Attribute): Ensure that Etype of the saved expression is set correctly. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_attr.adb | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 1396007a2d1..5c85b4912d2 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -1780,14 +1780,25 @@ package body Exp_Attr is begin Aux_Decl := Empty; - -- Generate a nominal type for the constant when the prefix is of - -- a constrained type. This is achieved by setting the Etype of - -- the relocated prefix to its base type. Since the prefix is now - -- the initialization expression of the constant, its freezing - -- will produce a proper nominal type. - Temp_Expr := Relocate_Node (Pref); - Set_Etype (Temp_Expr, Base_Typ); + + -- For Etype (Temp_Expr) in some cases we cannot use either + -- Etype (Pref) or Base_Typ. So we set Etype (Temp_Expr) to null + -- and mark Temp_Expr as requiring analysis. Rather than trying + -- to sort out exactly when this is needed, we do it + -- unconditionally. + -- One case where this is needed is when + -- 1) Pref is an N_Selected_Component name that + -- refers to a component which is subject to a + -- discriminant-dependent constraint; and + -- 2) The prefix of that N_Selected_Component refers to a + -- formal parameter with an unconstrained subtype; and + -- 3) Pref has only been preanalyzed (so that + -- Build_Actual_Subtype_Of_Component has not been called + -- and Etype (Pref) equals the Etype of the component). + + Set_Etype (Temp_Expr, Empty); + Set_Analyzed (Temp_Expr, False); -- Generate: -- Temp : constant Base_Typ := Pref;