From patchwork Tue May 15 09:27:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 159271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 449E2B6FB4 for ; Tue, 15 May 2012 19:27:37 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1337678858; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=JnU7/84R7Ab70c53tYjB 5leJ92I=; b=lYA+3pLCJGJj5LAjTqvR6FY8Yv9w1vONuaCqgFq+PdR/BQ0UVzfa NjK1Rx0oUvr1CPNW+vj4ZP2pcXvEI89KRU57XIn9DReTrfuJ04v6vjN7y2+/7494 9h7zfre3In7eTJFl8oBA4y4TvRumpPg9BQV1rdav4IMHrlm54WLqGm4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=vFsGOrrOQG/zMl4uvkFNJRPa1xlwCSQd5+nhzEaoid6X5r1H7/zw8BkmAcUvtp 88cxYIWr6BApuV88SJtptCBhxmWTgS4vAJNF0jFs+XXzsKGGVQ1dm45vLpCwRJtX n8VptXb5nzwqhePgXsPyWmV0p7fzoyBsj+XeClSS44wP0=; Received: (qmail 15004 invoked by alias); 15 May 2012 09:27:29 -0000 Received: (qmail 14934 invoked by uid 22791); 15 May 2012 09:27:26 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 May 2012 09:27:11 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 43AA01C6E3F; Tue, 15 May 2012 05:27:10 -0400 (EDT) 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 MabD7YYIqcvx; Tue, 15 May 2012 05:27:10 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 246091C6E61; Tue, 15 May 2012 05:27:10 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 24CBB92BF6; Tue, 15 May 2012 05:27:10 -0400 (EDT) Date: Tue, 15 May 2012 05:27:10 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Deferred constants are not always compile time known values in Alfa mode Message-ID: <20120515092710.GA25720@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Outside of the scope of their full view, deferred constants are not anymore considered as compile time known values in Alfa mode. This allows parameterized formal verification, in which a deferred constant value if not known from client units. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-05-15 Yannick Moy * sem_aux.ads: Correct typo. * sem_eval.adb (Compile_Time_Known_Value): Return False in Alfa mode for a deferred constant when outside of the scope of its full view. Index: sem_aux.ads =================================================================== --- sem_aux.ads (revision 187501) +++ sem_aux.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -99,7 +99,7 @@ function Constant_Value (Ent : Entity_Id) return Node_Id; -- Ent is a variable, constant, named integer, or named real entity. This -- call obtains the initialization expression for the entity. Will return - -- Empty for for a deferred constant whose full view is not available or + -- Empty for a deferred constant whose full view is not available or -- in some other cases of internal entities, which cannot be treated as -- constants from the point of view of constant folding. Empty is also -- returned for variables with no initialization expression. Index: sem_eval.adb =================================================================== --- sem_eval.adb (revision 187501) +++ sem_eval.adb (working copy) @@ -1302,7 +1302,16 @@ if Ekind (E) = E_Enumeration_Literal then return True; - elsif Ekind (E) = E_Constant then + -- In Alfa mode, the value of deferred constants should be ignored + -- outside the scope of their full view. This allows parameterized + -- formal verification, in which a deferred constant value if not + -- known from client units. + + elsif Ekind (E) = E_Constant + and then not (Alfa_Mode + and then Present (Full_View (E)) + and then not In_Open_Scopes (Scope (E))) + then V := Constant_Value (E); return Present (V) and then Compile_Time_Known_Value (V); end if;