]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2014-07-18 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Jul 2014 10:09:31 +0000 (10:09 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Jul 2014 10:09:31 +0000 (10:09 +0000)
* sem_util.adb (Check_Expression_Against_Static_Predicate):
Mark expression as non-static if it fails static predicate check,
and issue additional warning.

2014-07-18  Pascal Obry  <obry@adacore.com>

* a-witeio.adb (Put): Control translation based on
wide_text_translation_required.
* adaint.c (CurrentCCSEncoding): New variable.
* initialize.c (__gnat_initialize): On Windows initialize
CurrentCCSEncoding based on values in GNAT_CCS_ENCODING
environment variable.
* mingw32.h (CurrentCCSEncoding): New external.
(__gnat_wide_text_translation_required): Likewise.
* sysdep.c (wide_text_translation_required): New variable.
(__gnat_set_wide_text_mode): Set mode based on CurrentCCSEncoding.

2014-07-18  Hristian Kirtchev  <kirtchev@adacore.com>

* sem_prag.adb (Analyze_Refined_Depends_In_Decl_Part): Remove global
variable Refined_States.  Add global variable Matched_Items.
(Check_Dependency_Clause): Account for dependency
clauses utilizing states with visible null refinements.
(Is_Null_Refined_State): New routine.
(Match_Items): Record each successfully matched item of pragma Depends.
(Record_Item): New routine.

2014-07-18  Ed Schonberg  <schonberg@adacore.com>

* sem_attr.adb (Analyze_Attribute, case 'Update): Set
Do_Range_Check flag on a dynamic index expression used in a
component association in the argument of Update.

2014-07-18  Gary Dismukes  <dismukes@adacore.com>

* einfo.ads, sem_eval.ads, sem_ch13.adb: Minor reformatting.

2014-07-18  Hristian Kirtchev  <kirtchev@adacore.com>

* exp_ch6.adb (Expand_Simple_Function_Return): Redo the marking
of enclosing blocks, loops and the enclosing function using a
parent-based traversal.
* exp_util.adb (Wrap_Statements_In_Block): Suppress the secondary
stack reclamation if the iterator loop contains a return statement
that uses the stack.
* sem_ch5.adb (Analyze_Loop_Statement): There is no need to
patch up the scope stack as the secondary stack management now
takes into account the enclosing function of the iterator loop.

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

16 files changed:
gcc/ada/ChangeLog
gcc/ada/a-witeio.adb
gcc/ada/adaint.c
gcc/ada/einfo.ads
gcc/ada/exp_ch6.adb
gcc/ada/exp_util.adb
gcc/ada/gnat_rm.texi
gcc/ada/initialize.c
gcc/ada/mingw32.h
gcc/ada/sem_attr.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_eval.ads
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb
gcc/ada/sysdep.c

index d6a5c0af5ee56b93d67fff98460ef4bbe30cb40f..99cdb1e45288f84180e36a67fa8d07249afae1bd 100644 (file)
@@ -1,3 +1,54 @@
+2014-07-18  Robert Dewar  <dewar@adacore.com>
+
+       * sem_util.adb (Check_Expression_Against_Static_Predicate):
+       Mark expression as non-static if it fails static predicate check,
+       and issue additional warning.
+
+2014-07-18  Pascal Obry  <obry@adacore.com>
+
+       * a-witeio.adb (Put): Control translation based on
+       wide_text_translation_required.
+       * adaint.c (CurrentCCSEncoding): New variable.
+       * initialize.c (__gnat_initialize): On Windows initialize
+       CurrentCCSEncoding based on values in GNAT_CCS_ENCODING
+       environment variable.
+       * mingw32.h (CurrentCCSEncoding): New external.
+       (__gnat_wide_text_translation_required): Likewise.
+       * sysdep.c (wide_text_translation_required): New variable.
+       (__gnat_set_wide_text_mode): Set mode based on CurrentCCSEncoding.
+
+2014-07-18  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * sem_prag.adb (Analyze_Refined_Depends_In_Decl_Part): Remove global
+       variable Refined_States.  Add global variable Matched_Items.
+       (Check_Dependency_Clause): Account for dependency
+       clauses utilizing states with visible null refinements.
+       (Is_Null_Refined_State): New routine.
+       (Match_Items): Record each successfully matched item of pragma Depends.
+       (Record_Item): New routine.
+
+2014-07-18  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_attr.adb (Analyze_Attribute, case 'Update): Set
+       Do_Range_Check flag on a dynamic index expression used in a
+       component association in the argument of Update.
+
+2014-07-18  Gary Dismukes  <dismukes@adacore.com>
+
+       * einfo.ads, sem_eval.ads, sem_ch13.adb: Minor reformatting.
+
+2014-07-18  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * exp_ch6.adb (Expand_Simple_Function_Return): Redo the marking
+       of enclosing blocks, loops and the enclosing function using a
+       parent-based traversal.
+       * exp_util.adb (Wrap_Statements_In_Block): Suppress the secondary
+       stack reclamation if the iterator loop contains a return statement
+       that uses the stack.
+       * sem_ch5.adb (Analyze_Loop_Statement): There is no need to
+       patch up the scope stack as the secondary stack management now
+       takes into account the enclosing function of the iterator loop.
+
 2014-07-18  Robert Dewar  <dewar@adacore.com>
 
        * sem_ch3.adb, g-memdum.ads, i-cstrea.ads: Minor reformatting.
index 1f5e4622761f7805f861cdb4de144a911a0b6281..92c2dfa747761e4fe5364dc5826d18df7c025656 100644 (file)
@@ -1227,10 +1227,10 @@ package body Ada.Wide_Text_IO is
      (File : File_Type;
       Item : Wide_Character)
    is
-      text_translation_required : Boolean;
-      for text_translation_required'Size use Character'Size;
-      pragma Import (C, text_translation_required,
-                       "__gnat_text_translation_required");
+      wide_text_translation_required : Boolean;
+      for wide_text_translation_required'Size use Character'Size;
+      pragma Import (C, wide_text_translation_required,
+                       "__gnat_wide_text_translation_required");
       --  Text translation is required on Windows only. This means that the
       --  console is doing translation and we do not want to do any encoding
       --  here. If this boolean is set we just output the character as-is.
@@ -1256,7 +1256,7 @@ package body Ada.Wide_Text_IO is
    begin
       FIO.Check_Write_Status (AP (File));
 
-      if text_translation_required then
+      if wide_text_translation_required then
          set_wide_text_mode (fileno (File.Stream));
          Discard := fputwc (Wide_Character'Pos (Item), File.Stream);
       else
index 9bfb6895f33079c6fc60a0a07a3fc3400166077a..4d99c68ca0b24346c98a82759d3e87851165824e 100644 (file)
@@ -123,8 +123,9 @@ extern "C" {
 #else
 #include "mingw32.h"
 
-/* Current code page to use, set in initialize.c.  */
+/* Current code page and CCS encoding to use, set in initialize.c.  */
 UINT CurrentCodePage;
+UINT CurrentCCSEncoding;
 #endif
 
 #include <sys/utime.h>
index 73ec037fc80eec8b01cf9c49f6c18d5521d0c822..eb1f7b7d916337bbf8054379075736769348ad8a 100644 (file)
@@ -1881,7 +1881,7 @@ package Einfo is
 --       Defined in all types and subtypes. Set if the type (which must be
 --       a discrete, real, or string subtype) has a static predicate, i.e. a
 --       predicate whose expression is predicate-static. This can result from
---       use of a Predicate, Static_Predicate or Dynamic_Predicate aspect. We
+--       use of a Predicate, Static_Predicate, or Dynamic_Predicate aspect. We
 --       can distinguish these cases by testing Has_Static_Predicate_Aspect
 --       and Has_Dynamic_Predicate_Aspect. See description of the latter flag
 --       for further information on dynamic predicates which are also static.
@@ -1893,7 +1893,7 @@ package Einfo is
 --       from a Predicate aspect or pragma or even from a Dynamic_Predicate
 --       aspect. When we need to know the difference (e.g. to know what set of
 --       check policies apply, use this flag and Has_Dynamic_Predicate_Aspect
---       to determine which case we have.
+--       to determine which case we have).
 
 --    Has_Storage_Size_Clause (Flag23) [implementation base type only]
 --       Defined in task types and access types. It is set if a Storage_Size
index 4c8e94876f41ebb96dfe0a7e08d37d71f22696ff..51c49fd689a076bd7799340811c1391c5beed52d 100644 (file)
@@ -7471,27 +7471,44 @@ package body Exp_Ch6 is
       --  Here if secondary stack is used
 
       else
-         --  Make sure that no surrounding block will reclaim the secondary
-         --  stack on which we are going to put the result. Not only may this
-         --  introduce secondary stack leaks but worse, if the reclamation is
-         --  done too early, then the result we are returning may get
-         --  clobbered.
+         --  Prevent the reclamation of the secondary stack by all enclosing
+         --  blocks and loops as well as the related function, otherwise the
+         --  result will be reclaimed too early or even clobbered. Due to a
+         --  possible mix of internally generated blocks, source blocks and
+         --  loops, the scope stack may not be contiguous as all labels are
+         --  inserted at the top level within the related function. Instead,
+         --  perform a parent-based traversal and mark all appropriate
+         --  constructs.
 
          declare
-            S : Entity_Id;
+            P : Node_Id;
+
          begin
-            S := Current_Scope;
-            while Ekind (S) = E_Block or else Ekind (S) = E_Loop loop
-               Set_Sec_Stack_Needed_For_Return (S, True);
-               S := Enclosing_Dynamic_Scope (S);
-            end loop;
+            P := N;
+            while Present (P) loop
 
-            --  The enclosing function itself must be marked as well, to
-            --  prevent premature secondary stack cleanup.
+               --  Mark the label of a source or internally generated block or
+               --  loop.
 
-            if Ekind (S) = E_Function then
-               Set_Sec_Stack_Needed_For_Return (Scope_Id);
-            end if;
+               if Nkind_In (P, N_Block_Statement, N_Loop_Statement) then
+                  Set_Sec_Stack_Needed_For_Return (Entity (Identifier (P)));
+
+               --  Mark the enclosing function
+
+               elsif Nkind (P) = N_Subprogram_Body then
+                  if Present (Corresponding_Spec (P)) then
+                     Set_Sec_Stack_Needed_For_Return (Corresponding_Spec (P));
+                  else
+                     Set_Sec_Stack_Needed_For_Return (Defining_Entity (P));
+                  end if;
+
+                  --  Do not go beyond the enclosing function
+
+                  exit;
+               end if;
+
+               P := Parent (P);
+            end loop;
          end;
 
          --  Optimize the case where the result is a function call. In this
index a94a11b5994cb90a3df41f57bc716bf2fc33935a..d4b9604ae2ce68dba02a4c0e1ecc591ca971b446 100644 (file)
@@ -6668,17 +6668,18 @@ package body Exp_Util is
          --  When wrapping the statements of an iterator loop, check whether
          --  the loop requires secondary stack management and if so, propagate
          --  the appropriate flags to the block. This ensures that the cursor
-         --  is properly cleaned up at each iteration of the loop. Management
-         --  is not performed when the loop contains a return statement which
-         --  also uses the secondary stack as this will destroy the result
-         --  prematurely.
+         --  is properly cleaned up at each iteration of the loop.
 
          Iter_Loop := Find_Enclosing_Iterator_Loop (Scop);
 
          if Present (Iter_Loop) then
+            Set_Uses_Sec_Stack (Block_Id, Uses_Sec_Stack (Iter_Loop));
+
+            --  Secondary stack reclamation is suppressed when the associated
+            --  iterator loop contains a return statement which uses the stack.
+
             Set_Sec_Stack_Needed_For_Return
               (Block_Id, Sec_Stack_Needed_For_Return (Iter_Loop));
-            Set_Uses_Sec_Stack (Block_Id, Uses_Sec_Stack (Iter_Loop));
          end if;
 
          return Block_Nod;
index 854e26e0f93e5203411820678057c7bf20f68c77..8c39be02723a215ea5d565ab322e3dc1b424b4d6 100644 (file)
@@ -18196,6 +18196,29 @@ This encoding form parameter is only supported on the Windows
 platform. On the other Operating Systems the run-time is supporting
 UTF-8 natively.
 
+@node File content encoding
+@section File content encoding
+
+@noindent
+For text files it is possible to specify the encoding to use. This is
+controlled by the by the @samp{GNAT_CCS_ENCODING} environment
+variable. And if not set @samp{TEXT} is assumed.
+
+The possible values are those supported on Windows:
+
+@table @samp
+@item TEXT
+Translated text mode
+@item WTEXT
+Translated unicode encoding
+@item U16TEXT
+Unicode 16-bit encoding
+@item U8TEXT
+Unicode 8-bit encoding
+@end table
+
+This encoding is only supported on the Windows platform.
+
 @node Open Modes
 @section Open Modes
 
index 00c4d04e13bc4db4473431fc5d4a7c2cec262aa0..1aba5fdc82b672629c8f72d45dcebf160dd1f030 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2012, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2014, 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- *
@@ -52,6 +52,7 @@
 #endif
 
 #include "raise.h"
+#include <fcntl.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -151,6 +152,39 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
        }
    }
 
+   /* Set current encoding for the IO.  */
+   {
+     char *ccsencoding = getenv ("GNAT_CCS_ENCODING");
+
+     /* Default CCS Encoding.  */
+     CurrentCCSEncoding = _O_TEXT;
+     __gnat_wide_text_translation_required = 0;
+
+     if (ccsencoding != NULL)
+       {
+        if (strcmp (ccsencoding, "U16TEXT") == 0)
+           {
+             CurrentCCSEncoding = _O_U16TEXT;
+             __gnat_wide_text_translation_required = 1;
+           }
+        else if (strcmp (ccsencoding, "TEXT") == 0)
+           {
+             CurrentCCSEncoding = _O_TEXT;
+             __gnat_wide_text_translation_required = 0;
+           }
+        else if (strcmp (ccsencoding, "WTEXT") == 0)
+           {
+             CurrentCCSEncoding = _O_WTEXT;
+             __gnat_wide_text_translation_required = 1;
+           }
+        else if (strcmp (ccsencoding, "U8TEXT") == 0)
+           {
+             CurrentCCSEncoding = _O_U8TEXT;
+             __gnat_wide_text_translation_required = 1;
+           }
+       }
+   }
+
    /* Adjust gnat_argv to support Unicode characters. */
    {
      LPWSTR *wargv;
index 67bfd2cccfe16d5a54b864d7270f285df6cd0876..e466ee8d179963008ba77c03f5b3c259268dd360 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 2002-2011, Free Software Foundation, Inc.         *
+ *          Copyright (C) 2002-2014, 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- *
@@ -62,6 +62,8 @@
 #ifdef GNAT_UNICODE_SUPPORT
 
 extern UINT CurrentCodePage;
+extern UINT CurrentCCSEncoding;
+extern char __gnat_wide_text_translation_required;
 
 /*  Macros to convert to/from the code page specified in CurrentCodePage.  */
 #define S2WSC(wstr,str,len) \
index d76f8ce341734fa17d814819bf0ed78d3c400673..5a48f0e815c840e5de8d9cd713933ea82f36e681 100644 (file)
@@ -6349,6 +6349,9 @@ package body Sem_Attr is
 
                            else
                               Analyze_And_Resolve (Index, Etype (Index_Type));
+                              if not Is_OK_Static_Expression (Index) then
+                                 Set_Do_Range_Check (Index);
+                              end if;
                            end if;
 
                            Next (Index);
index de0fe2c1f84ba015841be0802a47ce57d12f7dd9..d8cfad9ceecc82ac58993d6fd355b39a21f6a0af 100644 (file)
@@ -7987,14 +7987,14 @@ package body Sem_Ch13 is
             EN : Node_Id;
 
          begin
-            --  Case where we have a predicate static aspect
+            --  Case where we have a predicate-static aspect
 
             if PS then
 
                --  We don't set Has_Static_Predicate_Aspect, since we can have
                --  any of the three cases (Predicate, Dynamic_Predicate, or
                --  Static_Predicate) generating a predicate with an expression
-               --  that is predicate static. We just indicate that we have a
+               --  that is predicate-static. We just indicate that we have a
                --  predicate that can be treated as static.
 
                Set_Has_Static_Predicate (Typ);
@@ -8030,7 +8030,7 @@ package body Sem_Ch13 is
                --  First a little fiddling to get a nice location for the
                --  message. If the expression is of the form (A and then B),
                --  then use the left operand for the Sloc. This avoids getting
-               --  confused by a call to a higher level predicate with a less
+               --  confused by a call to a higher-level predicate with a less
                --  convenient source location.
 
                EN := Expr;
@@ -10348,26 +10348,26 @@ package body Sem_Ch13 is
    is
       function All_Static_Case_Alternatives (L : List_Id) return Boolean;
       --  Given a list of case expression alternatives, returns True if
-      --  all the alternative are static (have all static choices, and a
+      --  all the alternatives are static (have all static choices, and a
       --  static expression).
 
       function All_Static_Choices (L : List_Id) return Boolean;
-      --  Returns true if all elements of the list are ok static choices
+      --  Returns true if all elements of the list are OK static choices
       --  as defined below for Is_Static_Choice. Used for case expression
       --  alternatives and for the right operand of a membership test.
 
       function Is_Static_Choice (N : Node_Id) return Boolean;
       --  Returns True if N represents a static choice (static subtype, or
-      --  static subtype indication, or static expression or static range).
+      --  static subtype indication, or static expression, or static range).
       --
       --  Note that this is a bit more inclusive than we actually need
       --  (in particular membership tests do not allow the use of subtype
-      --  indications. But that doesn't matter, we have already checked
+      --  indications). But that doesn't matter, we have already checked
       --  that the construct is legal to get this far.
 
       function Is_Type_Ref (N : Node_Id) return Boolean;
       pragma Inline (Is_Type_Ref);
-      --  Returns if True if N is a reference to the type for the predicate in
+      --  Returns True if N is a reference to the type for the predicate in
       --  the expression (i.e. if it is an identifier whose Chars field matches
       --  the Nam given in the call). N must not be parenthesized, if the type
       --  name appears in parens, this routine will return False.
@@ -10442,7 +10442,7 @@ package body Sem_Ch13 is
    --  Start of processing for Is_Predicate_Static
 
    begin
-      --  Only scalar types can be predicate static
+      --  Only scalar types can be predicate-static
 
       if not Is_Scalar_Type (Etype (Expr)) then
          return False;
@@ -10519,7 +10519,7 @@ package body Sem_Ch13 is
       --  One more test that is an implementation artifact caused by the fact
       --  that we are analyzing not the original expresesion, but the generated
       --  expression in the body of the predicate function. This can include
-      --  refereces to inherited predicates, so that the expression we are
+      --  references to inherited predicates, so that the expression we are
       --  processing looks like:
 
       --    expression and then xxPredicate (typ (Inns))
@@ -10535,7 +10535,7 @@ package body Sem_Ch13 is
          return True;
 
       --  That's an exhaustive list of tests, all other cases are not
-      --  predicate static, so we return False.
+      --  predicate-static, so we return False.
 
       else
          return False;
index 40034e788bf13489f991cb7e94c3d51de361d098..d90a7e534cb2077ec6cbb9aa1b34a9c5dc06ad95 100644 (file)
@@ -2885,12 +2885,6 @@ package body Sem_Ch5 is
 
             Add_Block_Identifier (Block_Nod, Block_Id);
 
-            --  Fix the loop scope once the loop statement is relocated inside
-            --  the block, otherwise the loop and the block end up sharing the
-            --  same parent scope.
-
-            Set_Scope (Ent, Block_Id);
-
             --  The expansion of iterator loops generates an iterator in order
             --  to traverse the elements of a container:
 
index 461bbdbd2348189d75d2ad34ad449c59dcfca346..7ade48345b5bcc6f3c33fed7017f7d6ff14acfd5 100644 (file)
@@ -367,8 +367,8 @@ package Sem_Eval is
    function Eval_Static_Predicate_Check
      (N   : Node_Id;
       Typ : Entity_Id) return Boolean;
-   --  Evaluate a static predicate check applied to a known at compile time
-   --  value N, which can be of a discrete, real or string type. The caller
+   --  Evaluate a static predicate check applied to a known-at-compile-time
+   --  value N, which can be of a discrete, real, or string type. The caller
    --  has checked that a static predicate does apply to Typ.
 
    procedure Fold_Str (N : Node_Id; Val : String_Id; Static : Boolean);
index 73a4f87484933a0d44699d9480c9dbc7e8595c74..a1f6f9fc80c3444accd3aa94e746a197549cd4ae 100644 (file)
@@ -21829,8 +21829,9 @@ package body Sem_Prag is
       Depends      : Node_Id;
       --  The corresponding Depends pragma along with its clauses
 
-      Refined_States : Elist_Id := No_Elist;
-      --  A list containing all successfully refined states
+      Matched_Items : Elist_Id := No_Elist;
+      --  A list containing the entities of all successfully matched items
+      --  found in pragma Depends.
 
       Refinements : List_Id := No_List;
       --  The clauses of pragma Refined_Depends
@@ -21863,6 +21864,10 @@ package body Sem_Prag is
          --  Determine whether dependence clause Dep_Clause denotes an abstract
          --  state that depends on itself (State => State).
 
+         function Is_Null_Refined_State (Item : Node_Id) return Boolean;
+         --  Determine whether item Item denotes an abstract state with visible
+         --  null refinement.
+
          procedure Match_Items
            (Dep_Item : Node_Id;
             Ref_Item : Node_Id;
@@ -21887,6 +21892,9 @@ package body Sem_Prag is
          --  When scenario 8 is in effect, the entity of the abstract state
          --  denoted by Dep_Item is added to list Refined_States.
 
+         procedure Record_Item (Item_Id : Entity_Id);
+         --  Store the entity of an item denoted by Item_Id in Matched_Items
+
          ----------------------------
          -- Is_In_Out_State_Clause --
          ----------------------------
@@ -21915,6 +21923,28 @@ package body Sem_Prag is
             end if;
          end Is_In_Out_State_Clause;
 
+         ---------------------------
+         -- Is_Null_Refined_State --
+         ---------------------------
+
+         function Is_Null_Refined_State (Item : Node_Id) return Boolean is
+            Item_Id : Entity_Id;
+
+         begin
+            if Is_Entity_Name (Item) then
+
+               --  Handle abstract views generated for limited with clauses
+
+               Item_Id := Available_View (Entity_Of (Item));
+
+               return
+                 Ekind (Item_Id) = E_Abstract_State
+                   and then Has_Null_Refinement (Item_Id);
+            else
+               return False;
+            end if;
+         end Is_Null_Refined_State;
+
          -----------------
          -- Match_Items --
          -----------------
@@ -21962,6 +21992,7 @@ package body Sem_Prag is
                   if Has_Null_Refinement (Dep_Item_Id)
                     and then (No (Ref_Item) or else Nkind (Ref_Item) = N_Null)
                   then
+                     Record_Item (Dep_Item_Id);
                      Matched := True;
 
                   --  An abstract state with visible non-null refinement
@@ -21976,12 +22007,7 @@ package body Sem_Prag is
                           and then Encapsulating_State (Ref_Item_Id) =
                                      Dep_Item_Id
                         then
-                           --  Record the successfully refined state
-
-                           if not Contains (Refined_States, Dep_Item_Id) then
-                              Add_Item (Dep_Item_Id, Refined_States);
-                           end if;
-
+                           Record_Item (Dep_Item_Id);
                            Matched := True;
                         end if;
                      end if;
@@ -21992,6 +22018,7 @@ package body Sem_Prag is
                   elsif Is_Entity_Name (Ref_Item)
                     and then Entity_Of (Ref_Item) = Dep_Item_Id
                   then
+                     Record_Item (Dep_Item_Id);
                      Matched := True;
                   end if;
 
@@ -22000,11 +22027,23 @@ package body Sem_Prag is
                elsif Is_Entity_Name (Ref_Item)
                  and then Entity_Of (Ref_Item) = Dep_Item_Id
                then
+                  Record_Item (Dep_Item_Id);
                   Matched := True;
                end if;
             end if;
          end Match_Items;
 
+         -----------------
+         -- Record_Item --
+         -----------------
+
+         procedure Record_Item (Item_Id : Entity_Id) is
+         begin
+            if not Contains (Matched_Items, Item_Id) then
+               Add_Item (Item_Id, Matched_Items);
+            end if;
+         end Record_Item;
+
          --  Local variables
 
          Clause_Matched  : Boolean := False;
@@ -22108,7 +22147,41 @@ package body Sem_Prag is
          if not Clause_Matched
            and then Is_In_Out_State_Clause
            and then Contains
-                      (Refined_States, Available_View (Entity_Of (Dep_Input)))
+                      (Matched_Items, Available_View (Entity_Of (Dep_Input)))
+         then
+            Clause_Matched := True;
+         end if;
+
+         --  A clause where the input is an abstract state with visible null
+         --  refinement is implicitly matched when the output has already been
+         --  matched in a previous clause.
+
+         --    Depends         => (Output => State)  --  implicitly OK
+         --    Refined_State   => (State => null)
+         --    Refined_Depends => (Output => ...)
+
+         if not Clause_Matched
+           and then Is_Null_Refined_State (Dep_Input)
+           and then Is_Entity_Name (Dep_Output)
+           and then Contains
+                      (Matched_Items, Available_View (Entity_Of (Dep_Output)))
+         then
+            Clause_Matched := True;
+         end if;
+
+         --  A clause where the output is an abstract state with visible null
+         --  refinement is implicitly matched when the input has already been
+         --  matched in a previous clause.
+
+         --    Depends           => (State => Input)  --  implicitly OK
+         --    Refined_State     => (State => null)
+         --    Refined_Depends   => (... => Input)
+
+         if not Clause_Matched
+           and then Is_Null_Refined_State (Dep_Output)
+           and then Is_Entity_Name (Dep_Input)
+           and then Contains
+                      (Matched_Items, Available_View (Entity_Of (Dep_Input)))
          then
             Clause_Matched := True;
          end if;
index ded1d401a907aada83ab2fc2670b328390778d53..34f68fe63c9f012f5d67baadac57cca3f3bfe51e 100644 (file)
@@ -1718,6 +1718,17 @@ package body Sem_Util is
          else
             Error_Msg_NE
               ("??static expression fails predicate check on &", Expr, Typ);
+
+            --  We now reset the static expression indication on the expression
+            --  since it is no longer static if it fails a predicate test. We
+            --  do not do this if the predicate was officially dynamic, since
+            --  dynamic predicates don't affect legality in this manner.
+
+            if not Has_Dynamic_Predicate_Aspect (Typ) then
+               Error_Msg_N
+                 ("\??expression is no longer considered static", Expr);
+               Set_Is_Static_Expression (Expr, False);
+            end if;
          end if;
       end if;
    end Check_Expression_Against_Static_Predicate;
index 9e129460a5481bf40a8e5e0c7d3dd40a7ad7204a..590a2ea5b984bf1d426a0f415aad2ec675e743c1 100644 (file)
@@ -131,6 +131,7 @@ extern struct tm *localtime_r(const time_t *, struct tm *);
 #if defined (WINNT) || defined (__CYGWIN__)
 
 const char __gnat_text_translation_required = 1;
+char __gnat_wide_text_translation_required = 0;
 
 #ifdef __CYGWIN__
 #define WIN_SETMODE setmode
@@ -154,7 +155,7 @@ __gnat_set_text_mode (int handle)
 void
 __gnat_set_wide_text_mode (int handle)
 {
-  WIN_SETMODE (handle, _O_U16TEXT);
+  WIN_SETMODE (handle, CurrentCCSEncoding);
 }
 
 #ifdef __CYGWIN__
@@ -240,6 +241,7 @@ __gnat_ttyname (int filedes)
 #else
 
 const char __gnat_text_translation_required = 0;
+const char __gnat_wide_text_translation_required = 0;
 
 /* These functions do nothing in non-DOS systems. */