From patchwork Tue Jan 11 13:32:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1578511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=P4iJPEgE; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYCKJ3wcfz9s1l for ; Wed, 12 Jan 2022 01:11:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 269E238A8038 for ; Tue, 11 Jan 2022 14:10:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 269E238A8038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641910258; bh=IeP8bZIhFmOw+GcH9MAZQdyKt0gP5iwHyGsXUHNvlP8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=P4iJPEgEGPMwS3/FR9ZGlutOceCYLIKgPbWMlFBKXuGCMgRC0EuCmpL2pNKUuHjHZ S2vldBCwW0tPYHg7O8mu4UOvzeBObKOAbJfNCmRShp9t1Ag8LcD8xbYHEywX6IuwDy 7x/ReW7lpHlGz4j9GJFJCeAHX+L5Mf+1eaiUBB/A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 6A21138A940C for ; Tue, 11 Jan 2022 13:32:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A21138A940C Received: by mail-wr1-x431.google.com with SMTP id s1so33012797wra.6 for ; Tue, 11 Jan 2022 05:32:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=IeP8bZIhFmOw+GcH9MAZQdyKt0gP5iwHyGsXUHNvlP8=; b=3NhXCh0ytKptNe/PzsKML1+gGdAGs6UfmzXVJBq0rU2YbLD3XMFU2FdK5Bp14m9tG+ +yv8Opt0oaixMimgieTdtqJabTbITgjNBctJos3uFTk8SaMa44lZxYttnUU4YT8uZCh5 NkYRuEKGV0xB7PPkJtb8r66XYuXjU2Xkk/jMrYRubsjV2RJUDSaTUc/J14K58mk2xy6z M78qXiuXHbNc/egUBS9SptG3owIr0W3f5/2+lJTYKMvOtrzvaKBfCGs7zQuTvc7JK1rs GUSOLEpUNE+eja63me8UQwZuVeq1/oVDzbcyCwJRx/jSJ2jrBu6eOU3LP/Xn6VHOooxB TQMw== X-Gm-Message-State: AOAM5328dcZRGxAoizd7vgGxrH6sKGuSmvHZHCaVZssng7sdw0mrZ2eL /Hp7asGwItx7b6zEQtSoZn3IpFC+LJJwiA== X-Google-Smtp-Source: ABdhPJx7JJePmHcn3N533QRA01ARafTQJBpwrTfyd9BUAw3IstLK62iB/a44UUDnYJqYA7wrIhBd0A== X-Received: by 2002:a5d:6e8a:: with SMTP id k10mr4053290wrz.113.1641907967456; Tue, 11 Jan 2022 05:32:47 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id f5sm1677056wmf.47.2022.01.11.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 05:32:46 -0800 (PST) Date: Tue, 11 Jan 2022 13:32:45 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Relax assertion on designated types for equality operators Message-ID: <20220111133245.GA749065@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This will avoid doing artificial conversions during semantic analysis. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils2.c (build_binary_op) : Relax a little the assertion on designated types of pointer types. diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2021, Free Software Foundation, Inc. * + * Copyright (C) 1992-2022, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -1118,7 +1118,7 @@ build_binary_op (enum tree_code op_code, tree result_type, return result; } - /* Otherwise, the base types must be the same, unless they are both fat + /* Otherwise, the base types must be the same, unless they are both (fat) pointer types or record types. In the latter case, use the best type and convert both operands to that type. */ if (left_base_type != right_base_type) @@ -1131,6 +1131,18 @@ build_binary_op (enum tree_code op_code, tree result_type, best_type = left_base_type; } + else if (POINTER_TYPE_P (left_base_type) + && POINTER_TYPE_P (right_base_type)) + { + /* Anonymous access types in Ada 2005 can point to different + members of a tagged type hierarchy. */ + gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (left_base_type)) + == TYPE_MAIN_VARIANT (TREE_TYPE (right_base_type)) + || (TYPE_ALIGN_OK (TREE_TYPE (left_base_type)) + && TYPE_ALIGN_OK (TREE_TYPE (right_base_type)))); + best_type = left_base_type; + } + else if (TREE_CODE (left_base_type) == RECORD_TYPE && TREE_CODE (right_base_type) == RECORD_TYPE) { @@ -1153,13 +1165,6 @@ build_binary_op (enum tree_code op_code, tree result_type, gcc_unreachable (); } - else if (POINTER_TYPE_P (left_base_type) - && POINTER_TYPE_P (right_base_type)) - { - gcc_assert (TREE_TYPE (left_base_type) - == TREE_TYPE (right_base_type)); - best_type = left_base_type; - } else gcc_unreachable ();