From patchwork Mon Oct 4 08:47:50 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: 1536001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VYwbDkGN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNF4j415lz9t0k for ; Mon, 4 Oct 2021 19:58:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDB4B3858410 for ; Mon, 4 Oct 2021 08:58:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDB4B3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633337921; bh=8V3QTx4FCSEbRXWhc0e+C3lzlC5PH3VUPg7pFbP92eQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VYwbDkGN5KGYzGW+yKhaO2KK/SnWjVPaVZi3hF4zUwLuQeWMe4EHvFaEqgkfW/Owi 7zkYZwA+5d1ZZYfBDUm2jE0WxqWulfKAmQZBOFUEVbl/AKOpspKmFS1plBdgWuCZVd GMdoFSCguQNggEENrHox87mCUxoHzJWi+bMo6eio= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix missing check on slice with a subtype indication Message-ID: <20211004084750.GA1536676@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: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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