]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
exp_ch11.ads, [...] (Expand_N_Raise_Expression): New procedure.
authorRobert Dewar <dewar@adacore.com>
Thu, 11 Apr 2013 10:39:15 +0000 (10:39 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 11 Apr 2013 10:39:15 +0000 (12:39 +0200)
2013-04-11  Robert Dewar  <dewar@adacore.com>

* exp_ch11.ads, exp_ch11.adb (Expand_N_Raise_Expression): New procedure.
* exp_util.adb (Insert_Actions): Add entry for N_Raise_Expression.
* expander.adb: Add call to Expand_N_Raise_Expression.
* par-ch11.adb (P_Raise_Expression): New procedure.
* par-ch4.adb (P_Relation): Handle Raise_Expression.
* par.adb (P_Raise_Expression): New procedure.
* sem.adb: Add handling for N_Raise_Expression.
* sem_ch11.ads, sem_ch11.adb (Analyze_Raise_Expression): New procedure.
* sem_res.adb (Resolve): Add handling for N_Raise_Expression.
* sinfo.ads, sinfo.adb (N_Raise_Expression): New node.
* sprint.adb (Sprint_Node_Actual): Add handling for N_Raise_Expression.
* stand.ads (Any_Type): Document use with N_Raise_Expression.

From-SVN: r197764

16 files changed:
gcc/ada/ChangeLog
gcc/ada/exp_ch11.adb
gcc/ada/exp_ch11.ads
gcc/ada/exp_util.adb
gcc/ada/expander.adb
gcc/ada/par-ch11.adb
gcc/ada/par-ch4.adb
gcc/ada/par.adb
gcc/ada/sem.adb
gcc/ada/sem_ch11.adb
gcc/ada/sem_ch11.ads
gcc/ada/sem_res.adb
gcc/ada/sinfo.adb
gcc/ada/sinfo.ads
gcc/ada/sprint.adb
gcc/ada/stand.ads

index 0f415826ae966de4f1624632fbede3ce9b8fa9fe..238de70703115a26d11d63f4720f27a2caad6e99 100644 (file)
@@ -1,3 +1,18 @@
+2013-04-11  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch11.ads, exp_ch11.adb (Expand_N_Raise_Expression): New procedure.
+       * exp_util.adb (Insert_Actions): Add entry for N_Raise_Expression.
+       * expander.adb: Add call to Expand_N_Raise_Expression.
+       * par-ch11.adb (P_Raise_Expression): New procedure.
+       * par-ch4.adb (P_Relation): Handle Raise_Expression.
+       * par.adb (P_Raise_Expression): New procedure.
+       * sem.adb: Add handling for N_Raise_Expression.
+       * sem_ch11.ads, sem_ch11.adb (Analyze_Raise_Expression): New procedure.
+       * sem_res.adb (Resolve): Add handling for N_Raise_Expression.
+       * sinfo.ads, sinfo.adb (N_Raise_Expression): New node.
+       * sprint.adb (Sprint_Node_Actual): Add handling for N_Raise_Expression.
+       * stand.ads (Any_Type): Document use with N_Raise_Expression.
+
 2013-04-11  Vincent Celier  <celier@adacore.com>
 
        * gnat_ugn.texi: Remove section "The Development Environments"
index 64a53e36cda6493d21fb02595dc6957ea980f978..1843ee0c932430a53df5cf764b786a59565659f1 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -1431,6 +1431,44 @@ package body Exp_Ch11 is
       Possible_Local_Raise (N, Standard_Constraint_Error);
    end Expand_N_Raise_Constraint_Error;
 
+   -------------------------------
+   -- Expand_N_Raise_Expression --
+   -------------------------------
+
+   procedure Expand_N_Raise_Expression (N : Node_Id) is
+      Loc : constant Source_Ptr := Sloc (N);
+      Typ : constant Entity_Id  := Etype (N);
+      RCE : Node_Id;
+
+   begin
+      Possible_Local_Raise (N, Name (N));
+
+      --  Later we must teach the back end/gigi how to deal with this, but
+      --  for now we will assume the type is Standard_Boolean and transform
+      --  the node to:
+
+      --     do
+      --       raise X [with string]
+      --     in
+      --       raise Consraint_Error;
+
+      --  The raise constraint error can never be executed. It is just a dummy
+      --  node that can be labeled with an arbitrary type.
+
+      RCE := Make_Raise_Constraint_Error (Loc, Reason => CE_Explicit_Raise);
+      Set_Etype (RCE, Typ);
+
+      Rewrite (N,
+        Make_Expression_With_Actions (Loc,
+          Actions     => New_List (
+            Make_Raise_Statement (Loc,
+              Name       => Name (N),
+              Expression => Expression (N))),
+           Expression => RCE));
+
+      Analyze_And_Resolve (N, Typ);
+   end Expand_N_Raise_Expression;
+
    ----------------------------------
    -- Expand_N_Raise_Program_Error --
    ----------------------------------
index d715a27c4e7ea6db1877e8e245946828b50d1fe5..96887e2b58020b295d7c2aea708507f91d355e14 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -31,6 +31,7 @@ package Exp_Ch11 is
    procedure Expand_N_Exception_Declaration          (N : Node_Id);
    procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id);
    procedure Expand_N_Raise_Constraint_Error         (N : Node_Id);
