OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [exp_prag.adb] - Blame information for rev 847

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             E X P _ P R A G                              --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17
-- for  more details.  You should have  received  a copy of the GNU General --
18
-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
19
-- http://www.gnu.org/licenses for a complete copy of the license.          --
20
--                                                                          --
21
-- GNAT was originally developed  by the GNAT team at  New York University. --
22
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
23
--                                                                          --
24
------------------------------------------------------------------------------
25
 
26
with Atree;    use Atree;
27
with Casing;   use Casing;
28
with Debug;    use Debug;
29
with Einfo;    use Einfo;
30
with Errout;   use Errout;
31
with Exp_Ch11; use Exp_Ch11;
32
with Exp_Util; use Exp_Util;
33
with Expander; use Expander;
34
with Namet;    use Namet;
35
with Nlists;   use Nlists;
36
with Nmake;    use Nmake;
37
with Opt;      use Opt;
38
with Restrict; use Restrict;
39
with Rident;   use Rident;
40
with Rtsfind;  use Rtsfind;
41
with Sem;      use Sem;
42
with Sem_Res;  use Sem_Res;
43
with Sem_Util; use Sem_Util;
44
with Sinfo;    use Sinfo;
45
with Sinput;   use Sinput;
46
with Snames;   use Snames;
47
with Stringt;  use Stringt;
48
with Stand;    use Stand;
49
with Targparm; use Targparm;
50
with Tbuild;   use Tbuild;
51
with Uintp;    use Uintp;
52
 
53
package body Exp_Prag is
54
 
55
   -----------------------
56
   -- Local Subprograms --
57
   -----------------------
58
 
59
   function Arg1 (N : Node_Id) return Node_Id;
60
   function Arg2 (N : Node_Id) return Node_Id;
61
   function Arg3 (N : Node_Id) return Node_Id;
62
   --  Obtain specified pragma argument expression
63
 
64
   procedure Expand_Pragma_Abort_Defer             (N : Node_Id);
65
   procedure Expand_Pragma_Check                   (N : Node_Id);
66
   procedure Expand_Pragma_Common_Object           (N : Node_Id);
67
   procedure Expand_Pragma_Import_Or_Interface     (N : Node_Id);
68
   procedure Expand_Pragma_Import_Export_Exception (N : Node_Id);
69
   procedure Expand_Pragma_Inspection_Point        (N : Node_Id);
70
   procedure Expand_Pragma_Interrupt_Priority      (N : Node_Id);
71
   procedure Expand_Pragma_Psect_Object            (N : Node_Id);
72
   procedure Expand_Pragma_Relative_Deadline       (N : Node_Id);
73
 
74
   ----------
75
   -- Arg1 --
76
   ----------
77
 
78
   function Arg1 (N : Node_Id) return Node_Id is
79
      Arg : constant Node_Id := First (Pragma_Argument_Associations (N));
80
   begin
81
      if Present (Arg)
82
        and then Nkind (Arg) = N_Pragma_Argument_Association
83
      then
84
         return Expression (Arg);
85
      else
86
         return Arg;
87
      end if;
88
   end Arg1;
89
 
90
   ----------
91
   -- Arg2 --
92
   ----------
93
 
94
   function Arg2 (N : Node_Id) return Node_Id is
95
      Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
96
 
97
   begin
98
      if No (Arg1) then
99
         return Empty;
100
 
101
      else
102
         declare
103
            Arg : constant Node_Id := Next (Arg1);
104
         begin
105
            if Present (Arg)
106
              and then Nkind (Arg) = N_Pragma_Argument_Association
107
            then
108
               return Expression (Arg);
109
            else
110
               return Arg;
111
            end if;
112
         end;
113
      end if;
114
   end Arg2;
115
 
116
   ----------
117
   -- Arg3 --
118
   ----------
119
 
120
   function Arg3 (N : Node_Id) return Node_Id is
121
      Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
122
 
123
   begin
124
      if No (Arg1) then
125
         return Empty;
126
 
127
      else
128
         declare
129
            Arg : Node_Id := Next (Arg1);
130
         begin
131
            if No (Arg) then
132
               return Empty;
133
 
134
            else
135
               Next (Arg);
136
 
137
               if Present (Arg)
