From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 2EB4C398B154; Wed, 16 Jun 2021 08:45:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EB4C398B154 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1508] [Ada] Spurious accessibility error on "for of" loop parameter X-Act-Checkin: gcc X-Git-Author: Justin Squirek X-Git-Refname: refs/heads/master X-Git-Oldrev: 7626537ae7643013855cf28f82b16239314f20d1 X-Git-Newrev: f5b4b6bf14a571df07021936c29b4773beb80324 Message-Id: <20210616084503.2EB4C398B154@sourceware.org> Date: Wed, 16 Jun 2021 08:45:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 08:45:03 -0000 https://gcc.gnu.org/g:f5b4b6bf14a571df07021936c29b4773beb80324 commit r12-1508-gf5b4b6bf14a571df07021936c29b4773beb80324 Author: Justin Squirek Date: Sat Feb 27 14:30:09 2021 -0500 [Ada] Spurious accessibility error on "for of" loop parameter gcc/ada/ * sem_util.adb (Accessibility_Level): Take into account renamings of loop parameters. Diff: --- gcc/ada/sem_util.adb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 65376b1e1a1..aa2449329cd 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -664,6 +664,15 @@ package body Sem_Util is return Make_Level_Literal (Scope_Depth (Enclosing_Dynamic_Scope (E)) + 1); + -- Check if E is an expansion-generated renaming of an iterator + -- by examining Related_Expression. If so, determine the + -- accessibility level based on the original expression. + + elsif Ekind (E) in E_Constant | E_Variable + and then Present (Related_Expression (E)) + then + return Accessibility_Level (Related_Expression (E)); + -- Normal object - get the level of the enclosing scope else