sem_ch4.adb (Analyze_Quantified_Expression): Add comment.
authorRobert Dewar <dewar@adacore.com>
Thu, 15 Mar 2012 09:10:42 +0000 (09:10 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 15 Mar 2012 09:10:42 +0000 (10:10 +0100)
2012-03-15  Robert Dewar  <dewar@adacore.com>

* sem_ch4.adb (Analyze_Quantified_Expression): Add comment.
* sem_prag.adb: Minor comment additions.
* sem_attr.adb (Check_First_Last_Valid): Make sure prefix type
is frozen.

From-SVN: r185420

gcc/ada/ChangeLog
gcc/ada/sem_attr.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_prag.adb

index 45a53bbd88a4272fc791c9d8c73992c989f7f6aa..864c3dd3c92e39d83ac5f131a6cf5fa5c9a4fee3 100644 (file)
@@ -1,3 +1,10 @@
+2012-03-15  Robert Dewar  <dewar@adacore.com>
+
+       * sem_ch4.adb (Analyze_Quantified_Expression): Add comment.
+       * sem_prag.adb: Minor comment additions.
+       * sem_attr.adb (Check_First_Last_Valid): Make sure prefix type
+       is frozen.
+
 2012-03-15  Vincent Pucci  <pucci@adacore.com>
 
        * sem_ch4.adb (Analyze_Quantified_Expression):
index 50c7d1242ec05c57d3a24de81a9f73146edd8737..f007a9dafe6968a9fef05802b2c1eb32a97c99e9 100644 (file)
@@ -1273,9 +1273,12 @@ package body Sem_Attr is
          Check_Ada_2012_Attribute;
          Check_Discrete_Type;
 
-         if not Is_Static_Subtype (P_Type) then
-            Error_Attr_P ("prefix of % attribute must be a static subtype");
-         end if;
+         --  Freeze the subtype now, so that the following test for predicates
+         --  works (we set the predicates stuff up at freeze time)
+
+         Insert_Actions (N, Freeze_Entity (P_Type, P));
+
+         --  Now test for dynamic predicate
 
          if Has_Predicates (P_Type)
            and then No (Static_Predicate (P_Type))
@@ -1284,6 +1287,14 @@ package body Sem_Attr is
               ("prefix of % attribute may not have dynamic predicate");
          end if;
 
+         --  Check non-static subtype
+
+         if not Is_Static_Subtype (P_Type) then
+            Error_Attr_P ("prefix of % attribute must be a static subtype");
+         end if;
+
+         --  Test case for no values
+
          if Expr_Value (Type_Low_Bound (P_Type)) >
             Expr_Value (Type_High_Bound (P_Type))
            or else (Has_Predicates (P_Type)
index 55674855ab3ad9ad1fb7a2849e1a2e27fc105e6a..5ab5d3fe475eb0a2a454eb0e112fc1749d7fbb11 100644 (file)
@@ -3449,6 +3449,12 @@ package body Sem_Ch4 is
          --  quantified expression, only a preanalysis of the condition needs
          --  to be done.
 
+         --  This is weird and irregular code for several reasons. First, doing
+         --  an Analyze with no Resolve is very suspicious, how can this be
+         --  right for the overloaded case ??? Second, doing two calls to
+         --  analyze on the same node is peculiar ??? Why can't we use the
+         --  normal Preanalyze calls here ???
+
          Expander_Mode_Save_And_Set (False);
          Analyze (Condition (N));
          Expander_Mode_Restore;
index 38a2c8c4a05603026d353bf7357b69963f18141c..d55325a272fc74bf72ba17e8103d8c763cd8b34b 100644 (file)
@@ -696,7 +696,8 @@ package body Sem_Prag is
       pragma No_Return (Error_Pragma);
       --  Outputs error message for current pragma. The message contains a %
       --  that will be replaced with the pragma name, and the flag is placed
-      --  on the pragma itself. Pragma_Exit is then raised.
+      --  on the pragma itself. Pragma_Exit is then raised. Note: this routine
+      --  calls Fix_Error (see spec of that function for details).
 
       procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
       pragma No_Return (Error_Pragma_Arg);
@@ -707,7 +708,8 @@ package body Sem_Prag is
       --  in which case the flag is placed directly on the expression. The
       --  message is placed using Error_Msg_N, so the message may also contain
       --  an & insertion character which will reference the given Arg value.
-      --  After placing the message, Pragma_Exit is raised.
+      --  After placing the message, Pragma_Exit is raised. Note: this routine
+      --  calls Fix_Error (see spec of that function for details).
 
       procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
       pragma No_Return (Error_Pragma_Arg);
@@ -723,14 +725,16 @@ package body Sem_Prag is
       --  on the identifier. The message is placed using Error_Msg_N so
       --  the message may also contain an & insertion character which will
       --  reference the identifier. After placing the message, Pragma_Exit
-      --  is raised.
+      --  is raised. Note: this routine calls Fix_Error (see spec of that
+      --  function for details).
 
       procedure Error_Pragma_Ref (Msg : String; Ref : Entity_Id);
       pragma No_Return (Error_Pragma_Ref);
       --  Outputs error message for current pragma. The message may contain
       --  a % that will be replaced with the pragma name. The parameter Ref
       --  must be an entity whose name can be referenced by & and sloc by #.
-      --  After placing the message, Pragma_Exit is raised.
+      --  After placing the message, Pragma_Exit is raised. Note: this routine
+      --  calls Fix_Error (see spec of that function for details).
 
       function Find_Lib_Unit_Name return Entity_Id;
       --  Used for a library unit pragma to find the entity to which the