+   procedure Expand_N_Raise_Expression               (N : Node_Id);
    procedure Expand_N_Raise_Program_Error            (N : Node_Id);
    procedure Expand_N_Raise_Statement                (N : Node_Id);
    procedure Expand_N_Raise_Storage_Error            (N : Node_Id);
index 1900a9fd7ea7e7511dd0acb0535d7b407dc443d2..f6e52342296f1fa3593e52a5c3d0b639ca6af3e1 100644 (file)
@@ -3674,6 +3674,7 @@ package body Exp_Util is
                N_Push_Storage_Error_Label               |
                N_Qualified_Expression                   |
                N_Quantified_Expression                  |
+               N_Raise_Expression                       |
                N_Range                                  |
                N_Range_Constraint                       |
                N_Real_Literal                           |
index 83a692067cf2ce9bd1702865d41c5e2468984959..cb20234db173134e9f3efdc08e15f2b457466e48 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -388,6 +388,9 @@ package body Expander is
                   when N_Raise_Constraint_Error =>
                      Expand_N_Raise_Constraint_Error (N);
 
+                  when N_Raise_Expression =>
+                     Expand_N_Raise_Expression (N);
+
                   when N_Raise_Program_Error =>
                      Expand_N_Raise_Program_Error (N);
 
index c255325699f1e7c506bf360d23c7efd04f4d3e0d..f0537f27cd109597ae59802c4e74e8786b7e9b7e 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -199,11 +199,43 @@ package body Ch11 is
          return Error;
    end P_Exception_Choice;
 
+   ----------------------------
+   -- 11.3  Raise Expression --
+   ----------------------------
+
+   --  RAISE_EXPRESSION ::= raise [exception_NAME [with string_EXPRESSION]]
+
+   --  The caller has verified that the initial token is RAISE
+
+   --  Error recovery: can raise Error_Resync
+
+   function P_Raise_Expression return Node_Id is
+      Raise_Node : Node_Id;
+
+   begin
+      if Ada_Version < Ada_2012 then
+         Error_Msg_SC ("raise expression is an Ada 2012 feature");
+         Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
+      end if;
+
+      Raise_Node := New_Node (N_Raise_Expression, Token_Ptr);
+      Scan; -- past RAISE
+
+      Set_Name (Raise_Node, P_Name);
+
+      if Token = Tok_With then
+         Scan; -- past WITH
+         Set_Expression (Raise_Node, P_Expression);
+      end if;
+
+      return Raise_Node;
+   end P_Raise_Expression;
+
    ---------------------------
    -- 11.3  Raise Statement --
    ---------------------------
 
-   --  RAISE_STATEMENT ::= raise [exception_NAME];
+   --  RAISE_STATEMENT ::= raise [exception_NAME with string_EXPRESSION];
 
    --  The caller has verified that the initial token is RAISE
 
index 185a07d97c2c5541f49513ccee8fb0c1a500d8d6..8066b8c37f02f28f42821a08dea82d43ccca974d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -1818,6 +1818,7 @@ package body Ch4 is
 
    --  RELATION ::=
    --    SIMPLE_EXPRESSION [not] in MEMBERSHIP_CHOICE_LIST
+   --  | RAISE_EXPRESSION
 
    --  MEMBERSHIP_CHOICE_LIST ::=
    --    MEMBERSHIP_CHOICE {'|' MEMBERSHIP CHOICE}
@@ -1825,6 +1826,8 @@ package body Ch4 is
    --  MEMBERSHIP_CHOICE ::=
    --    CHOICE_EXPRESSION | RANGE | SUBTYPE_MARK
 
