]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2016-04-18 Yannick Moy <moy@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Apr 2016 10:02:58 +0000 (10:02 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Apr 2016 10:02:58 +0000 (10:02 +0000)
* sem_res.adb (Resolve_Call): Prevent inlining of
calls inside expression functions.  Factor previous code issuing
errors to call Cannot_Inline instead, which does appropriate
processing of message for GNATprove.

2016-04-18  Arnaud Charlet  <charlet@adacore.com>

* einfo.ads, sem_ch3.adb, sem_ch8.adb, osint-l.adb, rtsfind.adb,
osint-b.adb: Cleanups.

2016-04-18  Yannick Moy  <moy@adacore.com>

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Only create
body to inline in GNATprove mode when SPARK_Mode On applies to
subprogram body.
* sem_prag.adb, sem_prag.ads (Get_SPARK_Mode_Type): Make function
public.

2016-04-18  Eric Botcazou  <ebotcazou@adacore.com>

* layout.adb: Fix minor typo in comment.
* inline.adb: Fix minor pasto.
* sem_ch12.ads: Fix minor typos in comments.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235111 138bc75d-0d04-0410-961f-82ee72b054a4

14 files changed:
gcc/ada/ChangeLog
gcc/ada/einfo.ads
gcc/ada/inline.adb
gcc/ada/layout.adb
gcc/ada/osint-b.adb
gcc/ada/osint-l.adb
gcc/ada/rtsfind.adb
gcc/ada/sem_ch12.ads
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_prag.ads
gcc/ada/sem_res.adb

index c4e73d113285476228270d0c3d409c5c7c98e11a..c8e9141ff328d1edd12aecfafe9881cde4b36721 100644 (file)
@@ -1,3 +1,29 @@
+2016-04-18  Yannick Moy  <moy@adacore.com>
+
+       * sem_res.adb (Resolve_Call): Prevent inlining of
+       calls inside expression functions.  Factor previous code issuing
+       errors to call Cannot_Inline instead, which does appropriate
+       processing of message for GNATprove.
+
+2016-04-18  Arnaud Charlet  <charlet@adacore.com>
+
+       * einfo.ads, sem_ch3.adb, sem_ch8.adb, osint-l.adb, rtsfind.adb,
+       osint-b.adb: Cleanups.
+
+2016-04-18  Yannick Moy  <moy@adacore.com>
+
+       * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Only create
+       body to inline in GNATprove mode when SPARK_Mode On applies to
+       subprogram body.
+       * sem_prag.adb, sem_prag.ads (Get_SPARK_Mode_Type): Make function
+       public.
+
+2016-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * layout.adb: Fix minor typo in comment.
+       * inline.adb: Fix minor pasto.
+       * sem_ch12.ads: Fix minor typos in comments.
+
 2016-04-18  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_disp.adb (Check_Dispatching_Call): Major rewriting to
index deae1b98249236f2c9f149cfaeee28fc22a6f7c3..1fb29e4d9ac857978a7ed7649bf95c46130ea3b3 100644 (file)
@@ -3449,7 +3449,7 @@ package Einfo is
 
 --    Next_Discriminant (synthesized)
 --       Applies to discriminants returned by First/Next_Discriminant. Returns
---       the next language-defined (ie: perhaps non-girder) discriminant by
+--       the next language-defined (i.e. perhaps non-girder) discriminant by
 --       following the chain of declared entities as long as the kind of the
 --       entity corresponds to a discriminant. Note that the discriminants
 --       might be the only components of the record. Returns Empty if there
index bc7bc32416dd7771d42748558ce49ff8956f6636..9a7b3758da484288f85261e195c243540ecb8a3b 100644 (file)
@@ -3866,7 +3866,6 @@ package body Inline is
          --  We can now complete the cleanup actions of scopes that contain
          --  pending instantiations (skipped for generic units, since we
          --  never need any cleanups in generic units).
-         --  pending instantiations.
 
          if Expander_Active
            and then not Is_Generic_Unit (Main_Unit_Entity)
index c8d7ed7f6c766f6e2e834c2f661692df278bc85e..cee5853fcf2fb5a5b7a07da2beff53bc6e87f669 100644 (file)
@@ -3318,7 +3318,7 @@ package body Layout is
             --  we have no way of doing that or easily figuring it out, so we
             --  don't bother.
 
-            --  Historical note. In versions of GNAT prior to Nov 6th, 2010, an
+            --  Historical note. In versions of GNAT prior to Nov 6th, 2011, an
             --  odd distinction was made between inherited alignments greater
             --  than the computed alignment (where the larger alignment was
             --  inherited) and inherited alignments smaller than the computed
index 554d804af96c7e75e04891b89bb89a51681dcac9..322bc6cdba0efa34d9b8ebd6e78c3a7e4068c67f 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2014, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2015, 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- --
@@ -153,7 +153,7 @@ package body Osint.B is
    -- More_Lib_Files --
    --------------------
 
-   function More_Lib_Files return Boolean renames  More_Files;
+   function More_Lib_Files return Boolean renames More_Files;
 
    ------------------------
    -- Next_Main_Lib_File --
index 9cc8f4c9b6d03e221abe7c93f87c4c38538d5d7a..eb7e3c379c19d3753a9e540120e17f00db659669 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2015, 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- --
@@ -29,7 +29,7 @@ package body Osint.L is
    -- More_Lib_Files --
    --------------------
 
-   function More_Lib_Files return Boolean renames  More_Files;
+   function More_Lib_Files return Boolean renames More_Files;
 
    ------------------------
    -- Next_Main_Lib_File --
index 3c84bbe1153440cad718e5f91f28e5acff3098b6..e2d9cb5301888d537f0e45f969d170a0f1023fc8 100644 (file)
@@ -730,7 +730,7 @@ package body Rtsfind is
 
          declare
             U : RT_Unit_Table_Record
-                  renames  RT_Unit_Table (RE_Unit_Table (E));
+                  renames RT_Unit_Table (RE_Unit_Table (E));
          begin
             if No (U.Entity) then
                U.Entity := S;
index c54d7359dee7bf31243e345de7fe3ad8315fb0b5..faf8917b11ec2e0edf84e5e9122ee9c0ca2d5415 100644 (file)
@@ -100,7 +100,7 @@ package Sem_Ch12 is
       Body_Optional : Boolean := False);
    --  Called after semantic analysis, to complete the instantiation of
    --  package instances. The flag Inlined_Body is set if the body is
