From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id B28103858024 for ; Thu, 6 Jan 2022 17:13:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B28103858024 Received: by mail-wm1-x336.google.com with SMTP id g7-20020a7bc4c7000000b00345c4bb365aso4026012wmk.4 for ; Thu, 06 Jan 2022 09:13:04 -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=36OfkbUAiLhz/stkppmVMwi5fOLVl8/iPzZO0MojJCc=; b=4mKWrXVfn2zS45+GuCpwN0yzFYLbPQm3gXxxOFbLu/U+gLcBLreBtiSnC49LgSk61C LQYRVgsGIMAgGPA2BQyYSqOMGvYa7EKN9g8uPLhzM05g6DiWMtx1XSpg6eMXoX+Kbf9w mc3eOQY2jRafu8GkW+F//m1oVikuTqOxGvSECGAEgdXkg5uWW8P06b4GGQ0pnACdKFaY 4AGTnhde90Hm05fuQB+QH//1ATwKJWaf8q71rghu7K5OSstfF43SDzdIRXcjH5A/w09J PzLEIq837jK+2UfpOIefxuCTzckJP6p8L2NbwKdDqRmMVh2HiOCUPtu932Kh2XLbYxov UP+A== X-Gm-Message-State: AOAM533gUUuP8gny1SEhkEAiiGqvd21X6i7rnoQHYDof4dRv288Miu5h Gf1KlZ+vvEnr8n0bgwuVp/TrX3W8lZDn3Q== X-Google-Smtp-Source: ABdhPJzC5GBKo2/1fo+aj0XlBY0Gaqxyw6M9l1slzsqamNiKcRvC4/2riAx92X8TEphxl+I8lb5cQw== X-Received: by 2002:a05:600c:3787:: with SMTP id o7mr7902809wmr.110.1641489183781; Thu, 06 Jan 2022 09:13:03 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id u15sm1333321wmm.37.2022.01.06.09.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 09:13:03 -0800 (PST) Date: Thu, 6 Jan 2022 17:13:02 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [Ada] Avoid building malformed component constraints Message-ID: <20220106171302.GA2921590@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="RnlQjJ0d97Da+TV1" Content-Disposition: inline X-Spam-Status: No, score=-13.1 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-List-Received-Date: Thu, 06 Jan 2022 17:13:05 -0000 --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The previous fix introduced a not-yet-understood regression in compiling CodePeer. For now, we attempt a quick workaround for the problem. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Build_Discriminant_Reference): In the unexpected case where we previously would fail an assertion, we instead revert to the old behavior. --RnlQjJ0d97Da+TV1 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2107,11 +2107,7 @@ package body Sem_Util is -- Start of processing for Build_Discriminant_Reference begin - if Obj_Is_Good_Prefix then - return Make_Selected_Component (Loc, - Prefix => Copy_And_Maybe_Dereference (Obj), - Selector_Name => New_Occurrence_Of (Discrim, Loc)); - else + if not Obj_Is_Good_Prefix then -- If the given discriminant is not a component of the given -- object, then try the enclosing object. @@ -2128,10 +2124,15 @@ package body Sem_Util is (Discrim_Name => Discrim_Name, Obj => Name (Parent (Entity (Obj)))); else - pragma Assert (False); - raise Program_Error; + -- We are in some unexpected case here, so revert to the + -- old behavior (by falling through to it). + null; end if; end if; + + return Make_Selected_Component (Loc, + Prefix => Copy_And_Maybe_Dereference (Obj), + Selector_Name => New_Occurrence_Of (Discrim, Loc)); end Build_Discriminant_Reference; ------------------------------------ --RnlQjJ0d97Da+TV1--