+   --  RAISE_EXPRESSION ::= raise exception_NAME [with string_EXPRESSION]
+
    --  On return, Expr_Form indicates the categorization of the expression
 
    --  Note: if Token = Tok_Apostrophe on return, then Expr_Form is set to
@@ -1839,6 +1842,15 @@ package body Ch4 is
       Optok        : Source_Ptr;
 
    begin
+      --  First check for raise expression
+
+      if Token = Tok_Raise then
+         Expr_Form := EF_Non_Simple;
+         return P_Raise_Expression;
+      end if;
+
+      --  All other cases
+
       Node1 := P_Simple_Expression;
 
       if Token not in Token_Class_Relop then
index 571713f3d513ea2bf8523287a60d88ae15dd1a0b..ac21375ef46d74fba5d0b064f68c4097068dc5bf 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -838,6 +838,7 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
 
    package Ch11 is
       function P_Handled_Sequence_Of_Statements       return Node_Id;
+      function P_Raise_Expression                     return Node_Id;
       function P_Raise_Statement                      return Node_Id;
 
       function Parse_Exception_Handlers               return List_Id;
index 95b694287049b65fb5f332481796d02aeaa55375..a81597a5af63d88f278dc19e4694ea2a7693e754 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -470,6 +470,9 @@ package body Sem is
          when N_Quantified_Expression =>
             Analyze_Quantified_Expression (N);
 
+         when N_Raise_Expression =>
+            Analyze_Raise_Expression (N);
+
          when N_Raise_Statement =>
             Analyze_Raise_Statement (N);
 
index e3635c66e171652318b77b20fba11da31627301d..180ecc6ca0b23a07d44ced0ec257a3df811d4b3f 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -424,6 +424,60 @@ package body Sem_Ch11 is
       end if;
    end Analyze_Handled_Statements;
 
+   ------------------------------
+   -- Analyze_Raise_Expression --
+   ------------------------------
+
+   procedure Analyze_Raise_Expression (N : Node_Id) is
+      Exception_Id   : constant Node_Id := Name (N);
+      Exception_Name : Entity_Id        := Empty;
+
+   begin
+      Check_SPARK_Restriction ("raise expression is not allowed", N);
+
+      --  Check exception restrictions on the original source
+
+      if Comes_From_Source (N) then
+         Check_Restriction (No_Exceptions, N);
+      end if;
+
+      Analyze (Exception_Id);
+
+      if Is_Entity_Name (Exception_Id) then
+         Exception_Name := Entity (Exception_Id);
+      end if;
+
+      if No (Exception_Name)
+        or else Ekind (Exception_Name) /= E_Exception
+      then
+         Error_Msg_N
+           ("exception name expected in raise statement", Exception_Id);
+      else
+         Set_Is_Raised (Exception_Name);
+      end if;
+
+      --  Deal with RAISE WITH case
+
+      if Present (Expression (N)) then
+         Check_Compiler_Unit (Expression (N));
+         Analyze_And_Resolve (Expression (N), Standard_String);
+      end if;
+
+      --  Check obsolescent use of Numeric_Error
+
+      if Exception_Name = Standard_Numeric_Error then
+         Check_Restriction (No_Obsolescent_Features, Exception_Id);
+      end if;
+
+      --  Kill last assignment indication
+
+      Kill_Current_Values (Last_Assignment_Only => True);
+
+      --  Set type as Any_Type since we have no information at all on the type
+
+      Set_Etype (N, Any_Type);
+   end Analyze_Raise_Expression;
+
    -----------------------------
    -- Analyze_Raise_Statement --
    -----------------------------
index 63544bd0e31a7bd01960dae5968d5804838cd925..656f12d8cc342cb5f56ea5e39bab517fde6be493 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -27,6 +27,7 @@ with Types; use Types;
 package Sem_Ch11 is
    procedure Analyze_Exception_Declaration              (N : Node_Id);
    procedure Analyze_Handled_Statements                 (N : Node_Id);
+   procedure Analyze_Raise_Expression                   (N : Node_Id);
    procedure Analyze_Raise_Statement                    (N : Node_Id);
    procedure Analyze_Raise_xxx_Error                    (N : Node_Id);
    procedure Analyze_Subprogram_Info                    (N : Node_Id);
index 4fcbee93a2ca0b357f5a2bd19f96f9fa99ef190e..49515c8d7722685a083fdeb1058d25a2b46f97cf 100644 (file)
@@ -2060,9 +2060,11 @@ package body Sem_Res is
          Analyze_Dimension (N);
          return;
 
-      --  Return if type = Any_Type (previous error encountered)
+      --  Return if type = Any_Type (previous error encountered). except that
+      --  a Raise_Expression node is OK: it is legitimately labeled this way
+      --  since it provides no information on the context.
 
-      elsif Etype (N) = Any_Type then
+      elsif Etype (N) = Any_Type and then Nkind (N) /= N_Raise_Expression then
          Debug_A_Exit ("resolving  ", N, "  (done, Etype = Any_Type)");
          return;
       end if;
@@ -2804,8 +2806,13 @@ package body Sem_Res is
             when N_Qualified_Expression
                              => Resolve_Qualified_Expression     (N, Ctx_Type);
 
+            --  Why is the following null, needs a comment ???
+
             when N_Quantified_Expression => null;
 
+            when N_Raise_Expression
+                             => Set_Etype (N, Ctx_Type);
+
             when N_Raise_xxx_Error
                              => Set_Etype (N, Ctx_Type);
 
index 3d5a64434f241146bfeba6257791de57e85f2cb8..19896ea1c6f8d60b2874d9b68ac3f01d39853dc4 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -1233,6 +1233,7 @@ package body Sinfo is
         or else NT (N).Nkind = N_Parameter_Specification
         or else NT (N).Nkind = N_Pragma_Argument_Association
         or else NT (N).Nkind = N_Qualified_Expression
+        or else NT (N).Nkind = N_Raise_Expression
         or else NT (N).Nkind = N_Raise_Statement
         or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion
@@ -2130,6 +2131,7 @@ package body Sinfo is
         or else NT (N).Nkind = N_Package_Renaming_Declaration
         or else NT (N).Nkind = N_Procedure_Call_Statement
         or else NT (N).Nkind = N_Procedure_Instantiation
+        or else NT (N).Nkind = N_Raise_Expression
         or else NT (N).Nkind = N_Raise_Statement
         or else NT (N).Nkind = N_Requeue_Statement
         or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
@@ -4305,6 +4307,7 @@ package body Sinfo is
         or else NT (N).Nkind = N_Parameter_Specification
         or else NT (N).Nkind = N_Pragma_Argument_Association
         or else NT (N).Nkind = N_Qualified_Expression
+        or else NT (N).Nkind = N_Raise_Expression
         or else NT (N).Nkind = N_Raise_Statement
         or else NT (N).Nkind = N_Simple_Return_Statement
         or else NT (N).Nkind = N_Type_Conversion
@@ -5202,6 +5205,7 @@ package body Sinfo is
         or else NT (N).Nkind = N_Package_Renaming_Declaration
         or else NT (N).Nkind = N_Procedure_Call_Statement
         or else NT (N).Nkind = N_Procedure_Instantiation
+        or else NT (N).Nkind = N_Raise_Expression
         or else NT (N).Nkind = N_Raise_Statement
         or else NT (N).Nkind = N_Requeue_Statement
         or else NT (N).Nkind = N_Subprogram_Renaming_Declaration
index 20fb08c407187d98d48c782ce5005c27144b47e8..89f11f74579b88656109046638bc8218f87a606a 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -3545,6 +3545,7 @@ package Sinfo is
 
       --  RELATION ::=
       --    SIMPLE_EXPRESSION [not] in MEMBERSHIP_CHOICE_LIST
+      --  | RAISE_EXPRESSION
 
       --  MEMBERSHIP_CHOICE_LIST ::=
       --    MEMBERSHIP_CHOICE {'|' MEMBERSHIP CHOICE}
@@ -6119,7 +6120,8 @@ package Sinfo is
 
       --  In Ada 2005, we have
 
-      --  RAISE_STATEMENT ::= raise; | raise exception_NAME [with EXPRESSION];
+      --  RAISE_STATEMENT ::=
+      --    raise; | raise exception_NAME [with string_EXPRESSION];
 
       --  N_Raise_Statement
       --  Sloc points to RAISE
@@ -6127,6 +6129,18 @@ package Sinfo is
       --  Expression (Node3) (set to Empty if no expression present)
       --  From_At_End (Flag4-Sem)
 