-   --  being instantiated on the fly for inlined purposes.
+   --  being instantiated on the fly for inlining purposes.
    --
    --  The flag Body_Optional indicates that the call is for an instance
    --  that precedes the current instance in the same declarative part.
@@ -112,10 +112,10 @@ package Sem_Ch12 is
    --  appears in the context of some other unit P that contains an instance
    --  of G, we compile the body of I2, but not that of I1. However, when we
    --  compile U as the main unit, we compile both bodies. This will lead to
-   --  lead to link-time errors if the compilation of I1 generates public
-   --  symbols, because those in I2 will receive different names in both
-   --  cases. This forces us to analyze the body of I1 even when U is not the
-   --  main unit. We don't want this additional mechanism to generate an error
+   --  link-time errors if the compilation of I1 generates public symbols,
+   --  because those in I2 will receive different names in both cases.
+   --  This forces us to analyze the body of I1 even when U is not the main
+   --  unit. We don't want this additional mechanism to generate an error
    --  when the body of the generic for I1 is not present, and this is the
    --  reason for the presence of the flag Body_Optional, which is exchanged
    --  between the current procedure and Load_Parent_Of_Generic.
index 5f28a14ba4a2db26a9e626351959cd66ed93ae00..a010b54cb618a272d25dbce9597674a07c5a5c41 100644 (file)
@@ -19828,7 +19828,7 @@ package body Sem_Ch3 is
                         end if;
 
                      elsif Is_Dispatching_Operation (Prim)
-                       and then Disp_Typ  /= Full_T
+                       and then Disp_Typ /= Full_T
                      then
 
                         --  Verify that it is not otherwise controlled by a
index 7f424791e6f356ed0426928f131667d36fc1d151..a0a75b2ef8d311b37fcf79f0700985d1e9cf3f14 100644 (file)
@@ -2178,6 +2178,11 @@ package body Sem_Ch6 is
       --  Check whether unanalyzed body has an aspect or pragma that may
       --  generate a SPARK contract.
 
+      function Body_Has_SPARK_Mode_On return Boolean;
+      --  Check whether SPARK_Mode On applies to the subprogram body, either
+      --  because it is specified directly on the body, or because it is
+      --  inherited from the enclosing subprogram or package.
+
       procedure Build_Subprogram_Declaration;
       --  Create a matching subprogram declaration for subprogram body N
 
@@ -2272,6 +2277,53 @@ package body Sem_Ch6 is
          return False;
       end Body_Has_Contract;
 
