From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 5A01A3A7643E for ; Wed, 28 Apr 2021 09:41:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5A01A3A7643E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=derodat@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1FBB856152; Wed, 28 Apr 2021 05:41:40 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IvxMFn7wKB3y; Wed, 28 Apr 2021 05:41:40 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E150956147; Wed, 28 Apr 2021 05:41:39 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id E094112D; Wed, 28 Apr 2021 05:41:39 -0400 (EDT) Date: Wed, 28 Apr 2021 05:41:39 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Refactor repeated checks for the expression of aspect Static Message-ID: <20210428094139.GA140007@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 28 Apr 2021 09:41:45 -0000 --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Check for the expression of the aspect Static were done inside branches corresponding to inside-a-generic and outside-a-generic. Now this check occurs only once. Code cleanup; behaviour is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Static): Refactor to have a single check for the expression being present; adapt comments. --ZGiS0Q5IWpPtfppv Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -2610,25 +2610,23 @@ package body Sem_Ch13 is -- component type C, a similar rule applies to C." end if; - -- Preanalyze the expression (if any) when the aspect resides - -- in a generic unit. (Is this generic-related code necessary - -- for this aspect? It's modeled on what's done for aspect - -- Disable_Controlled. ???) + -- When the expression is present, it must be static. If it + -- evaluates to True, the expression function is treated as + -- a static function. Otherwise the aspect appears without + -- an expression and defaults to True. - if Inside_A_Generic then - if Present (Expr) then - Preanalyze_And_Resolve (Expr, Any_Boolean); - end if; + if Present (Expr) then + -- Preanalyze the expression when the aspect resides in a + -- generic unit. (Is this generic-related code necessary + -- for this aspect? It's modeled on what's done for aspect + -- Disable_Controlled. ???) - -- Otherwise the aspect resides in a nongeneric context + if Inside_A_Generic then + Preanalyze_And_Resolve (Expr, Any_Boolean); - else - -- When the expression statically evaluates to True, the - -- expression function is treated as a static function. - -- Otherwise the aspect appears without an expression and - -- defaults to True. + -- Otherwise the aspect resides in a nongeneric context - if Present (Expr) then + else Analyze_And_Resolve (Expr, Any_Boolean); -- Error if the boolean expression is not static --ZGiS0Q5IWpPtfppv--