From patchwork Tue Nov 9 09:46:08 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: 47258 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74FCB3858428 for ; Tue, 9 Nov 2021 10:02:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74FCB3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636452168; bh=HUwBZN+8BGE6KXxLoIbCmk0KcXZ1D+Warp+97beB9EQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Nj8DdwGjH4VkTAzy4j1cBn03N6OjDugD4B1W6ywP9VSPj7VisQPtCTDxryiE9Ak3z 2EkHvUYowzHtzMAQJbK3nGui1aBiJheqR5TCwSiz3Rmp2SGRFDzAzYumK+Yi4rNiYO qyX83+m+FXJMEPriBQMd/YQ8eReJ0ruY9RmKN008= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 8F59B3858425 for ; Tue, 9 Nov 2021 09:46:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F59B3858425 Received: by mail-lf1-x12f.google.com with SMTP id x27so43028498lfu.5 for ; Tue, 09 Nov 2021 01:46:11 -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=HUwBZN+8BGE6KXxLoIbCmk0KcXZ1D+Warp+97beB9EQ=; b=fcEMM9L7FM/XSFSES3j5hfbL7HEWObjOFMD6+EZpiZ4xIKZ2q1RcV0k+rhuhPwJtmW 6BpptXMfN1MRVFGaSZPiCXJ3PoBMvwzQMq+GLKBgouMMgh1FBir4OQ2KKE1R/1M8Sc6F /DrKrPaEu57QPZnZaR+JUfQi8PrPi6ol8bvyamxvMP/cWchgH5vudnpbKV7tCEXDZRdj ZCFij/Gb8rGfKHLmVfmmis+3CnM+xJSDfVDQJRdt6QHk5kfBpExWEgdcbbI90bIvZvGk 0BeA3u2VsPspNtpJC2nmiP5zigu2aahHZTU8J9hesGL9x3zJtPMCVGCE2QvqpU/l8tci Z4JA== X-Gm-Message-State: AOAM531/bWZ7+7k61GSdBAI7ZsSBZimelcYrypq4/f6MbXQ/YFVsitaO 9UneEOp+3eyNbyetaLu9mZDk/ny3xZ0sNjpA X-Google-Smtp-Source: ABdhPJyF1Ksxr6rzvvpxz9VKXBwfURrxs+2pvb1zKxwGUvMgwpSD9HB87Qw7Ba+wEmpwQmozmXvlWg== X-Received: by 2002:a05:6512:3e09:: with SMTP id i9mr5745891lfv.239.1636451170496; Tue, 09 Nov 2021 01:46:10 -0800 (PST) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id u22sm1217310lff.118.2021.11.09.01.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 01:46:09 -0800 (PST) Date: Tue, 9 Nov 2021 09:46:08 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Accessibility fix Message-ID: <20211109094608.GA830553@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: Ghjuvan Lacambre Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This commit fixes an issue where when creating initialization procedures, GNAT would generate failing accessibility checks because it would use the scope depth of the parameter of the initialization procedure instead of using the scope depth passed as parameter. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Accessibility_Level): Use init_proc_level_formal instead of computing a new accessibility level from Scope_Depth (E). 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 @@ -744,6 +744,13 @@ package body Sem_Util is then return Accessibility_Level (Related_Expression (E)); + elsif Level = Dynamic_Level + and then Ekind (E) in E_In_Parameter | E_In_Out_Parameter + and then Present (Init_Proc_Level_Formal (Scope (E))) + then + return New_Occurrence_Of + (Init_Proc_Level_Formal (Scope (E)), Loc); + -- Normal object - get the level of the enclosing scope else