+      ----------------------------
+      -- Body_Has_SPARK_Mode_On --
+      ----------------------------
+
+      function Body_Has_SPARK_Mode_On return Boolean is
+         Decls : constant List_Id := Declarations (N);
+         Item  : Node_Id;
+
+      begin
+         --  Check for SPARK_Mode aspect
+
+         if Present (Aspect_Specifications (N)) then
+            Item := First (Aspect_Specifications (N));
+            while Present (Item) loop
+               if Get_Aspect_Id (Item) = Aspect_SPARK_Mode then
+                  return No (Expression (Item))
+                           or else
+                        (Nkind (Expression (Item)) = N_Identifier
+                           and then
+                         Get_SPARK_Mode_Type (Chars (Expression (Item))) = On);
+               end if;
+
+               Next (Item);
+            end loop;
+         end if;
+
+         --  Check for SPARK_Mode pragma
+
+         if Present (Decls) then
+            Item := First (Decls);
+            while Present (Item) loop
+               if Nkind (Item) = N_Pragma
+                 and then Get_Pragma_Id (Item) = Pragma_SPARK_Mode
+               then
+                  return Get_SPARK_Mode_From_Pragma (Item) = On;
+               end if;
+
+               Next (Item);
+            end loop;
+         end if;
+
+         --  Applicable SPARK_Mode is inherited from the enclosing subprogram
+         --  or package.
+
+         return SPARK_Mode = On;
+      end Body_Has_SPARK_Mode_On;
+
       ----------------------------------
       -- Build_Subprogram_Declaration --
       ----------------------------------
@@ -3695,6 +3747,7 @@ package body Sem_Ch6 is
         and then Present (Spec_Id)
         and then
           Nkind (Unit_Declaration_Node (Spec_Id)) = N_Subprogram_Declaration
+        and then Body_Has_SPARK_Mode_On
         and then Can_Be_Inlined_In_GNATprove_Mode (Spec_Id, Body_Id)
         and then not Body_Has_Contract
       then
@@ -3814,18 +3867,6 @@ package body Sem_Ch6 is
 
       Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id);
 
-      --  If SPARK_Mode for body is not On, disable frontend inlining for this
-      --  subprogram in GNATprove mode, as its body should not be analyzed.
-
-      if SPARK_Mode /= On
-        and then GNATprove_Mode
-        and then Present (Spec_Id)
-        and then Nkind (Parent (Parent (Spec_Id))) = N_Subprogram_Declaration
-      then
-         Set_Body_To_Inline (Parent (Parent (Spec_Id)), Empty);
-         Set_Is_Inlined_Always (Spec_Id, False);
-      end if;
-
       --  Check completion, and analyze the statements
 
       Check_Completion;
index e8f7b1f00d352de4762838d59be8263c4d749e11..73303f49f1215a58d2a1aa747b79b808a73d45f8 100644 (file)
@@ -7526,7 +7526,7 @@ package body Sem_Ch8 is
          --  array of Boolean type.
 
          when Name_Op_And | Name_Op_Not | Name_Op_Or  | Name_Op_Xor =>
-            while Id  /= Priv_Id loop
+            while Id /= Priv_Id loop
                if Valid_Boolean_Arg (Id) and then Is_Base_Type (Id) then
                   Add_Implicit_Operator (Id);
                   return True;
@@ -7538,7 +7538,7 @@ package body Sem_Ch8 is
          --  Equality: look for any non-limited type (result is Boolean)
 
          when Name_Op_Eq | Name_Op_Ne =>
-            while Id  /= Priv_Id loop
+            while Id /= Priv_Id loop
                if Is_Type (Id)
                  and then not Is_Limited_Type (Id)
                  and then Is_Base_Type (Id)
@@ -7553,7 +7553,7 @@ package body Sem_Ch8 is
          --  Comparison operators: scalar type, or array of scalar
 
          when Name_Op_Lt | Name_Op_Le | Name_Op_Gt | Name_Op_Ge =>
-            while Id  /= Priv_Id loop
+            while Id /= Priv_Id loop
                if (Is_Scalar_Type (Id)
                     or else (Is_Array_Type (Id)
                               and then Is_Scalar_Type (Component_Type (Id))))
@@ -7576,7 +7576,7 @@ package body Sem_Ch8 is
               Name_Op_Multiply |
               Name_Op_Divide   |
               Name_Op_Expon    =>
-            while Id  /= Priv_Id loop
+            while Id /= Priv_Id loop
                if Is_Numeric_Type (Id) and then Is_Base_Type (Id) then
                   Add_Implicit_Operator (Id);
                   return True;
@@ -7588,7 +7588,7 @@ package body Sem_Ch8 is
          --  Concatenation: any one-dimensional array type
 
          when Name_Op_Concat =>
-            while Id  /= Priv_Id loop
+            while Id /= Priv_Id loop
                if Is_Array_Type (Id)
                  and then Number_Dimensions (Id) = 1
                  and then Is_Base_Type (Id)
