From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 8A896385020E for ; Mon, 12 Sep 2022 08:19:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A896385020E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x432.google.com with SMTP id c11so14030189wrp.11 for ; Mon, 12 Sep 2022 01:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=d2LPt+RvWCN8ryJxeca0ZuduHUeUWI5sP/98V1uFprI=; b=CPlEzc8cbeY4Kch9boUG81YwMBKUF62Tpnm1oGZKv6Dm1C8/x8sIdK/QCO2VjZ+8cB n9XSuvVpirdkPkrg51TIjMylOGF8JPtsos4aLPX1utlyOyeKHUmtjT4TL69ZtRNAQ6NJ DwJuXgdV0K+EnSxdxLR/v87t29cYtO1VsdZWKFfQmIWeHIQELtS0Eh7Bn0tFNtbVv576 yF6ndWaP8E/lLOttSG5fr6xy+Qjh2ax5UsGha5XpJCYThjGjvGYy2o8eu71o71V+/6+f 2Jwlgx57XGkhX03iPkBX/7YivPRx4AFqAb4+x8jzVD1kBOdGfAhbJlPxjBj1azSWZPeL FaxA== 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=d2LPt+RvWCN8ryJxeca0ZuduHUeUWI5sP/98V1uFprI=; b=YAlAqjP9wvhAjyhgUesTvDBnRmhLWgT6js7Ial5ZnO2qcMuKoSQrh87d+MB3bJiohW y/GwLwbtDvDxyN8m7JdHwMoSTtzcOTNLL0EUyhC1cAdsV8GSTzpFUq8DjYHtljP+TXDU BZHlnrszgwBly+SYpnuEPiukObgAukrqflvOgYeqTTVHyNR9kloPwZ4rZQTxT90TPqfp Yw0Uyp7XgaCTD6uZj4RUaOIQowoAm7jYZSO9b/8KNHSnHGTmMoKEsrdm6TGbi6q2ocS3 wH4cdN7hiVlNBnpKAm8OzU/CZFq/a7AA/ZW5aY7huctevCxqM0Ieqa763VxjQNXAcR3n rW8A== X-Gm-Message-State: ACgBeo1GvD6Demu6MUBjKuIEKVCrlNHpT+HTB8XF1I5gsLtWrNOKGxB4 jv58UsbU6jDeMgVBI6LpV+uAqG8C9uGgLQ== X-Google-Smtp-Source: AA6agR4jzeKrUQvdrn7Aw54U5zAMQXxxXbHOTFharngu/JFIroL3Xn9sU5EOigym89Zuq+raRpbKgw== X-Received: by 2002:a5d:64c2:0:b0:228:cb2b:f38d with SMTP id f2-20020a5d64c2000000b00228cb2bf38dmr14242632wri.491.1662970786194; Mon, 12 Sep 2022 01:19:46 -0700 (PDT) Received: from poulhies-Precision-5550 (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id u8-20020a05600c19c800b003a54d610e5fsm9840051wmq.26.2022.09.12.01.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:45 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:45 +0200 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [Ada] Storage_Error raised analyzing type with call in its range constraint Message-ID: <20220912081945.GA1513162@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" 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 List-Id: --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch corrects a problem in the compiler whereby the determination of scope levels during the generation of accessibility checks for function calls within range constraints leads to a compiler crash due to the type not being fully analyzed at the point in which its scope depth must be obtained. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Innermost_Master_Scope_Depth): Detect and handle case where scope depth is not set on an enclosing scope. --0F1p//8PRICkK4MW 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 @@ -316,8 +316,20 @@ package body Sem_Util is -- Ignore transient scopes made during expansion if Comes_From_Source (Node_Par) then - return - Scope_Depth (Encl_Scop) + Master_Lvl_Modifier; + -- Note that in some rare cases the scope depth may not be + -- set, for example, when we are in the middle of analyzing + -- a type and the enclosing scope is said type. So, instead, + -- continue to move up the parent chain since the scope + -- depth of the type's parent is the same as that of the + -- type. + + if not Scope_Depth_Set (Encl_Scop) then + pragma Assert (Nkind (Parent (Encl_Scop)) + = N_Full_Type_Declaration); + else + return + Scope_Depth (Encl_Scop) + Master_Lvl_Modifier; + end if; end if; -- For a return statement within a function, return --0F1p//8PRICkK4MW--