Fix unused warnings.
[official-gcc/graphite-test-results.git] / gcc / ada / exp_prag.adb
blobcb896ec20ba76655f278804ff66e054882571d03
1 ------------------------------------------------------------------------------
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-2010, 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 ------------------------------------------------------------------------------
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;
53 package body Exp_Prag is
55 -----------------------
56 -- Local Subprograms --
57 -----------------------
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
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);
74 ----------
75 -- Arg1 --
76 ----------
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;
90 ----------
91 -- Arg2 --
92 ----------
94 function Arg2 (N : Node_Id) return Node_Id is
95 Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
97 begin
98 if No (Arg1) then
99 return Empty;
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;
116 ----------
117 -- Arg3 --
118 ----------
120 function Arg3 (N : Node_Id) return Node_Id is
121 Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
123 begin
124 if No (Arg1) then
125 return Empty;
127 else
128 declare
129 Arg : Node_Id := Next (Arg1);
130 begin
131 if No (Arg) then
132 return Empty;
134 else
135 Next (Arg);
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;
149 ---------------------
150 -- Expand_N_Pragma --
151 ---------------------
153 procedure Expand_N_Pragma (N : Node_Id) is
154 Pname : constant Name_Id := Pragma_Name (N);
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.
160 if Is_Pragma_Name (Pname) then
161 case Get_Pragma_Id (Pname) is
163 -- Pragmas requiring special expander action
165 when Pragma_Abort_Defer =>
166 Expand_Pragma_Abort_Defer (N);
168 when Pragma_Check =>
169 Expand_Pragma_Check (N);
171 when Pragma_Common_Object =>
172 Expand_Pragma_Common_Object (N);
174 when Pragma_Export_Exception =>
175 Expand_Pragma_Import_Export_Exception (N);
177 when Pragma_Import =>
178 Expand_Pragma_Import_Or_Interface (N);
180 when Pragma_Import_Exception =>
181 Expand_Pragma_Import_Export_Exception (N);
183 when Pragma_Inspection_Point =>
184 Expand_Pragma_Inspection_Point (N);
186 when Pragma_Interface =>
187 Expand_Pragma_Import_Or_Interface (N);
189 when Pragma_Interrupt_Priority =>
190 Expand_Pragma_Interrupt_Priority (N);
192 when Pragma_Psect_Object =>
193 Expand_Pragma_Psect_Object (N);
195 when Pragma_Relative_Deadline =>
196 Expand_Pragma_Relative_Deadline (N);
198 -- All other pragmas need no expander action
200 when others => null;
201 end case;
202 end if;
204 end Expand_N_Pragma;
206 -------------------------------
207 -- Expand_Pragma_Abort_Defer --
208 -------------------------------
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.
215 -- The transformation is to transform
217 -- pragma Abort_Defer;
218 -- statements;
220 -- into
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;
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');
241 begin
242 Stms := New_List (Build_Runtime_Call (Loc, RE_Abort_Defer));
244 loop
245 Stm := Remove_Next (N);
246 exit when No (Stm);
247 Append (Stm, Stms);
248 end loop;
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));
256 Rewrite (N,
257 Make_Block_Statement (Loc,
258 Handled_Statement_Sequence => HSS));
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;
267 --------------------------
268 -- Expand_Pragma_Check --
269 --------------------------
271 procedure Expand_Pragma_Check (N : Node_Id) is
272 Cond : constant Node_Id := Arg2 (N);
273 Loc : constant Source_Ptr := Sloc (Cond);
274 Nam : constant Name_Id := Chars (Arg1 (N));
275 Msg : Node_Id;
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)
281 -- Since this check is enabled, we rewrite the pragma into a
282 -- corresponding if statement, and then analyze the statement
284 -- The normal case expansion transforms:
286 -- pragma Check (name, condition [,message]);
288 -- into
290 -- if not condition then
291 -- System.Assertions.Raise_Assert_Failure (Str);
292 -- end if;
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.
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:
305 -- if not condition then
306 -- raise Assert_Failure;
307 -- end if;
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).
313 -- We also generate the direct raise if the Suppress_Exception_Locations
314 -- is active, since we don't want to generate messages in this case.
316 -- Note that the reason we do not always generate a direct raise is that
317 -- the form in which the procedure is called allows for more efficient
318 -- breakpointing of assertion errors.
320 -- Generate the appropriate if statement. Note that we consider this to
321 -- be an explicit conditional in the source, not an implicit if, so we
322 -- do not call Make_Implicit_If_Statement.
324 -- Case where we generate a direct raise
326 if ((Debug_Flag_Dot_G
327 or else Restriction_Active (No_Exception_Propagation))
328 and then Present (Find_Local_Handler (RTE (RE_Assert_Failure), N)))
329 or else (Opt.Exception_Locations_Suppressed and then No (Arg3 (N)))
330 then
331 Rewrite (N,
332 Make_If_Statement (Loc,
333 Condition =>
334 Make_Op_Not (Loc,
335 Right_Opnd => Cond),
336 Then_Statements => New_List (
337 Make_Raise_Statement (Loc,
338 Name =>
339 New_Reference_To (RTE (RE_Assert_Failure), Loc)))));
341 -- Case where we call the procedure
343 else
344 -- If we have a message given, use it
346 if Present (Arg3 (N)) then
347 Msg := Get_Pragma_Arg (Arg3 (N));
349 -- Here we have no string, so prepare one
351 else
352 declare
353 Msg_Loc : constant String := Build_Location_String (Loc);
355 begin
356 -- For Assert, we just use the location
358 if Nam = Name_Assertion then
359 Name_Len := 0;
361 -- For any check except Precondition/Postcondition, the
362 -- string is "xxx failed at yyy" where xxx is the name of
363 -- the check with current source file casing.
365 elsif Nam /= Name_Precondition
366 and then
367 Nam /= Name_Postcondition
368 then
369 Get_Name_String (Nam);
370 Set_Casing (Identifier_Casing (Current_Source_File));
371 Add_Str_To_Name_Buffer (" failed at ");
373 -- For special case of Precondition/Postcondition the string is
374 -- "failed xx from yy" where xx is precondition/postcondition
375 -- in all lower case. The reason for this different wording is
376 -- that the failure is not at the point of occurrence of the
377 -- pragma, unlike the other Check cases.
379 else
380 Get_Name_String (Nam);
381 Insert_Str_In_Name_Buffer ("failed ", 1);
382 Add_Str_To_Name_Buffer (" from ");
383 end if;
385 -- In all cases, add location string
387 Add_Str_To_Name_Buffer (Msg_Loc);
389 -- Build the message
391 Msg := Make_String_Literal (Loc, Name_Buffer (1 .. Name_Len));
392 end;
393 end if;
395 -- Now rewrite as an if statement
397 Rewrite (N,
398 Make_If_Statement (Loc,
399 Condition =>
400 Make_Op_Not (Loc,
401 Right_Opnd => Cond),
402 Then_Statements => New_List (
403 Make_Procedure_Call_Statement (Loc,
404 Name =>
405 New_Reference_To (RTE (RE_Raise_Assert_Failure), Loc),
406 Parameter_Associations => New_List (Relocate_Node (Msg))))));
407 end if;
409 Analyze (N);
411 -- If new condition is always false, give a warning
413 if Warn_On_Assertion_Failure
414 and then Nkind (N) = N_Procedure_Call_Statement
415 and then Is_RTE (Entity (Name (N)), RE_Raise_Assert_Failure)
416 then
417 -- If original condition was a Standard.False, we assume that this is
418 -- indeed intended to raise assert error and no warning is required.
420 if Is_Entity_Name (Original_Node (Cond))
421 and then Entity (Original_Node (Cond)) = Standard_False
422 then
423 return;
424 elsif Nam = Name_Assertion then
425 Error_Msg_N ("?assertion will fail at run time", N);
426 else
427 Error_Msg_N ("?check will fail at run time", N);
428 end if;
429 end if;
430 end Expand_Pragma_Check;
432 ---------------------------------
433 -- Expand_Pragma_Common_Object --
434 ---------------------------------
436 -- Use a machine attribute to replicate semantic effect in DEC Ada
438 -- pragma Machine_Attribute (intern_name, "common_object", extern_name);
440 -- For now we do nothing with the size attribute ???
442 -- Note: Psect_Object shares this processing
444 procedure Expand_Pragma_Common_Object (N : Node_Id) is
445 Loc : constant Source_Ptr := Sloc (N);
447 Internal : constant Node_Id := Arg1 (N);
448 External : constant Node_Id := Arg2 (N);
450 Psect : Node_Id;
451 -- Psect value upper cased as string literal
453 Iloc : constant Source_Ptr := Sloc (Internal);
454 Eloc : constant Source_Ptr := Sloc (External);
455 Ploc : Source_Ptr;
457 begin
458 -- Acquire Psect value and fold to upper case
460 if Present (External) then
461 if Nkind (External) = N_String_Literal then
462 String_To_Name_Buffer (Strval (External));
463 else
464 Get_Name_String (Chars (External));
465 end if;
467 Set_All_Upper_Case;
469 Psect :=
470 Make_String_Literal (Eloc,
471 Strval => String_From_Name_Buffer);
473 else
474 Get_Name_String (Chars (Internal));
475 Set_All_Upper_Case;
476 Psect :=
477 Make_String_Literal (Iloc,
478 Strval => String_From_Name_Buffer);
479 end if;
481 Ploc := Sloc (Psect);
483 -- Insert the pragma
485 Insert_After_And_Analyze (N,
486 Make_Pragma (Loc,
487 Chars => Name_Machine_Attribute,
488 Pragma_Argument_Associations => New_List (
489 Make_Pragma_Argument_Association (Iloc,
490 Expression => New_Copy_Tree (Internal)),
491 Make_Pragma_Argument_Association (Eloc,
492 Expression =>
493 Make_String_Literal (Sloc => Ploc,
494 Strval => "common_object")),
495 Make_Pragma_Argument_Association (Ploc,
496 Expression => New_Copy_Tree (Psect)))));
498 end Expand_Pragma_Common_Object;
500 ---------------------------------------
501 -- Expand_Pragma_Import_Or_Interface --
502 ---------------------------------------
504 -- When applied to a variable, the default initialization must not be
505 -- done. As it is already done when the pragma is found, we just get rid
506 -- of the call the initialization procedure which followed the object
507 -- declaration. The call is inserted after the declaration, but validity
508 -- checks may also have been inserted and the initialization call does
509 -- not necessarily appear immediately after the object declaration.
511 -- We can't use the freezing mechanism for this purpose, since we
512 -- have to elaborate the initialization expression when it is first
513 -- seen (i.e. this elaboration cannot be deferred to the freeze point).
515 procedure Expand_Pragma_Import_Or_Interface (N : Node_Id) is
516 Def_Id : constant Entity_Id := Entity (Arg2 (N));
517 Init_Call : Node_Id;
519 begin
520 if Ekind (Def_Id) = E_Variable then
522 -- Find generated initialization call for object, if any
524 Init_Call := Find_Init_Call (Def_Id, Rep_Clause => N);
525 if Present (Init_Call) then
526 Remove (Init_Call);
527 end if;
529 -- Any default initialization expression should be removed
530 -- (e.g., null defaults for access objects, zero initialization
531 -- of packed bit arrays). Imported objects aren't allowed to
532 -- have explicit initialization, so the expression must have
533 -- been generated by the compiler.
535 if No (Init_Call) and then Present (Expression (Parent (Def_Id))) then
536 Set_Expression (Parent (Def_Id), Empty);
537 end if;
538 end if;
539 end Expand_Pragma_Import_Or_Interface;
541 -------------------------------------------
542 -- Expand_Pragma_Import_Export_Exception --
543 -------------------------------------------
545 -- For a VMS exception fix up the language field with "VMS"
546 -- instead of "Ada" (gigi needs this), create a constant that will be the
547 -- value of the VMS condition code and stuff the Interface_Name field
548 -- with the unexpanded name of the exception (if not already set).
549 -- For a Ada exception, just stuff the Interface_Name field
550 -- with the unexpanded name of the exception (if not already set).
552 procedure Expand_Pragma_Import_Export_Exception (N : Node_Id) is
553 begin
554 -- This pragma is only effective on OpenVMS systems, it was ignored
555 -- on non-VMS systems, and we need to ignore it here as well.
557 if not OpenVMS_On_Target then
558 return;
559 end if;
561 declare
562 Id : constant Entity_Id := Entity (Arg1 (N));
563 Call : constant Node_Id := Register_Exception_Call (Id);
564 Loc : constant Source_Ptr := Sloc (N);
566 begin
567 if Present (Call) then
568 declare
569 Excep_Internal : constant Node_Id := Make_Temporary (Loc, 'V');
570 Export_Pragma : Node_Id;
571 Excep_Alias : Node_Id;
572 Excep_Object : Node_Id;
573 Excep_Image : String_Id;
574 Exdata : List_Id;
575 Lang_Char : Node_Id;
576 Code : Node_Id;
578 begin
579 if Present (Interface_Name (Id)) then
580 Excep_Image := Strval (Interface_Name (Id));
581 else
582 Get_Name_String (Chars (Id));
583 Set_All_Upper_Case;
584 Excep_Image := String_From_Name_Buffer;
585 end if;
587 Exdata := Component_Associations (Expression (Parent (Id)));
589 if Is_VMS_Exception (Id) then
590 Lang_Char := Next (First (Exdata));
592 -- Change the one-character language designator to 'V'
594 Rewrite (Expression (Lang_Char),
595 Make_Character_Literal (Loc,
596 Chars => Name_uV,
597 Char_Literal_Value =>
598 UI_From_Int (Character'Pos ('V'))));
599 Analyze (Expression (Lang_Char));
601 if Exception_Code (Id) /= No_Uint then
602 Code :=
603 Make_Integer_Literal (Loc,
604 Intval => Exception_Code (Id));
606 Excep_Object :=
607 Make_Object_Declaration (Loc,
608 Defining_Identifier => Excep_Internal,
609 Object_Definition =>
610 New_Reference_To (RTE (RE_Exception_Code), Loc));
612 Insert_Action (N, Excep_Object);
613 Analyze (Excep_Object);
615 Start_String;
616 Store_String_Int
617 (UI_To_Int (Exception_Code (Id)) / 8 * 8);
619 Excep_Alias :=
620 Make_Pragma
621 (Loc,
622 Name_Linker_Alias,
623 New_List
624 (Make_Pragma_Argument_Association
625 (Sloc => Loc,
626 Expression =>
627 New_Reference_To (Excep_Internal, Loc)),
629 Make_Pragma_Argument_Association
630 (Sloc => Loc,
631 Expression =>
632 Make_String_Literal
633 (Sloc => Loc,
634 Strval => End_String))));
636 Insert_Action (N, Excep_Alias);
637 Analyze (Excep_Alias);
639 Export_Pragma :=
640 Make_Pragma
641 (Loc,
642 Name_Export,
643 New_List
644 (Make_Pragma_Argument_Association
645 (Sloc => Loc,
646 Expression => Make_Identifier (Loc, Name_C)),
648 Make_Pragma_Argument_Association
649 (Sloc => Loc,
650 Expression =>
651 New_Reference_To (Excep_Internal, Loc)),
653 Make_Pragma_Argument_Association
654 (Sloc => Loc,
655 Expression =>
656 Make_String_Literal
657 (Sloc => Loc,
658 Strval => Excep_Image)),
660 Make_Pragma_Argument_Association
661 (Sloc => Loc,
662 Expression =>
663 Make_String_Literal
664 (Sloc => Loc,
665 Strval => Excep_Image))));
667 Insert_Action (N, Export_Pragma);
668 Analyze (Export_Pragma);
670 else
671 Code :=
672 Unchecked_Convert_To (RTE (RE_Exception_Code),
673 Make_Function_Call (Loc,
674 Name =>
675 New_Reference_To (RTE (RE_Import_Value), Loc),
676 Parameter_Associations => New_List
677 (Make_String_Literal (Loc,
678 Strval => Excep_Image))));
679 end if;
681 Rewrite (Call,
682 Make_Procedure_Call_Statement (Loc,
683 Name => New_Reference_To
684 (RTE (RE_Register_VMS_Exception), Loc),
685 Parameter_Associations => New_List (
686 Code,
687 Unchecked_Convert_To (RTE (RE_Exception_Data_Ptr),
688 Make_Attribute_Reference (Loc,
689 Prefix => New_Occurrence_Of (Id, Loc),
690 Attribute_Name => Name_Unrestricted_Access)))));
692 Analyze_And_Resolve (Code, RTE (RE_Exception_Code));
693 Analyze (Call);
694 end if;
696 if No (Interface_Name (Id)) then
697 Set_Interface_Name (Id,
698 Make_String_Literal
699 (Sloc => Loc,
700 Strval => Excep_Image));
701 end if;
702 end;
703 end if;
704 end;
705 end Expand_Pragma_Import_Export_Exception;
707 ------------------------------------
708 -- Expand_Pragma_Inspection_Point --
709 ------------------------------------
711 -- If no argument is given, then we supply a default argument list that
712 -- includes all objects declared at the source level in all subprograms
713 -- that enclose the inspection point pragma.
715 procedure Expand_Pragma_Inspection_Point (N : Node_Id) is
716 Loc : constant Source_Ptr := Sloc (N);
717 A : List_Id;
718 Assoc : Node_Id;
719 S : Entity_Id;
720 E : Entity_Id;
722 begin
723 if No (Pragma_Argument_Associations (N)) then
724 A := New_List;
725 S := Current_Scope;
727 while S /= Standard_Standard loop
728 E := First_Entity (S);
729 while Present (E) loop
730 if Comes_From_Source (E)
731 and then Is_Object (E)
732 and then not Is_Entry_Formal (E)
733 and then Ekind (E) /= E_Component
734 and then Ekind (E) /= E_Discriminant
735 and then Ekind (E) /= E_Generic_In_Parameter
736 and then Ekind (E) /= E_Generic_In_Out_Parameter
737 then
738 Append_To (A,
739 Make_Pragma_Argument_Association (Loc,
740 Expression => New_Occurrence_Of (E, Loc)));
741 end if;
743 Next_Entity (E);
744 end loop;
746 S := Scope (S);
747 end loop;
749 Set_Pragma_Argument_Associations (N, A);
750 end if;
752 -- Expand the arguments of the pragma. Expanding an entity reference
753 -- is a noop, except in a protected operation, where a reference may
754 -- have to be transformed into a reference to the corresponding prival.
755 -- Are there other pragmas that may require this ???
757 Assoc := First (Pragma_Argument_Associations (N));
759 while Present (Assoc) loop
760 Expand (Expression (Assoc));
761 Next (Assoc);
762 end loop;
763 end Expand_Pragma_Inspection_Point;
765 --------------------------------------
766 -- Expand_Pragma_Interrupt_Priority --
767 --------------------------------------
769 -- Supply default argument if none exists (System.Interrupt_Priority'Last)
771 procedure Expand_Pragma_Interrupt_Priority (N : Node_Id) is
772 Loc : constant Source_Ptr := Sloc (N);
774 begin
775 if No (Pragma_Argument_Associations (N)) then
776 Set_Pragma_Argument_Associations (N, New_List (
777 Make_Pragma_Argument_Association (Loc,
778 Expression =>
779 Make_Attribute_Reference (Loc,
780 Prefix =>
781 New_Occurrence_Of (RTE (RE_Interrupt_Priority), Loc),
782 Attribute_Name => Name_Last))));
783 end if;
784 end Expand_Pragma_Interrupt_Priority;
786 --------------------------------
787 -- Expand_Pragma_Psect_Object --
788 --------------------------------
790 -- Convert to Common_Object, and expand the resulting pragma
792 procedure Expand_Pragma_Psect_Object (N : Node_Id)
793 renames Expand_Pragma_Common_Object;
795 -------------------------------------
796 -- Expand_Pragma_Relative_Deadline --
797 -------------------------------------
799 procedure Expand_Pragma_Relative_Deadline (N : Node_Id) is
800 P : constant Node_Id := Parent (N);
801 Loc : constant Source_Ptr := Sloc (N);
803 begin
804 -- Expand the pragma only in the case of the main subprogram. For tasks
805 -- the expansion is done in exp_ch9. Generate a call to Set_Deadline
806 -- at Clock plus the relative deadline specified in the pragma. Time
807 -- values are translated into Duration to allow for non-private
808 -- addition operation.
810 if Nkind (P) = N_Subprogram_Body then
811 Rewrite
813 Make_Procedure_Call_Statement (Loc,
814 Name => New_Reference_To (RTE (RE_Set_Deadline), Loc),
815 Parameter_Associations => New_List (
816 Unchecked_Convert_To (RTE (RO_RT_Time),
817 Make_Op_Add (Loc,
818 Left_Opnd =>
819 Make_Function_Call (Loc,
820 New_Reference_To (RTE (RO_RT_To_Duration), Loc),
821 New_List (Make_Function_Call (Loc,
822 New_Reference_To (RTE (RE_Clock), Loc)))),
823 Right_Opnd =>
824 Unchecked_Convert_To (Standard_Duration, Arg1 (N)))))));
826 Analyze (N);
827 end if;
828 end Expand_Pragma_Relative_Deadline;
830 end Exp_Prag;