From patchwork Tue Jan 9 13:16:02 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: 186384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp105351dyi; Tue, 9 Jan 2024 05:28:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHieNDlmcli8+3XcwegtnvS3cbMuvDeg9iAaVuxXCgWsURCL053MBYwn8qxQSlK2fcJwban X-Received: by 2002:ac8:5892:0:b0:429:9cb6:4b9d with SMTP id t18-20020ac85892000000b004299cb64b9dmr2794145qta.57.1704806883049; Tue, 09 Jan 2024 05:28:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704806883; cv=pass; d=google.com; s=arc-20160816; b=s3e/mlR5Lmq8VhJ12GOStnn5ytkqjgjjnH3xKpFhLO3KtQiJAYxW0Owmn5lpLzl9BG SPQX514dAkn1D1ngQJZWFLn0To4cUU1Ya6Z4AyfVbdgra0/gTmtvABMszfoPBgT+uMeH 44i6Msnpf2chz3Y3Rzc2zkneB5k1DzLGw2mycmEBCqj/hnp3VxitsYdlm++SAmoBviL7 0loebf/HK2D/h8GGJAd9SencavesifExkrj1+tbLer2rEksDOQKIm9RTehP8+fjxXmcU uRgHl4mrZQm1CTNFqDLSh8Hm046Qwh1a8uRE5oAKUPs988LfKkrZuyQZJX0UJD5Frk6P +V9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=MxXRfAhCqf09fYwG78CiCCrkZ/0c5DMT8El/0zH9X9M=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=rxifi59zNOYcwQfSzv0cvAxcJwwnfSl0EdZMptDcuIwVXz1z1f7DFvsjMK90Et5zXE dM/FjMH2gdujlOPELkydVW3RUExmqS+6biz8xy1l9ROHhMsmCerlwV32bb9bIs3vNvY+ G5f/TczrLdwim53Ww0jqRPXDgs5VCOWjDlrqlkuglYggtY4jPeiWzTACKYTR3LXDs30+ g3PXjAj7hqb/QyH8LN+aIm+lSQvCe41PYFbQ8ypj3dSrnqegNfdYXpK/1VRisXuRNTHg RNp5C8+LU3EHwBA5PEjSOv6lM5DKR/n8NlOfSdXVBdNr8fKPg7pR/+GdeuYuR7pXOQ3W abrw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=BHeLVD4V; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t10-20020a05622a148a00b00428032714basi2091835qtx.212.2024.01.09.05.28.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:28:03 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=BHeLVD4V; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC53E3861846 for ; Tue, 9 Jan 2024 13:28:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 1B04D386186B for ; Tue, 9 Jan 2024 13:16:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B04D386186B 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 1B04D386186B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704806168; cv=none; b=MUtlVRA7TP3hF/k4FTtORSbfiiw9bG30c776qoJcbtQjaTe0x351bos2HT3nqoUec+szm+IiTWFG65S4fqy7yIIqqDru/2ew5iUA6EXx79NzGnhShY+5scNlfnvpxCW+x0+Z5gs6mN1qbC3yNL2sO78x6AhqrMQQ8cEPlEl2jNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704806168; c=relaxed/simple; bh=PNKsf76Gjzwv9QmQoWbOGVRssfYUZTsIGnZ8kZ6GihY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XfCN8R6cObH0oyGvTOtBWj7z71frqGPNytXyeJuY0YN6m6tQoBsjWGzkYqykbw5gVYf55x7kbeoGc96SwGag8PTpErmR53JJDi47m84WhB5zDjnnADtBgylRE/uFGOcZ32KzEHiodtdCDaHXeTs3YfzHabKCS/iR0yQjoVuVffU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33748c4f33dso2814301f8f.1 for ; Tue, 09 Jan 2024 05:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1704806164; x=1705410964; 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=MxXRfAhCqf09fYwG78CiCCrkZ/0c5DMT8El/0zH9X9M=; b=BHeLVD4ViH06UFwbKS0aPQdyef/viqoPbv9orrJzy7bObPNFOiwKufgh9ROa4c3CiX 0miRlrywOZo2nyFmMaof4yKzWW0uMqqn45NYJ3DTA1hRJrOAXu8Qo75Tkubm1fh9Oomd RG4IrA1j/ToNWvchJuigz7mTdcUKFO1H2+WHbyPJi9IbuKA3V0adjbUDXhYoV4ruVvMD kp5jH8nWuZ96kU2d0mfXVgiy9GpFHKwSa4e4SlVgNX+XRlIbJjN8Badnu8ogvYJd8QG5 3kvKrNHLFfdhUJcfotzhx+cntTrZBZvLSjL4hbsdW8bF+sWCdeEooWSk345diSET18mo 9xFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704806164; x=1705410964; 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=MxXRfAhCqf09fYwG78CiCCrkZ/0c5DMT8El/0zH9X9M=; b=NhpcjAIy7eHgCv9CG9yUboVHpziCK7zWWZE9350HoJ/brMpktMpwfomGYjacbh7t1Y uzTwjZcsWBSImLl9UIMLoR8PbpqA3cKIhaB9KfHKFf3D48NRfIZCamEdvdkytghN6VOt kR3c4GwzWTwqDt4T8BUGOpSeDi/2NGSdkfd68LZvyoGWv27e7P+bQmTK2MftExX11JC2 UXSnJuRm+vvsGcEj1LB+NabAfFYzyWwPMeS+vEHzapBXnxZ2wZgiRFELkRGGQ6zYW2IK DCQfy3qVAGCQhlKu5aRoUe1CpCkA914BvEDHKzkeNiMk9VAVAh202az6LVwgkk4Xh6PR EKYA== X-Gm-Message-State: AOJu0Yzw2WrGt6+ttL9+11O/kjnPY2wed/hBZjM9pgl23EPR6AORU3cF ZyejeOC6YKBCvLEGgFApfGJWWHm89T0oBSTTS7dhzZqmFw== X-Received: by 2002:adf:f84b:0:b0:337:76a6:10e6 with SMTP id d11-20020adff84b000000b0033776a610e6mr394509wrq.53.1704806163981; Tue, 09 Jan 2024 05:16:03 -0800 (PST) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id m24-20020a056000181800b003365aa39d30sm2380276wrh.11.2024.01.09.05.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 05:16:03 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix bogus Constraint_Error on allocator for access to array of access type Date: Tue, 9 Jan 2024 14:16:02 +0100 Message-ID: <20240109131602.745077-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787619582219637226 X-GMAIL-MSGID: 1787619582219637226 From: Eric Botcazou This occurs because the access element type is not its own TYPE_CANONICAL, which creates a discrepancy between the aliasing support code, which deals with types directly, and the middle-end which looks at TYPE_CANONICAL only. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Use the TYPE_CANONICAL of types when it comes to aliasing. * gcc-interface/utils.cc (relate_alias_sets): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 6 +++--- gcc/ada/gcc-interface/utils.cc | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 221baebb554..93cfcb74fbf 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -2185,8 +2185,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (COMPLETE_TYPE_P (gnu_fat_type)) { fld = TYPE_FIELDS (gnu_fat_type); - if (TYPE_ALIAS_SET_KNOWN_P (TREE_TYPE (fld))) - ptr_set = TYPE_ALIAS_SET (TREE_TYPE (fld)); + if (TYPE_ALIAS_SET_KNOWN_P (TYPE_CANONICAL (TREE_TYPE (fld)))) + ptr_set = TYPE_ALIAS_SET (TYPE_CANONICAL (TREE_TYPE (fld))); TREE_TYPE (fld) = ptr_type_node; TREE_TYPE (DECL_CHAIN (fld)) = gnu_ptr_template; TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (gnu_fat_type)) = 0; @@ -2417,7 +2417,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) else TREE_TYPE (fld) = build_pointer_type (tem); if (ptr_set != -1) - TYPE_ALIAS_SET (TREE_TYPE (fld)) = ptr_set; + TYPE_ALIAS_SET (TYPE_CANONICAL (TREE_TYPE (fld))) = ptr_set; /* If the maximum size doesn't overflow, use it. */ if (gnu_max_size diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index bc063c20387..b3aae5bda52 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -1867,7 +1867,8 @@ relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op) && TYPE_NONALIASED_COMPONENT (new_type) != TYPE_NONALIASED_COMPONENT (old_type))); - TYPE_ALIAS_SET (new_type) = get_alias_set (old_type); + /* The alias set always lives on the TYPE_CANONICAL. */ + TYPE_ALIAS_SET (TYPE_CANONICAL (new_type)) = get_alias_set (old_type); break; case ALIAS_SET_SUBSET: