2008-08-20 Gary Dismukes <dismukes@adacore.com>
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 20 Aug 2008 13:24:40 +0000 (15:24 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 20 Aug 2008 13:24:40 +0000 (15:24 +0200)
* exp_ch11.adb:
(Expand_Exception_Handlers): Call Make_Exception_Handler instead of
Make_Implicit_Exception_Handler when rewriting an exception handler with
a choice parameter, and pass the handler's Sloc instead of that of the
handled sequence of statements. Make_Implicit_Exception_Handler sets the
Sloc to No_Location (unless debugging generated code), which we don't
want for the case of a user handler.

From-SVN: r139291

gcc/ada/ChangeLog
gcc/ada/exp_ch11.adb

index d23dc16..b868744 100644 (file)
@@ -1,3 +1,17 @@
+2008-08-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch8.adb (Analyze_Subprogram_Renaming): Inherit Is_Imported flag.
+
+2008-08-20  Gary Dismukes  <dismukes@adacore.com>
+
+       * exp_ch11.adb:
+       (Expand_Exception_Handlers): Call Make_Exception_Handler instead of
+       Make_Implicit_Exception_Handler when rewriting an exception handler with
+       a choice parameter, and pass the handler's Sloc instead of that of the
+       handled sequence of statements. Make_Implicit_Exception_Handler sets the
+       Sloc to No_Location (unless debugging generated code), which we don't
+       want for the case of a user handler.
+
 2008-08-20  Robert Dewar  <dewar@adacore.com>
 
        * freeze.adb (Freeze_Record_Type): Improve msg for non-contiguous field
index a8219fe..7ad1881 100644 (file)
@@ -1011,7 +1011,8 @@ package body Exp_Ch11 is
                if Present (Choice_Parameter (Handler)) then
                   declare
                      Cparm : constant Entity_Id  := Choice_Parameter (Handler);
-                     Clc   : constant Source_Ptr := Sloc (Cparm);
+                     Cloc  : constant Source_Ptr := Sloc (Cparm);
+                     Hloc  : constant Source_Ptr := Sloc (Handler);
                      Save  : Node_Id;
 
                   begin
@@ -1020,7 +1021,7 @@ package body Exp_Ch11 is
                          Name =>
                            New_Occurrence_Of (RTE (RE_Save_Occurrence), Loc),
                          Parameter_Associations => New_List (
-                           New_Occurrence_Of (Cparm, Clc),
+                           New_Occurrence_Of (Cparm, Cloc),
                            Make_Explicit_Dereference (Loc,
                              Make_Function_Call (Loc,
                                Name => Make_Explicit_Dereference (Loc,
@@ -1032,24 +1033,33 @@ package body Exp_Ch11 is
 
                      Obj_Decl :=
                        Make_Object_Declaration
-                         (Clc,
+                         (Cloc,
                           Defining_Identifier => Cparm,
                           Object_Definition   =>
                             New_Occurrence_Of
-                              (RTE (RE_Exception_Occurrence), Clc));
+                              (RTE (RE_Exception_Occurrence), Cloc));
                      Set_No_Initialization (Obj_Decl, True);
 
                      Rewrite (Handler,
-                       Make_Implicit_Exception_Handler (Loc,
+                       Make_Exception_Handler (Hloc,
+                         Choice_Parameter  => Empty,
                          Exception_Choices => Exception_Choices (Handler),
 
                          Statements => New_List (
-                           Make_Block_Statement (Loc,
+                           Make_Block_Statement (Hloc,
                              Declarations => New_List (Obj_Decl),
                              Handled_Statement_Sequence =>
-                               Make_Handled_Sequence_Of_Statements (Loc,
+                               Make_Handled_Sequence_Of_Statements (Hloc,
                                  Statements => Statements (Handler))))));
 
+                     --  Local raise statements can't occur, since exception
+                     --  handlers with choice parameters are not allowed when
+                     --  No_Exception_Propagation applies, so set attributes
+                     --  accordingly.
+
+                     Set_Local_Raise_Statements (Handler, No_Elist);
+                     Set_Local_Raise_Not_OK (Handler);
+
                      Analyze_List
                        (Statements (Handler), Suppress => All_Checks);
                   end;