From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97224 invoked by alias); 4 Jul 2019 08:50:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97117 invoked by uid 89); 4 Jul 2019 08:50:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=SPARK, spark, Node_Id, moy@adacore.com X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 08:50:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 76074560F9; Thu, 4 Jul 2019 04:50:38 -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 ENwAmz13kpKg; Thu, 4 Jul 2019 04:50:38 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 64DCE560DF; Thu, 4 Jul 2019 04:50:38 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 61C96619; Thu, 4 Jul 2019 04:50:38 -0400 (EDT) Date: Thu, 04 Jul 2019 08:51:00 -0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Skip code not in SPARK for ownership analysis Message-ID: <20190704085038.GA38817@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg00352.txt.bz2 --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 327 Ownership rules for pointer support should only apply to code marked in SPARK. There is no impact on compilation. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-07-04 Yannick Moy gcc/ada/ * sem_spark.adb (Check_Package_Spec, Check_Package_Body): Only analyze parts of the code marked in SPARK. --xHFwDpU9dbj6ez1V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" Content-length: 4168 --- gcc/ada/sem_spark.adb +++ gcc/ada/sem_spark.adb @@ -2364,39 +2364,43 @@ package body Sem_SPARK is Save_In_Elab : constant Boolean := Inside_Elaboration; Spec : constant Node_Id := Package_Specification (Corresponding_Spec (Pack)); - Prag : constant Node_Id := SPARK_Pragma (Defining_Entity (Pack)); + Id : constant Entity_Id := Defining_Entity (Pack); + Prag : constant Node_Id := SPARK_Pragma (Id); + Aux_Prag : constant Node_Id := SPARK_Aux_Pragma (Id); Saved_Env : Perm_Env; begin - -- Only SPARK bodies are analyzed - - if No (Prag) - or else Get_SPARK_Mode_From_Annotation (Prag) /= Opt.On + if Present (Prag) + and then Get_SPARK_Mode_From_Annotation (Prag) = Opt.On then - return; - end if; + Inside_Elaboration := True; - Inside_Elaboration := True; + -- Save environment and put a new one in place - -- Save environment and put a new one in place + Move_Env (Current_Perm_Env, Saved_Env); - Move_Env (Current_Perm_Env, Saved_Env); + -- Reanalyze package spec to have its variables in the environment - -- Reanalyze package spec to have its variables in the environment + Check_List (Visible_Declarations (Spec)); + Check_List (Private_Declarations (Spec)); - Check_List (Visible_Declarations (Spec)); - Check_List (Private_Declarations (Spec)); + -- Check declarations and statements in the special mode for + -- elaboration. - -- Check declarations and statements in the special mode for elaboration + Check_List (Declarations (Pack)); - Check_List (Declarations (Pack)); - Check_Node (Handled_Statement_Sequence (Pack)); + if Present (Aux_Prag) + and then Get_SPARK_Mode_From_Annotation (Aux_Prag) = Opt.On + then + Check_Node (Handled_Statement_Sequence (Pack)); + end if; - -- Restore the saved environment and free the current one + -- Restore the saved environment and free the current one - Move_Env (Saved_Env, Current_Perm_Env); + Move_Env (Saved_Env, Current_Perm_Env); - Inside_Elaboration := Save_In_Elab; + Inside_Elaboration := Save_In_Elab; + end if; end Check_Package_Body; ------------------------ @@ -2406,25 +2410,37 @@ package body Sem_SPARK is procedure Check_Package_Spec (Pack : Node_Id) is Save_In_Elab : constant Boolean := Inside_Elaboration; Spec : constant Node_Id := Specification (Pack); + Id : constant Entity_Id := Defining_Entity (Pack); + Prag : constant Node_Id := SPARK_Pragma (Id); + Aux_Prag : constant Node_Id := SPARK_Aux_Pragma (Id); Saved_Env : Perm_Env; begin - Inside_Elaboration := True; + if Present (Prag) + and then Get_SPARK_Mode_From_Annotation (Prag) = Opt.On + then + Inside_Elaboration := True; - -- Save environment and put a new one in place + -- Save environment and put a new one in place - Move_Env (Current_Perm_Env, Saved_Env); + Move_Env (Current_Perm_Env, Saved_Env); - -- Check declarations in the special mode for elaboration + -- Check declarations in the special mode for elaboration - Check_List (Visible_Declarations (Spec)); - Check_List (Private_Declarations (Spec)); + Check_List (Visible_Declarations (Spec)); - -- Restore the saved environment and free the current one + if Present (Aux_Prag) + and then Get_SPARK_Mode_From_Annotation (Aux_Prag) = Opt.On + then + Check_List (Private_Declarations (Spec)); + end if; - Move_Env (Saved_Env, Current_Perm_Env); + -- Restore the saved environment and free the current one - Inside_Elaboration := Save_In_Elab; + Move_Env (Saved_Env, Current_Perm_Env); + + Inside_Elaboration := Save_In_Elab; + end if; end Check_Package_Spec; ------------------------------- --xHFwDpU9dbj6ez1V--