From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 428693858437 for ; Mon, 4 Oct 2021 08:47:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 428693858437 Received: by mail-lf1-x12a.google.com with SMTP id b20so68769942lfv.3 for ; Mon, 04 Oct 2021 01:47:53 -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=8V3QTx4FCSEbRXWhc0e+C3lzlC5PH3VUPg7pFbP92eQ=; b=3fGSiu9cbudAAZQcZDJ3UOp9bfvc9PRI8Q02by5S08Ss1uF54WnzXnl08zM40Nn1wn GcuDQjQSfMfj9DVHjohe5VAN2eNvQYLq0WbWRGQa/jvAM0oP5Tql17qa6WqfT5PWhGX+ I7cjMIJN1xlrPgMHM0bQzcnFUZl7GX12KgJvsvtRmBYx/fgJE/U4UKQsMapES2duiXRB Mlw+vfTrU8BV5cptwBLmnB/lPr+kB4Cv/MkKndb5f9fgk/j3Tg/90MSGaGTc3Ckepp/v j49uJqCK7M5uucFFZBkoXOs2HC4vPXlEPrPHB4CsmazDECOyKCo10e10vQs7iH8ljqzK Fjvg== X-Gm-Message-State: AOAM533oNbqXhQqj0kPDbR4TSbZ6tH63oFNmTTARFKqulFbLyg5tWFZz ydZspHWUIMwLNB5uaT0vvuxoUslS+wMqug== X-Google-Smtp-Source: ABdhPJxWsvDdfCbGpMk3w9Mcm36XcqDEsjbuYRoZ3HIko4Vg+aUHzsUIBJEg0FdBgD+rL+s1+FiK7w== X-Received: by 2002:a19:9142:: with SMTP id y2mr14038967lfj.168.1633337272097; Mon, 04 Oct 2021 01:47:52 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id j20sm1372563lfu.304.2021.10.04.01.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 01:47:51 -0700 (PDT) Date: Mon, 4 Oct 2021 08:47:50 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Fix missing check on slice with a subtype indication Message-ID: <20211004084750.GA1536676@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tThc/1wpZn/ma/RB" 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-List-Received-Date: Mon, 04 Oct 2021 08:47:54 -0000 --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A slice range can be specified either by a subtype name, regular range, or subtype indication with constraints. The compiler missed the last case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Slice): Handle range given as a subtype indication. --tThc/1wpZn/ma/RB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -11360,7 +11360,11 @@ package body Sem_Res is Set_Parent (Dexpr, Parent (Drange)); Set_Sloc (Dexpr, Sloc (Drange)); - -- The discrete_range is a regular range. Resolve the bounds and remove + elsif Nkind (Drange) = N_Subtype_Indication then + Dexpr := Range_Expression (Constraint (Drange)); + + -- The discrete_range is a regular range (or a range attribute, which + -- will be resolved into a regular range). Resolve the bounds and remove -- their side effects. else --tThc/1wpZn/ma/RB--