138
                 and then Nkind (Arg) = N_Pragma_Argument_Association
139
               then
140
                  return Expression (Arg);
141
               else
142
                  return Arg;
143
               end if;
144
            end if;
145
         end;
146
      end if;
147
   end Arg3;
148
 
149
   ---------------------
150
   -- Expand_N_Pragma --
151
   ---------------------
152
 
153
   procedure Expand_N_Pragma (N : Node_Id) is
154
      Pname : constant Name_Id := Pragma_Name (N);
155
 
156
   begin
157
      --  Note: we may have a pragma whose Pragma_Identifier field is not a
158
      --  recognized pragma, and we must ignore it at this stage.
159
 
160
      if Is_Pragma_Name (Pname) then
161
         case Get_Pragma_Id (Pname) is
162
 
163
            --  Pragmas requiring special expander action
164
 
165
            when Pragma_Abort_Defer =>
166
               Expand_Pragma_Abort_Defer (N);
167
 
168
            when Pragma_Check =>
169
               Expand_Pragma_Check (N);
170
 
171
            when Pragma_Common_Object =>
172
               Expand_Pragma_Common_Object (N);
173
 
174
            when Pragma_Export_Exception =>
175
               Expand_Pragma_Import_Export_Exception (N);
176
 
177
            when Pragma_Import =>
178
               Expand_Pragma_Import_Or_Interface (N);
179
 
180
            when Pragma_Import_Exception =>
181
               Expand_Pragma_Import_Export_Exception (N);
182
 
183
            when Pragma_Inspection_Point =>
184
               Expand_Pragma_Inspection_Point (N);
185
 
186
            when Pragma_Interface =>
187
               Expand_Pragma_Import_Or_Interface (N);
188
 
189
            when Pragma_Interrupt_Priority =>
190
               Expand_Pragma_Interrupt_Priority (N);
191
 
192
            when Pragma_Psect_Object =>
193
               Expand_Pragma_Psect_Object (N);
194
 
195
            when Pragma_Relative_Deadline =>
196
               Expand_Pragma_Relative_Deadline (N);
197
 
198
            --  All other pragmas need no expander action
199
 
200
            when others => null;
201
         end case;
202
      end if;
203
 
204
   end Expand_N_Pragma;
205
 
206
   -------------------------------
207
   -- Expand_Pragma_Abort_Defer --
208
   -------------------------------
209
 
210
   --  An Abort_Defer pragma appears as the first statement in a handled
211
   --  statement sequence (right after the begin). It defers aborts for
212
   --  the entire statement sequence, but not for any declarations or
213
   --  handlers (if any) associated with this statement sequence.
214
 
215
   --  The transformation is to transform
216
 
217
   --    pragma Abort_Defer;
218
   --    statements;
219
 
220
   --  into
221
 
222
   --    begin
223
   --       Abort_Defer.all;
224
   --       statements
225
   --    exception
226
   --       when all others =>
227
   --          Abort_Undefer.all;
228
   --          raise;
229
   --    at end
230
   --       Abort_Undefer_Direct;
231
   --    end;
232
 
233
   procedure Expand_Pragma_Abort_Defer (N : Node_Id) is
234
      Loc  : constant Source_Ptr := Sloc (N);
235
      Stm  : Node_Id;
236
      Stms : List_Id;
237
      HSS  : Node_Id;
238
      Blk  : constant Entity_Id :=
239
        New_Internal_Entity (E_Block, Current_Scope, Sloc (N), 'B');
240
 
241
   begin
242
      Stms := New_List (Build_Runtime_Call (Loc, RE_Abort_Defer));
243
 
244
      loop
245
         Stm := Remove_Next (N);
246
         exit when No (Stm);
247
         Append (Stm, Stms);
248
      end loop;
249
 
250
      HSS :=
251
        Make_Handled_Sequence_Of_Statements (Loc,
252
          Statements => Stms,
253
          At_End_Proc =>
254
            New_Occurrence_Of (RTE (RE_Abort_Undefer_Direct), Loc));
255
 
256
      Rewrite (N,
257
        Make_Block_Statement (Loc,
258
          Handled_Statement_Sequence => HSS));
259
 
260
      Set_Scope (Blk, Current_Scope);
261
      Set_Etype (Blk, Standard_Void_Type);
