From patchwork Tue Sep 6 07:15:46 2022 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: 1018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp504939wrt; Tue, 6 Sep 2022 00:21:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7eK0zNEO47R/Vx7E/k1wN7TyCHZmPuzwJtqRK91F3AIF7zu0owaa0t2RwQkZ66QDsOi/wE X-Received: by 2002:a17:906:8a79:b0:76f:55ff:5ced with SMTP id hy25-20020a1709068a7900b0076f55ff5cedmr398209ejc.765.1662448917377; Tue, 06 Sep 2022 00:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662448917; cv=none; d=google.com; s=arc-20160816; b=VzBmbimgZvFWWucR8Q043lkF3sW4blTaKbKLJTxGetVd9Y3SAncf0etRW1fC06lWSk 6MRfkoCmOFrtNM6t+7Wv8ZisvwV+zueFbacnlTmGUQaZJB8/qQ+ggNu3m7UxVXdSWd0c ClNkCgNs+7cAO8bl7pZ6iKa3u2gdC/dulC/tLeyz+2lJoNVwqS3u7NZUxQklacUCS9IB 8PrG8DeXuNuLEgxpJNT7Czsx2HDaZ11EdT2C2/Aemmxrm7t92YHEDGTlzBASx+6gAUqb cu0Fqg5CJJ6GHaIEp96oEVC7K2kgPuAIWRxQD1Yln83F6WsehvipqlumGaQUb2YNU18x LjVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=erauPPPTqmWo6bCMRkNrjKWYpCTAfcIFuhIW3Kjpdh0=; b=VkjcgmqyLiJZRgzGgJqSeBgBtbbUSb/kZLVpg+w+QSfwpRTLdUooZjLkSytoU4YPmP jht7CMWQixpFpI8LefRo8HtnmrD1OWFA0jhnrLVTB7VGKFL7f3EvXFdym5+tdV76vnBN cnSzq1uH2bcwwoMT+PL7vMUgyYFXTGzXlAv7uX5piWLqoQnhRMzkuUIUqYtCGYqCs1CG tjKcq3WllX1NBl/U/G3N17TsptL3tj1fLcIaN6HK6vhUCFWt//Dejbx4FNr6uDodB+1x H1T3rL2aRurK7TYvmbcRcRK2wpbtcwNlq7T5M3bQSgguQJv+egfj1Od6ZZMqU9RMxtuE Ilig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yC5tcXWB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cs15-20020a0564020c4f00b00445dfc9c0cdsi8914998edb.122.2022.09.06.00.21.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yC5tcXWB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5775E393BA5B for ; Tue, 6 Sep 2022 07:18:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5775E393BA5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662448713; bh=erauPPPTqmWo6bCMRkNrjKWYpCTAfcIFuhIW3Kjpdh0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=yC5tcXWB+z6u8ZK1MslDNDvO28TLrxM9I/1t0sGunEpihF6bU+Zwy/4Af9tEoGv7I E4oGLSoxZb4ZsmVSZccvZ7bnTXPSYM/Uz0P51BB+oqaHHCzJVWWHr84joll0w/HW7w cQnq6IG9I2rsKvd/JOpFYzVx2fQMlKnFtlHF3aYk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 547FA3851408 for ; Tue, 6 Sep 2022 07:15:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 547FA3851408 Received: by mail-wr1-x435.google.com with SMTP id t7so8982854wrm.10 for ; Tue, 06 Sep 2022 00:15:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=erauPPPTqmWo6bCMRkNrjKWYpCTAfcIFuhIW3Kjpdh0=; b=EzN5eV2K9nefwqTg2C77zq465UXvE5oVypcQY/3jYYGP+XQnlHY2qtZCEKUgIHq7GR 2niBSbe5WP0J6PQmFDyupMDIIhvt/VV1QE1c7Jh/uSPKkJ6TNZgbXC99cUnj6spkeAcN AR+6mf5+k1QgZhqtdQSGNkc7YNprwdzGs2RtNZEab+7wLiQ8m3AcoMafiuaXyE2s0xT7 eKSa5q1ahYeBts0eRp17FASKXcHIVvzFLpVD14fgmbJgAA7YadeoFAo/2zFtN8TtDVU+ Gadd1JPakZUvsW2j2haXwZkCr65N8D96X864vZqH6Jse4vPSALs0zAuV6SnlpQ21DeS6 tYfA== X-Gm-Message-State: ACgBeo0BLuU84ZZ6b+SoVkCHhaK4zIAiatIKW4hG7W5IaCaAPMKOMex8 FFTuWDnZ0S8mn0CCqMyc1nGpTyQUJGsEGA== X-Received: by 2002:a05:6000:1d84:b0:224:f447:b1a7 with SMTP id bk4-20020a0560001d8400b00224f447b1a7mr25218725wrb.688.1662448547212; Tue, 06 Sep 2022 00:15:47 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id a11-20020a056000050b00b002205a5de337sm11234831wrf.102.2022.09.06.00.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:15:46 -0700 (PDT) Date: Tue, 6 Sep 2022 09:15:46 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Temporarily simplify legality checks for Inox case statements Message-ID: <20220906071546.GA1280295@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.9 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Steve Baird Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743204035647431518?= X-GMAIL-MSGID: =?utf-8?q?1743204035647431518?= INOX (which is enabled via -gnatX) supports composite case-statement selectors. As a temporary measure, simplify the coverage-related compile-time checks for such case statements via two changes: an others choice is always required for such a case statement, and no legality checks relating to overlapping of case choices are performed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_case.adb: Define a new Boolean constant, Simplified_Composite_Coverage_Rules, initialized to True. Setting this constant to True has two effects: 1- Representative value sets are not fully initialized - this is done to avoid capacity problems, as well as for performance. 2- In Check_Case_Pattern_Choices, the only legality check performed is a check that a "when others =>" choice is present. diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb --- a/gcc/ada/sem_case.adb +++ b/gcc/ada/sem_case.adb @@ -106,6 +106,14 @@ package body Sem_Case is package Composite_Case_Ops is + Simplified_Composite_Coverage_Rules : constant Boolean := True; + -- Indicates that, as a temporary stopgap, we implement + -- simpler coverage-checking rules when casing on a + -- composite selector: + -- 1) Require that an Others choice must be given, regardless + -- of whether all possible values are covered explicitly. + -- 2) No legality checks regarding overlapping choices. + function Box_Value_Required (Subtyp : Entity_Id) return Boolean; -- If result is True, then the only allowed value (in a choice -- aggregate) for a component of this (sub)type is a box. This rule @@ -263,7 +271,6 @@ package body Sem_Case is type Bound_Values is array (Positive range <>) of Node_Id; end Choice_Analysis; - end Composite_Case_Ops; procedure Expand_Others_Choice @@ -2526,6 +2533,14 @@ package body Sem_Case is for P in Part_Id loop Insert_Representative (Component_Bounds (P).Low, P); end loop; + + if Simplified_Composite_Coverage_Rules then + -- Omit other representative values to avoid capacity + -- problems building data structures only used in + -- compile-time checks that will not be performed. + return Result; + end if; + for C of Choices_Bounds loop if not C.Is_Others then for P in Part_Id loop @@ -3368,8 +3383,6 @@ package body Sem_Case is -------------------------------- procedure Check_Case_Pattern_Choices is - -- ??? Need to Free/Finalize value sets allocated here. - package Ops is new Composite_Case_Ops.Choice_Analysis (Case_Statement => N); use Ops; @@ -3394,8 +3407,14 @@ package body Sem_Case is Covered : Value_Set := Empty; -- The union of all alternatives seen so far - begin + if Composite_Case_Ops.Simplified_Composite_Coverage_Rules then + if not (for some Choice of Info => Choice.Is_Others) then + Error_Msg_N ("others choice required", N); + end if; + return; + end if; + for Choice of Info loop if Choice.Is_Others then Others_Seen := True;