+      ----------------------------
+      -- 11.3  Raise Expression --
+      ----------------------------
+
+      --  RAISE_EXPRESSION ::= raise exception_NAME [with string_EXPRESSION]
+
+      --  N_Raise_Expression
+      --  Sloc points to RAISE
+      --  Name (Node2) (always present)
+      --  Expression (Node3) (set to Empty if no expression present)
+      --  plus fields for expression
+
       -------------------------------
       -- 12.1  Generic Declaration --
       -------------------------------
@@ -7664,6 +7678,7 @@ package Sinfo is
       N_Allocator,
       N_Case_Expression,
       N_Extension_Aggregate,
+      N_Raise_Expression,
       N_Range,
       N_Real_Literal,
       N_Reference,
@@ -11348,6 +11363,13 @@ package Sinfo is
         4 => False,   --  unused
         5 => False),  --  unused
 
+     N_Raise_Expression =>
+       (1 => False,   --  unused
+        2 => True,    --  Name (Node2)
+        3 => True,    --  Expression (Node3)
+        4 => False,   --  unused
+        5 => False),  --  Etype (Node5-Sem)
+
      N_Generic_Subprogram_Declaration =>
        (1 => True,    --  Specification (Node1)
         2 => True,    --  Generic_Formal_Declarations (List2)
index 27173504aed0e08fcef3c0fe8684673f4729be1e..5185c1527aaf220acb4711045de7c1c0ad928c2e 100644 (file)
@@ -1993,6 +1993,7 @@ package body Sprint is
                if not Has_Parens then
                   Write_Char ('(');
                end if;
+
                Write_Str_With_Col_Check_Sloc ("if ");
                Sprint_Node (Condition);
                Write_Str_With_Col_Check (" then ");
@@ -2763,6 +2764,32 @@ package body Sprint is
             Write_Str (" => ");
             Sprint_Node (Condition (Node));
 
+         when N_Raise_Expression =>
+            declare
+               Has_Parens : constant Boolean := Paren_Count (Node) > 0;
+
+            begin
+               --  The syntax for raise_expression does not include parentheses
+               --  but sometimes parentheses are required, so unconditionally
+               --  generate them here unless already present.
+
+               if not Has_Parens then
+                  Write_Char ('(');
+               end if;
+
+               Write_Str_With_Col_Check_Sloc ("raise ");
+               Sprint_Node (Name (Node));
+
+               if Present (Expression (Node)) then
+                  Write_Str_With_Col_Check (" with ");
+                  Sprint_Node (Expression (Node));
+               end if;
+
+               if not Has_Parens then
+                  Write_Char (')');
+               end if;
+            end;
+
          when N_Raise_Constraint_Error =>
 
             --  This node can be used either as a subexpression or as a
index 16f388d5fe6d9c7e4d178386afcebf6bc9b8f50c..0eeeed6cbb9a44e2115c82a79cdc06255b8f39a0 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, 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- --
@@ -362,10 +362,25 @@ package Stand is
    --  identifier references to prevent cascaded errors.
 
    Any_Type : Entity_Id;
-   --  Used to represent some unknown type. Plays an important role in
-   --  avoiding cascaded errors, since any node that remains labeled with
-   --  this type corresponds to an already issued error message. Any_Type
-   --  is propagated to avoid cascaded errors from a single type error.
+   --  Used to represent some unknown type. Any_Type is the type of an
+   --  unresolved operator, and it is the type of a node where a type error
+   --  has been detected.  Any_Type plays an important role in avoiding
+   --  cascaded errors, because it is compatible with all other types, and is
+   --  propagated to any expression that has a subexpression of Any_Type.
+   --  When resolving operators, Any_Type is the initial type of the node
+   --  before any of its candidate interpretations has been examined. If after
+   --  examining all of them the type is still Any_Type, the node has no
+   --  possible interpretation and an error can be emitted (and Any_Type will
+   --  be propagated upwards).
+
+   --  There is one situation in which Any_Type is used to legitimately
+   --  represent a case where the type is not known pre-resolution, and
+   --  that is for the N_Raise_Expression node. In this case, the Etype
+   --  being set to Any_Type is normal and does not represent an error.
+   --  In particular, it is compatible with the type of any constituend of
+   --  the enclosing expression, if any.  The type is eventually replaced
+   --  with the type of the context, which plays no role in the resolution
+   --  of the Raise_Expression.
 
    Any_Access : Entity_Id;
    --  Used to resolve the overloaded literal NULL