262
      Set_Identifier (N, New_Occurrence_Of (Blk, Sloc (N)));
263
      Expand_At_End_Handler (HSS, Blk);
264
      Analyze (N);
265
   end Expand_Pragma_Abort_Defer;
266
 
267
   --------------------------
268
   -- Expand_Pragma_Check --
269
   --------------------------
270
 
271
   procedure Expand_Pragma_Check (N : Node_Id) is
272
      Loc  : constant Source_Ptr := Sloc (N);
273
      Cond : constant Node_Id    := Arg2 (N);
274
      Nam  : constant Name_Id    := Chars (Arg1 (N));
275
      Msg  : Node_Id;
276
 
277
   begin
278
      --  We already know that this check is enabled, because otherwise the
279
      --  semantic pass dealt with rewriting the assertion (see Sem_Prag)
280
 
281
      --  Since this check is enabled, we rewrite the pragma into a
282
      --  corresponding if statement, and then analyze the statement
283
 
284
      --  The normal case expansion transforms:
285
 
286
      --    pragma Check (name, condition [,message]);
287
 
288
      --  into
289
 
290
      --    if not condition then
291
      --       System.Assertions.Raise_Assert_Failure (Str);
292
      --    end if;
293
 
294
      --  where Str is the message if one is present, or the default of