index 534681a8294d13c91595e43de786f06ac8bb348d..1d64de503f480e340aecf04f5dd8e9ad9e28f327 100644 (file)
@@ -235,11 +235,6 @@ package body Sem_Prag is
    --  original one, following the renaming chain) is returned. Otherwise the
    --  entity is returned unchanged. Should be in Einfo???
 
-   function Get_SPARK_Mode_Type (N : Name_Id) return SPARK_Mode_Type;
-   --  Subsidiary to the analysis of pragma SPARK_Mode as well as subprogram
-   --  Get_SPARK_Mode_Type. Convert a name into a corresponding value of type
-   --  SPARK_Mode_Type.
-
    function Has_Extra_Parentheses (Clause : Node_Id) return Boolean;
    --  Subsidiary to the analysis of pragmas Depends and Refined_Depends.
    --  Determine whether dependency clause Clause is surrounded by extra
index ce05bfd432c714e5450ea0862edef40154618764..3bc2f65ae92faabab72b7e0059d51edb9902db59 100644 (file)
@@ -383,6 +383,11 @@ package Sem_Prag is
    function Get_SPARK_Mode_From_Pragma (N : Node_Id) return SPARK_Mode_Type;
    --  Given a pragma SPARK_Mode node, return corresponding mode id
 
+   function Get_SPARK_Mode_Type (N : Name_Id) return SPARK_Mode_Type;
+   --  Subsidiary to the analysis of pragma SPARK_Mode as well as subprogram
+   --  Get_SPARK_Mode_From_Pragma. Convert a name into a corresponding value
+   --  of type SPARK_Mode_Type.
+
    procedure Initialize;
    --  Initializes data structures used for pragma processing. Must be called
    --  before analyzing each new main source program.
index 8eb8ac04f582a2c77010835e09b4645a575c3589..bd4b562f09bc7407a8f6e71d27eca3f9bb629d11 100644 (file)
@@ -6428,16 +6428,14 @@ package body Sem_Res is
             --  assertions as logic expressions.
 
             elsif In_Assertion_Expr /= 0 then
-               Error_Msg_NE ("info: no contextual analysis of &?", N, Nam);
-               Error_Msg_N ("\call appears in assertion expression", N);
-               Set_Is_Inlined_Always (Nam_UA, False);
+               Cannot_Inline
+                 ("cannot inline & (in assertion expression)?", N, Nam_UA);
 
             --  Calls cannot be inlined inside default expressions
 
             elsif In_Default_Expr then
-               Error_Msg_NE ("info: no contextual analysis of &?", N, Nam);
-               Error_Msg_N ("\call appears in default expression", N);
-               Set_Is_Inlined_Always (Nam_UA, False);
+               Cannot_Inline
+                 ("cannot inline & (in default expression)?", N, Nam_UA);
 
             --  Inlining should not be performed during pre-analysis
 
@@ -6447,10 +6445,8 @@ package body Sem_Res is
                --  inlined if the corresponding body has not been seen yet.
 
                if No (Body_Id) then
-                  Error_Msg_NE
-                    ("info: no contextual analysis of & (body not seen yet)?",
-                     N, Nam);
-                  Set_Is_Inlined_Always (Nam_UA, False);
+                  Cannot_Inline
+                    ("cannot inline & (body not seen yet)?", N, Nam_UA);
 
                --  Nothing to do if there is no body to inline, indicating that
                --  the subprogram is not suitable for inlining in GNATprove
@@ -6459,15 +6455,26 @@ package body Sem_Res is
                elsif No (Body_To_Inline (Nam_Decl)) then
                   null;
 
+               --  Do not inline calls inside expression functions, as this
+               --  would prevent interpreting them as logical formulas in
+               --  GNATprove.
+
+               elsif Present (Current_Subprogram)
+                       and then
+                     Is_Expression_Function_Or_Completion (Current_Subprogram)
+               then
+                  Cannot_Inline
+                    ("cannot inline & (inside expression function)?",
+                     N, Nam_UA);
+
                --  Calls cannot be inlined inside potentially unevaluated
                --  expressions, as this would create complex actions inside
                --  expressions, that are not handled by GNATprove.
 
                elsif Is_Potentially_Unevaluated (N) then
-                  Error_Msg_NE ("info: no contextual analysis of &?", N, Nam);
-                  Error_Msg_N
-                    ("\call appears in potentially unevaluated context", N);
-                  Set_Is_Inlined_Always (Nam_UA, False);
+                  Cannot_Inline
+                    ("cannot inline & (in potentially unevaluated context)?",
+                     N, Nam_UA);
 
                --  Otherwise, inline the call