From patchwork Tue Nov 9 09:46:16 2021 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: 47261 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 52B293858415 for ; Tue, 9 Nov 2021 10:06:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52B293858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636452413; bh=ikzkxwcNbDqO65CogQB0bWS2JI+YF9zBF4LMKZptKbc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Q7VQxE36Jp0hJWoe48mjy59pUsDxH8k/lmYPE8W3wAKwAc3NFaulE4dvWGkNO/T4d H1DZxsS72PSEMuyk1nfDKb0+FVCnRlCwsFnj3tS/dJTwX3F2uRnpDq0JjnJRWrq+YD 5KKN76197Ea4kJO6jCUzxTHBNJRZLn/0AuNV+1Ms= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 907733858C2C for ; Tue, 9 Nov 2021 09:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 907733858C2C Received: by mail-lf1-x130.google.com with SMTP id x27so43029383lfu.5 for ; Tue, 09 Nov 2021 01:46:19 -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=ikzkxwcNbDqO65CogQB0bWS2JI+YF9zBF4LMKZptKbc=; b=lvpqAs1NNz3KmF7arjdKchXtLDykJl1TkPmNjqlF5Ik3xAuSfj9KLU5ELK/0zFGX97 +VWTdrEzac9T0ebIkNfzvZAzWtwic3FDgRh5XDopU+bhcJUV8Mko2QsyTbqfjbgZE/YX SUbPmz6JExobTWDXgEhcaQml6hmZ2rklzy/++bBdpUcq8EVSZUnzguXQFjrYjLrLjEMW bPM2xPNVIp/U1ImCAiR65betc2MqCaoi2aMyKorus9iBreGxisuVcZFJZ9CMq09Lv2ir /S1KMUg1dXE7Xi3Rkw5DZMYiwB5gGaJx836YoPqM0GOKOv+VxQ1MQZobj3psPAQrZZlp l4Bw== X-Gm-Message-State: AOAM531TNsvzN/onjhc9VGxORBdP7o8BjZ1BsSwiraB1Cq+547ACPn9p 0sgaxwD+xbeXpZ/CMGKxLWfVqx8cd4pLeQ== X-Google-Smtp-Source: ABdhPJx4HYrK6yFyS8PqqGH2MA7sdZgfipjwt1dn9VeVyPKVU0rhmzwL+o47Y+7X88zU4pvaKyli7A== X-Received: by 2002:ac2:5310:: with SMTP id c16mr5878883lfh.580.1636451178451; Tue, 09 Nov 2021 01:46:18 -0800 (PST) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id i7sm919376lfu.89.2021.11.09.01.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 01:46:17 -0800 (PST) Date: Tue, 9 Nov 2021 09:46:16 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Crash on expansion of tagged membership test Message-ID: <20211109094616.GA830891@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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: Justin Squirek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch corrects an issue in the compiler whereby the expansion of a tagged membership test when one of the types involved is a protected type can cause a crash a compile-time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Tagged_Membership): Use corresponding record type when expanding a tagged membership test on protected types. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -15346,6 +15346,17 @@ package body Exp_Ch4 is begin SCIL_Node := Empty; + -- We have to examine the corresponding record type when dealing with + -- protected types instead of the original, unexpanded, type. + + if Ekind (Right_Type) = E_Protected_Type then + Right_Type := Corresponding_Record_Type (Right_Type); + end if; + + if Ekind (Left_Type) = E_Protected_Type then + Left_Type := Corresponding_Record_Type (Left_Type); + end if; + -- In the case where the type is an access type, the test is applied -- using the designated types (needed in Ada 2012 for implicit anonymous -- access conversions, for AI05-0149).