295
      --  name failed at file:line if no message is given (the "name failed
296
      --  at" is omitted for name = Assertion, since it is redundant, given
297
      --  that the name of the exception is Assert_Failure.
298
 
299
      --  An alternative expansion is used when the No_Exception_Propagation
300
      --  restriction is active and there is a local Assert_Failure handler.
301
      --  This is not a common combination of circumstances, but it occurs in
302
      --  the context of Aunit and the zero footprint profile. In this case we
303
      --  generate:
304
 
305
      --    if not condition then
306
      --       raise Assert_Failure;
307
      --    end if;
308
 
309
      --  This will then be transformed into a goto, and the local handler will
310
      --  be able to handle the assert error (which would not be the case if a
311
      --  call is made to the Raise_Assert_Failure procedure).
312
 
313
      --  Note that the reason we do not always generate a direct raise is that
314
      --  the form in which the procedure is called allows for more efficient
315
      --  breakpointing of assertion errors.
316
 
317
      --  Generate the appropriate if statement. Note that we consider this to
318
      --  be an explicit conditional in the source, not an implicit if, so we
319
      --  do not call Make_Implicit_If_Statement.
320
 
321
      --  Case where we generate a direct raise
322
 
323
      if (Debug_Flag_Dot_G
324
           or else Restriction_Active (No_Exception_Propagation))
325
        and then Present (Find_Local_Handler (RTE (RE_Assert_Failure), N))
326
      then
327
         Rewrite (N,
328
           Make_If_Statement (Loc,
329
             Condition =>
330
               Make_Op_Not (Loc,
331
                 Right_Opnd => Cond),
332
             Then_Statements => New_List (
333
               Make_Raise_Statement (Loc,
334
                 Name =>
335
                   New_Reference_To (RTE (RE_Assert_Failure), Loc)))));
336
 
337
      --  Case where we call the procedure
338
 
339
      else
340
         --  First, we need to prepare the string argument
341
 
342
         --  If we have a message given, use it
343
 
344
         if Present (Arg3 (N)) then
345
            Msg := Arg3 (N);
346
 
347
         --  Otherwise string is "name failed at location" except in the case
348
         --  of Assertion where "name failed at" is omitted.
349
 
350
         else
351
            if Nam = Name_Assertion then
352
               Name_Len := 0;
353
            else
354
               Get_Name_String (Nam);
355
               Set_Casing (Identifier_Casing (Current_Source_File));
356
               Add_Str_To_Name_Buffer (" failed at ");
357
            end if;
358
 
359
            Build_Location_String (Loc);
360
            Msg :=
361
              Make_String_Literal (Loc,
362
                Strval => String_From_Name_Buffer);
363
         end if;
364
 
365
         --  Now rewrite as an if statement
366
 
367
         Rewrite (N,
368
           Make_If_Statement (Loc,
369
             Condition =>
370
               Make_Op_Not (Loc,
371
                 Right_Opnd => Cond),
372
             Then_Statements => New_List (
373
               Make_Procedure_Call_Statement (Loc,
374
                 Name =>
375
                   New_Reference_To (RTE (RE_Raise_Assert_Failure), Loc),
376
                 Parameter_Associations => New_List (Msg)))));
377
      end if;
378
 
379
      Analyze (N);
380
 
381
      --  If new condition is always false, give a warning
382
 
383
      if Warn_On_Assertion_Failure
384
        and then Nkind (N) = N_Procedure_Call_Statement
385
        and then Is_RTE (Entity (Name (N)), RE_Raise_Assert_Failure)
386
      then
387
         --  If original condition was a Standard.False, we assume that this is
388
         --  indeed intended to raise assert error and no warning is required.
389
 
390
         if Is_Entity_Name (Original_Node (Cond))
391
           and then Entity (Original_Node (Cond)) = Standard_False
392
         then
393
            return;
394
         elsif Nam = Name_Assertion then
395
            Error_Msg_N ("?assertion will fail at run-time", N);
396
         else
397
            Error_Msg_N ("?check will fail at run time", N);
398
         end if;
399
      end if;
400
   end Expand_Pragma_Check;
401
 
402
   ---------------------------------
403
   -- Expand_Pragma_Common_Object --
404
   ---------------------------------
405
 
406
   --  Use a machine attribute to replicate semantic effect in DEC Ada
407
 
408
   --    pragma Machine_Attribute (intern_name, "common_object", extern_name);
409
 
410
   --  For now we do nothing with the size attribute ???
411
 
412
   --  Note: Psect_Object shares this processing
413
 
414
   procedure Expand_Pragma_Common_Object (N : Node_Id) is
415
      Loc : constant Source_Ptr := Sloc (N);
416
 
417
      Internal : constant Node_Id := Arg1 (N);
418
      External : constant Node_Id := Arg2 (N);
419
 
420
      Psect : Node_Id;
421
      --  Psect value upper cased as string literal
422
 
423
      Iloc : constant Source_Ptr := Sloc (Internal);
424
      Eloc : constant Source_Ptr := Sloc (External);
425
      Ploc : Source_Ptr;
426
 
427
   begin
428
      --  Acquire Psect value and fold to upper case
429
 
430
      if Present (External) then
431
         if Nkind (External) = N_String_Literal then
432
            String_To_Name_Buffer (Strval (External));
433
         else
434
            Get_Name_String (Chars (External));
435
         end if;
436
 
437
         Set_All_Upper_Case;
438
 
439
         Psect :=
440
           Make_String_Literal (Eloc,
441
             Strval => String_From_Name_Buffer);
442
 
443
      else
444
         Get_Name_String (Chars (Internal));
445
         Set_All_Upper_Case;
446
         Psect :=
447
           Make_String_Literal (Iloc,
448
             Strval => String_From_Name_Buffer);
449
      end if;
450
 
451
      Ploc := Sloc (Psect);
452
 
453
      --  Insert the pragma
454
 
455
      Insert_After_And_Analyze (N,
456
         Make_Pragma (Loc,
457
           Chars => Name_Machine_Attribute,
458
           Pragma_Argument_Associations => New_List (
459
             Make_Pragma_Argument_Association (Iloc,
460
               Expression => New_Copy_Tree (Internal)),
461
             Make_Pragma_Argument_Association (Eloc,
462
               Expression =>
463
                 Make_String_Literal (Sloc => Ploc,
464
                   Strval => "common_object")),
465
             Make_Pragma_Argument_Association (Ploc,
466
               Expression => New_Copy_Tree (Psect)))));
467
 
468
   end Expand_Pragma_Common_Object;
469
 
470
   ---------------------------------------
471
   -- Expand_Pragma_Import_Or_Interface --
472
   ---------------------------------------
473
 
474
   --  When applied to a variable, the default initialization must not be
475
   --  done. As it is already done when the pragma is found, we just get rid
476
   --  of the call the initialization procedure which followed the object
477
   --  declaration. The call is inserted after the declaration, but validity
478
   --  checks may also have been inserted and the initialization call does
479
   --  not necessarily appear immediately after the object declaration.
480
 
481
   --  We can't use the freezing mechanism for this purpose, since we
482
   --  have to elaborate the initialization expression when it is first
483
   --  seen (i.e. this elaboration cannot be deferred to the freeze point).
484
 
485
   procedure Expand_Pragma_Import_Or_Interface (N : Node_Id) is
486
      Def_Id    : constant Entity_Id := Entity (Arg2 (N));
487
      Init_Call : Node_Id;
488
 
489
   begin
490
      if Ekind (Def_Id) = E_Variable then
491
 
492
         --  Find generated initialization call for object, if any
493
 
494
         Init_Call := Find_Init_Call (Def_Id, Rep_Clause => N);
495
         if Present (Init_Call) then
496
            Remove (Init_Call);
497
         end if;
498
 
499
         --  Any default initialization expression should be removed
500
         --  (e.g., null defaults for access objects, zero initialization
501
         --  of packed bit arrays). Imported objects aren't allowed to
502
         --  have explicit initialization, so the expression must have
503
         --  been generated by the compiler.
504
 
505
         if No (Init_Call) and then Present (Expression (Parent (Def_Id))) then
506
            Set_Expression (Parent (Def_Id), Empty);
507
         end if;
508
      end if;
509
   end Expand_Pragma_Import_Or_Interface;
510
 
511
   -------------------------------------------
512
   -- Expand_Pragma_Import_Export_Exception --
513
   -------------------------------------------
514
 
515
   --  For a VMS exception fix up the language field with "VMS"
516
   --  instead of "Ada" (gigi needs this), create a constant that will be the
517
   --  value of the VMS condition code and stuff the Interface_Name field
518
   --  with the unexpanded name of the exception (if not already set).
519
   --  For a Ada exception, just stuff the Interface_Name field
520
   --  with the unexpanded name of the exception (if not already set).
521
 
522
   procedure Expand_Pragma_Import_Export_Exception (N : Node_Id) is
523
   begin
524
      --  This pragma is only effective on OpenVMS systems, it was ignored
525
      --  on non-VMS systems, and we need to ignore it here as well.
526
 
527
      if not OpenVMS_On_Target then
528
         return;
529
      end if;
530
 
531
      declare
532
         Id     : constant Entity_Id := Entity (Arg1 (N));
533
         Call   : constant Node_Id := Register_Exception_Call (Id);
534
         Loc    : constant Source_Ptr := Sloc (N);
535
 
536
      begin
537
         if Present (Call) then
538
            declare
539
               Excep_Internal : constant Node_Id :=
540
                                 Make_Defining_Identifier
541
                                  (Loc, New_Internal_Name ('V'));
542
 
543
               Export_Pragma : Node_Id;
544
               Excep_Alias   : Node_Id;
545
               Excep_Object  : Node_Id;
546
               Excep_Image   : String_Id;
547
               Exdata        : List_Id;
548
               Lang_Char     : Node_Id;
549
               Code          : Node_Id;
550
 
551
            begin
552
               if Present (Interface_Name (Id)) then
553
                  Excep_Image := Strval (Interface_Name (Id));
554
               else
555
                  Get_Name_String (Chars (Id));
556
                  Set_All_Upper_Case;
557
                  Excep_Image := String_From_Name_Buffer;
558
               end if;
559
 
560
               Exdata := Component_Associations (Expression (Parent (Id)));
561
 
562
               if Is_VMS_Exception (Id) then
563
                  Lang_Char := Next (First (Exdata));
564
 
565
                  --  Change the one-character language designator to 'V'
566
 
567
                  Rewrite (Expression (Lang_Char),
568
                    Make_Character_Literal (Loc,
569
                      Chars => Name_uV,
570
                      Char_Literal_Value =>
571
                        UI_From_Int (Character'Pos ('V'))));
572
                  Analyze (Expression (Lang_Char));
573
 
574
                  if Exception_Code (Id) /= No_Uint then
575
                     Code :=
576
                       Make_Integer_Literal (Loc,
577
                         Intval => Exception_Code (Id));
578
 
579
                     Excep_Object :=
580
                       Make_Object_Declaration (Loc,
581
                         Defining_Identifier => Excep_Internal,
582
                         Object_Definition   =>
583
                           New_Reference_To (RTE (RE_Exception_Code), Loc));
584
 
585
                     Insert_Action (N, Excep_Object);
586
                     Analyze (Excep_Object);
587
 
588
                     Start_String;
589
                     Store_String_Int
590
                       (UI_To_Int (Exception_Code (Id)) / 8 * 8);
591
 
592
                     Excep_Alias :=
593
                       Make_Pragma
594
                         (Loc,
595
                          Name_Linker_Alias,
596
                          New_List
597
                            (Make_Pragma_Argument_Association
598
                               (Sloc => Loc,
599
                                Expression =>
600
                                  New_Reference_To (Excep_Internal, Loc)),
601
 
602
                             Make_Pragma_Argument_Association
603
                               (Sloc => Loc,
604
                                Expression =>
605
                                  Make_String_Literal
606
                                    (Sloc => Loc,
607
                                     Strval => End_String))));
608
 
609
                     Insert_Action (N, Excep_Alias);
610
                     Analyze (Excep_Alias);
611
 
612
                     Export_Pragma :=
613
                       Make_Pragma
614
                         (Loc,
615
                          Name_Export,
616
                          New_List
617
                            (Make_Pragma_Argument_Association
618
                               (Sloc => Loc,
619
                                Expression => Make_Identifier (Loc, Name_C)),
620
 
621
                             Make_Pragma_Argument_Association
622
                               (Sloc => Loc,
623
                                Expression =>
624
                                  New_Reference_To (Excep_Internal, Loc)),
625
 
626
                             Make_Pragma_Argument_Association
627
                               (Sloc => Loc,
628
                                Expression =>
629
                                  Make_String_Literal
630
                                    (Sloc => Loc,
631
                                     Strval => Excep_Image)),
632
 
633
                             Make_Pragma_Argument_Association
634
                               (Sloc => Loc,
635
                                Expression =>
636
                                  Make_String_Literal
637
                                    (Sloc => Loc,
638
                                     Strval => Excep_Image))));
639
 
640
                     Insert_Action (N, Export_Pragma);
641
                     Analyze (Export_Pragma);
642
 
643
                  else
644
                     Code :=
645
                        Unchecked_Convert_To (RTE (RE_Exception_Code),
646
                          Make_Function_Call (Loc,
647
                            Name =>
648
                              New_Reference_To (RTE (RE_Import_Value), Loc),
649
                            Parameter_Associations => New_List
650
                              (Make_String_Literal (Loc,
651
                                Strval => Excep_Image))));
652
                  end if;
653
 
654
                  Rewrite (Call,
655
                    Make_Procedure_Call_Statement (Loc,
656
                      Name => New_Reference_To
657
                                (RTE (RE_Register_VMS_Exception), Loc),
658
                      Parameter_Associations => New_List (
659
                        Code,
660
                        Unchecked_Convert_To (RTE (RE_Exception_Data_Ptr),
661
                          Make_Attribute_Reference (Loc,
662
                            Prefix         => New_Occurrence_Of (Id, Loc),
663
                            Attribute_Name => Name_Unrestricted_Access)))));
664
 
665
                  Analyze_And_Resolve (Code, RTE (RE_Exception_Code));
666
                  Analyze (Call);
667
               end if;
668
 
669
               if No (Interface_Name (Id)) then
670
                  Set_Interface_Name (Id,
671
                     Make_String_Literal
672
                       (Sloc => Loc,
673
                        Strval => Excep_Image));
674
               end if;
675
            end;
676
         end if;
677
      end;
678
   end Expand_Pragma_Import_Export_Exception;
679
 
680
   ------------------------------------
681
   -- Expand_Pragma_Inspection_Point --
682
   ------------------------------------
683
 
684
   --  If no argument is given, then we supply a default argument list that
685
   --  includes all objects declared at the source level in all subprograms
686
   --  that enclose the inspection point pragma.
687
 
688
   procedure Expand_Pragma_Inspection_Point (N : Node_Id) is
689
      Loc : constant Source_Ptr := Sloc (N);
690
      A     : List_Id;
691
      Assoc : Node_Id;
692
      S     : Entity_Id;
693
      E     : Entity_Id;
694
 
695
   begin
696
      if No (Pragma_Argument_Associations (N)) then
697
         A := New_List;
698
         S := Current_Scope;
699
 
700
         while S /= Standard_Standard loop
701
            E := First_Entity (S);
702
            while Present (E) loop
703
               if Comes_From_Source (E)
704
                 and then Is_Object (E)
705
                 and then not Is_Entry_Formal (E)
706
                 and then Ekind (E) /= E_Component
707
                 and then Ekind (E) /= E_Discriminant
708
                 and then Ekind (E) /= E_Generic_In_Parameter
709
                 and then Ekind (E) /= E_Generic_In_Out_Parameter
710
               then
711
                  Append_To (A,
712
                    Make_Pragma_Argument_Association (Loc,
713
                      Expression => New_Occurrence_Of (E, Loc)));
714
               end if;
715
 
716
               Next_Entity (E);
717
            end loop;
718
 
719
            S := Scope (S);
720
         end loop;
721
 
722
         Set_Pragma_Argument_Associations (N, A);
723
      end if;
724
 
725
      --  Expand the arguments of the pragma. Expanding an entity reference
726
      --  is a noop, except in a protected operation, where a reference may
727
      --  have to be transformed into a reference to the corresponding prival.
728
      --  Are there other pragmas that may require this ???
729
 
730
      Assoc := First (Pragma_Argument_Associations (N));
731
 
732
      while Present (Assoc) loop
733
         Expand (Expression (Assoc));
734
         Next (Assoc);
735
      end loop;
736
   end Expand_Pragma_Inspection_Point;
737
 
738
   --------------------------------------
739
   -- Expand_Pragma_Interrupt_Priority --
740
   --------------------------------------
741
 
742
   --  Supply default argument if none exists (System.Interrupt_Priority'Last)
743
 
744
   procedure Expand_Pragma_Interrupt_Priority (N : Node_Id) is
745
      Loc : constant Source_Ptr := Sloc (N);
746
 
747
   begin
748
      if No (Pragma_Argument_Associations (N)) then
749
         Set_Pragma_Argument_Associations (N, New_List (
750
           Make_Pragma_Argument_Association (Loc,
751
             Expression =>
752
               Make_Attribute_Reference (Loc,
753
                 Prefix =>
754
                   New_Occurrence_Of (RTE (RE_Interrupt_Priority), Loc),
755
                 Attribute_Name => Name_Last))));
756
      end if;
757
   end Expand_Pragma_Interrupt_Priority;
758
 
759
   --------------------------------
760
   -- Expand_Pragma_Psect_Object --
761
   --------------------------------
762
 
763
   --  Convert to Common_Object, and expand the resulting pragma
764
 
765
   procedure Expand_Pragma_Psect_Object (N : Node_Id)
766
     renames Expand_Pragma_Common_Object;
767
 
768
   -------------------------------------
769
   -- Expand_Pragma_Relative_Deadline --
770
   -------------------------------------
771
 
772
   procedure Expand_Pragma_Relative_Deadline (N : Node_Id) is
773
      P    : constant Node_Id    := Parent (N);
774
      Loc  : constant Source_Ptr := Sloc (N);
775
 
776
   begin
777
      --  Expand the pragma only in the case of the main subprogram. For tasks
778
      --  the expansion is done in exp_ch9. Generate a call to Set_Deadline
779
      --  at Clock plus the relative deadline specified in the pragma. Time
780
      --  values are translated into Duration to allow for non-private
781
      --  addition operation.
782
 
783
      if Nkind (P) = N_Subprogram_Body then
784
         Rewrite
785
           (N,
786
            Make_Procedure_Call_Statement (Loc,
787
              Name => New_Reference_To (RTE (RE_Set_Deadline), Loc),
788
              Parameter_Associations => New_List (
789
                Unchecked_Convert_To (RTE (RO_RT_Time),
790
                  Make_Op_Add (Loc,
791
                    Left_Opnd  =>
792
                      Make_Function_Call (Loc,
793
                        New_Reference_To (RTE (RO_RT_To_Duration), Loc),
794
                        New_List (Make_Function_Call (Loc,
795
                          New_Reference_To (RTE (RE_Clock), Loc)))),
796
                    Right_Opnd  =>
797
                      Unchecked_Convert_To (Standard_Duration, Arg1 (N)))))));
798
 
799
         Analyze (N);
800
      end if;
801
   end Expand_Pragma_Relative_Deadline;
802
 
803
end Exp_Prag;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.