From patchwork Tue May 17 08:27:35 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: 54071 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 AD900385782C for ; Tue, 17 May 2022 08:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD900385782C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652776654; bh=8RjGDkdf97yr3Jl+oLxlKlPHVmw0p26nZB/1Ca5VWm8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OifmKm0WRq4B4ii9MlAgVMpGeG13+oL7Lbku2Hpry5CA2Ww3A6wnoeLB01KUgsNO9 GoAXdLR5DrPQaKREvfCqjQxuO2ZxKXBSEYW0c/lLYTL2Keq3rSi18NM40lMKkRdaLD oY4PvnFMw2zvi6821d8zdb5xVmJyObu9LAxdQOk0= 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 229A7385741C for ; Tue, 17 May 2022 08:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 229A7385741C Received: by mail-wr1-x431.google.com with SMTP id m1so23646759wrb.8 for ; Tue, 17 May 2022 01:27:38 -0700 (PDT) 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=8RjGDkdf97yr3Jl+oLxlKlPHVmw0p26nZB/1Ca5VWm8=; b=PoxXI7mRYySjLOeaihSRXuCkPn/WLrjrocoJnpEaJ9UKqqRrha2GgA3y/1122cBelh tswPn1lpvzqeB+iMd0qPkZ38dXOGFQKCNCo8lCtLGz/Kyd7AerHlQLUGWFt4kMLSP/SE htxjOqLPwvizjdFWwjeCKhPdJ9FUdRFzrDZbBqpft8TRdAd7y/4GrUHUoRcQM0ycm2V6 3NA4L6kKR/go4XnKNwwFAsNw0JRLqJ/KVtCYTk+L8F/mdTfuWQnpQX6dc1u4kRIJ9GyZ RgLpGJfK3e0DcCo3YmKgz895yTFZVIFJJajv2BmIe4FB1vydliAttbonk93y3ZTt9QwY gREA== X-Gm-Message-State: AOAM53136cTAvIKpX4wLguYM5Zm/8hjlM1xYx+Ij2/V02eLUsh68kIf+ 0mxlCgBiJ7QYikdqqoLNWIkf0bvN1QNE1SMi X-Google-Smtp-Source: ABdhPJwAno6ybesAgLEdLVSJevQpaIAI0sEf3hjWV6J93QWnxokX/2gEEmkRJZUU7sRwa62jhRZYoA== X-Received: by 2002:adf:f24c:0:b0:20c:fe15:504c with SMTP id b12-20020adff24c000000b0020cfe15504cmr11901985wrp.123.1652776056855; Tue, 17 May 2022 01:27:36 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id t5-20020adfba45000000b0020cdbc5c4f0sm11623656wrg.104.2022.05.17.01.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 01:27:36 -0700 (PDT) Date: Tue, 17 May 2022 08:27:35 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Deal with derived record types in Has_Compatible_Representation Message-ID: <20220517082735.GA1088759@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, 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.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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" More precisely, untagged record types, as tagged record types are already handled by the predicate. If the derived type has not been given its own representation clause, then the representations are the same. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Has_Compatible_Representation): Return true for derived untagged record types without representation clause. diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -13539,6 +13539,16 @@ package body Sem_Ch13 is if Is_Packed (T1) /= Is_Packed (T2) then return False; + -- If the operand type is derived from the target type and no clause + -- has been given after the derivation, then the representations are + -- the same since the derived type inherits that of the parent type. + + elsif Is_Derived_Type (T2) + and then Etype (T2) = T1 + and then not Has_Record_Rep_Clause (T2) + then + return True; + -- Otherwise we must check components. Typ2 maybe a constrained -- subtype with fewer components, so we compare the components -- of the base types.