1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                             P A R . P R A G                              --
6--                                                                          --
7--                                 B o d y                                  --
8--                                                                          --
9--          Copyright (C) 1992-2015, 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--  Generally the parser checks the basic syntax of pragmas, but does not
27--  do specialized syntax checks for individual pragmas, these are deferred
28--  to semantic analysis time (see unit Sem_Prag). There are some pragmas
29--  which require recognition and either partial or complete processing
30--  during parsing, and this unit performs this required processing.
31
32with Fname.UF; use Fname.UF;
33with Osint;    use Osint;
34with Rident;   use Rident;
35with Restrict; use Restrict;
36with Stringt;  use Stringt;
37with Stylesw;  use Stylesw;
38with Uintp;    use Uintp;
39with Uname;    use Uname;
40
41with System.WCh_Con; use System.WCh_Con;
42
43separate (Par)
44
45function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
46   Prag_Name   : constant Name_Id    := Pragma_Name (Pragma_Node);
47   Prag_Id     : constant Pragma_Id  := Get_Pragma_Id (Prag_Name);
48   Pragma_Sloc : constant Source_Ptr := Sloc (Pragma_Node);
49   Arg_Count   : Nat;
50   Arg_Node    : Node_Id;
51
52   -----------------------
53   -- Local Subprograms --
54   -----------------------
55
56   procedure Add_List_Pragma_Entry (PT : List_Pragma_Type; Loc : Source_Ptr);
57   --  Make a new entry in the List_Pragmas table if this entry is not already
58   --  in the table (it will always be the last one if there is a duplication
59   --  resulting from the use of Save/Restore_Scan_State).
60
61   function Arg1 return Node_Id;
62   function Arg2 return Node_Id;
63   function Arg3 return Node_Id;
64   --  Obtain specified Pragma_Argument_Association. It is allowable to call
65   --  the routine for the argument one past the last present argument, but
66   --  that is the only case in which a non-present argument can be referenced.
67
68   procedure Check_Arg_Count (Required : Int);
69   --  Check argument count for pragma = Required. If not give error and raise
70   --  Error_Resync.
71
72   procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
73   --  Check the expression of the specified argument to make sure that it
74   --  is a string literal. If not give error and raise Error_Resync.
75
76   procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id);
77   --  Check the expression of the specified argument to make sure that it
78   --  is an identifier which is either ON or OFF, and if not, then issue
79   --  an error message and raise Error_Resync.
80
81   procedure Check_No_Identifier (Arg : Node_Id);
82   --  Checks that the given argument does not have an identifier. If
83   --  an identifier is present, then an error message is issued, and
84   --  Error_Resync is raised.
85
86   procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
87   --  Checks if the given argument has an identifier, and if so, requires
88   --  it to match the given identifier name. If there is a non-matching
89   --  identifier, then an error message is given and Error_Resync raised.
90
91   procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id);
92   --  Same as Check_Optional_Identifier, except that the name is required
93   --  to be present and to match the given Id value.
94
95   procedure Process_Restrictions_Or_Restriction_Warnings;
96   --  Common processing for Restrictions and Restriction_Warnings pragmas.
97   --  For the most part, restrictions need not be processed at parse time,
98   --  since they only affect semantic processing. This routine handles the
99   --  exceptions as follows
100   --
101   --    No_Obsolescent_Features must be processed at parse time, since there
102   --    are some obsolescent features (e.g. character replacements) which are
103   --    handled at parse time.
104   --
105   --    SPARK must be processed at parse time, since this restriction controls
106   --    whether the scanner recognizes a spark HIDE directive formatted as an
107   --    Ada comment (and generates a Tok_SPARK_Hide token for the directive).
108   --
109   --    No_Dependence must be processed at parse time, since otherwise it gets
110   --    handled too late.
111   --
112   --  Note that we don't need to do full error checking for badly formed cases
113   --  of restrictions, since these will be caught during semantic analysis.
114
115   ---------------------------
116   -- Add_List_Pragma_Entry --
117   ---------------------------
118
119   procedure Add_List_Pragma_Entry (PT : List_Pragma_Type; Loc : Source_Ptr) is
120   begin
121      if List_Pragmas.Last < List_Pragmas.First
122        or else (List_Pragmas.Table (List_Pragmas.Last)) /= ((PT, Loc))
123      then
124         List_Pragmas.Append ((PT, Loc));
125      end if;
126   end Add_List_Pragma_Entry;
127
128   ----------
129   -- Arg1 --
130   ----------
131
132   function Arg1 return Node_Id is
133   begin
134      return First (Pragma_Argument_Associations (Pragma_Node));
135   end Arg1;
136
137   ----------
138   -- Arg2 --
139   ----------
140
141   function Arg2 return Node_Id is
142   begin
143      return Next (Arg1);
144   end Arg2;
145
146   ----------
147   -- Arg3 --
148   ----------
149
150   function Arg3 return Node_Id is
151   begin
152      return Next (Arg2);
153   end Arg3;
154
155   ---------------------
156   -- Check_Arg_Count --
157   ---------------------
158
159   procedure Check_Arg_Count (Required : Int) is
160   begin
161      if Arg_Count /= Required then
162         Error_Msg ("wrong number of arguments for pragma%", Pragma_Sloc);
163         raise Error_Resync;
164      end if;
165   end Check_Arg_Count;
166
167   ----------------------------
168   -- Check_Arg_Is_On_Or_Off --
169   ----------------------------
170
171   procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id) is
172      Argx : constant Node_Id := Expression (Arg);
173
174   begin
175      if Nkind (Expression (Arg)) /= N_Identifier
176        or else not Nam_In (Chars (Argx), Name_On, Name_Off)
177      then
178         Error_Msg_Name_2 := Name_On;
179         Error_Msg_Name_3 := Name_Off;
180
181         Error_Msg ("argument for pragma% must be% or%", Sloc (Argx));
182         raise Error_Resync;
183      end if;
184   end Check_Arg_Is_On_Or_Off;
185
186   ---------------------------------
187   -- Check_Arg_Is_String_Literal --
188   ---------------------------------
189
190   procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
191   begin
192      if Nkind (Expression (Arg)) /= N_String_Literal then
193         Error_Msg
194           ("argument for pragma% must be string literal",
195             Sloc (Expression (Arg)));
196         raise Error_Resync;
197      end if;
198   end Check_Arg_Is_String_Literal;
199
200   -------------------------
201   -- Check_No_Identifier --
202   -------------------------
203
204   procedure Check_No_Identifier (Arg : Node_Id) is
205   begin
206      if Chars (Arg) /= No_Name then
207         Error_Msg_N ("pragma% does not permit named arguments", Arg);
208         raise Error_Resync;
209      end if;
210   end Check_No_Identifier;
211
212   -------------------------------
213   -- Check_Optional_Identifier --
214   -------------------------------
215
216   procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
217   begin
218      if Present (Arg) and then Chars (Arg) /= No_Name then
219         if Chars (Arg) /= Id then
220            Error_Msg_Name_2 := Id;
221            Error_Msg_N ("pragma% argument expects identifier%", Arg);
222         end if;
223      end if;
224   end Check_Optional_Identifier;
225
226   -------------------------------
227   -- Check_Required_Identifier --
228   -------------------------------
229
230   procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id) is
231   begin
232      if Chars (Arg) /= Id then
233         Error_Msg_Name_2 := Id;
234         Error_Msg_N ("pragma% argument must have identifier%", Arg);
235      end if;
236   end Check_Required_Identifier;
237
238   --------------------------------------------------
239   -- Process_Restrictions_Or_Restriction_Warnings --
240   --------------------------------------------------
241
242   procedure Process_Restrictions_Or_Restriction_Warnings is
243      Arg  : Node_Id;
244      Id   : Name_Id;
245      Expr : Node_Id;
246
247   begin
248      Arg := Arg1;
249      while Present (Arg) loop
250         Id := Chars (Arg);
251         Expr := Expression (Arg);
252
253         if Id = No_Name and then Nkind (Expr) = N_Identifier then
254            case Chars (Expr) is
255               when Name_No_Obsolescent_Features =>
256                  Set_Restriction (No_Obsolescent_Features, Pragma_Node);
257                  Restriction_Warnings (No_Obsolescent_Features) :=
258                    Prag_Id = Pragma_Restriction_Warnings;
259
260               when Name_SPARK | Name_SPARK_05 =>
261                  Set_Restriction (SPARK_05, Pragma_Node);
262                  Restriction_Warnings (SPARK_05) :=
263                    Prag_Id = Pragma_Restriction_Warnings;
264
265               when others =>
266                  null;
267            end case;
268
269         elsif Id = Name_No_Dependence then
270            Set_Restriction_No_Dependence
271              (Unit => Expr,
272               Warn => Prag_Id = Pragma_Restriction_Warnings
273                         or else Treat_Restrictions_As_Warnings);
274         end if;
275
276         Next (Arg);
277      end loop;
278   end Process_Restrictions_Or_Restriction_Warnings;
279
280--  Start of processing for Prag
281
282begin
283   Error_Msg_Name_1 := Prag_Name;
284
285   --  Ignore unrecognized pragma. We let Sem post the warning for this, since
286   --  it is a semantic error, not a syntactic one (we have already checked
287   --  the syntax for the unrecognized pragma as required by (RM 2.8(11)).
288
289   if Prag_Id = Unknown_Pragma then
290      return Pragma_Node;
291   end if;
292
293   --  Ignore pragma previously flagged by Ignore_Pragma
294
295   if Get_Name_Table_Boolean3 (Prag_Name) then
296      return Pragma_Node;
297   end if;
298
299   --  Count number of arguments. This loop also checks if any of the arguments
300   --  are Error, indicating a syntax error as they were parsed. If so, we
301   --  simply return, because we get into trouble with cascaded errors if we
302   --  try to perform our error checks on junk arguments.
303
304   Arg_Count := 0;
305
306   if Present (Pragma_Argument_Associations (Pragma_Node)) then
307      Arg_Node := Arg1;
308      while Arg_Node /= Empty loop
309         Arg_Count := Arg_Count + 1;
310
311         if Expression (Arg_Node) = Error then
312            return Error;
313         end if;
314
315         Next (Arg_Node);
316      end loop;
317   end if;
318
319   --  Remaining processing is pragma dependent
320
321   case Prag_Id is
322
323      ------------
324      -- Ada_83 --
325      ------------
326
327      --  This pragma must be processed at parse time, since we want to set
328      --  the Ada version properly at parse time to recognize the appropriate
329      --  Ada version syntax.
330
331      when Pragma_Ada_83 =>
332         Ada_Version := Ada_83;
333         Ada_Version_Explicit := Ada_83;
334         Ada_Version_Pragma := Pragma_Node;
335
336      ------------
337      -- Ada_95 --
338      ------------
339
340      --  This pragma must be processed at parse time, since we want to set
341      --  the Ada version properly at parse time to recognize the appropriate
342      --  Ada version syntax.
343
344      when Pragma_Ada_95 =>
345         Ada_Version := Ada_95;
346         Ada_Version_Explicit := Ada_95;
347         Ada_Version_Pragma := Pragma_Node;
348
349      ---------------------
350      -- Ada_05/Ada_2005 --
351      ---------------------
352
353      --  These pragmas must be processed at parse time, since we want to set
354      --  the Ada version properly at parse time to recognize the appropriate
355      --  Ada version syntax. However, it is only the zero argument form that
356      --  must be processed at parse time.
357
358      when Pragma_Ada_05 | Pragma_Ada_2005 =>
359         if Arg_Count = 0 then
360            Ada_Version := Ada_2005;
361            Ada_Version_Explicit := Ada_2005;
362            Ada_Version_Pragma := Pragma_Node;
363         end if;
364
365      ---------------------
366      -- Ada_12/Ada_2012 --
367      ---------------------
368
369      --  These pragmas must be processed at parse time, since we want to set
370      --  the Ada version properly at parse time to recognize the appropriate
371      --  Ada version syntax. However, it is only the zero argument form that
372      --  must be processed at parse time.
373
374      when Pragma_Ada_12 | Pragma_Ada_2012 =>
375         if Arg_Count = 0 then
376            Ada_Version := Ada_2012;
377            Ada_Version_Explicit := Ada_2012;
378            Ada_Version_Pragma := Pragma_Node;
379         end if;
380
381      ---------------------------
382      -- Compiler_Unit_Warning --
383      ---------------------------
384
385      --  This pragma must be processed at parse time, since the resulting
386      --  status may be tested during the parsing of the program.
387
388      when Pragma_Compiler_Unit | Pragma_Compiler_Unit_Warning =>
389         Check_Arg_Count (0);
390
391         --  Only recognized in main unit
392
393         if Current_Source_Unit = Main_Unit then
394            Compiler_Unit := True;
395         end if;
396
397      -----------
398      -- Debug --
399      -----------
400
401      --  pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
402
403      when Pragma_Debug =>
404         Check_No_Identifier (Arg1);
405
406         if Arg_Count = 2 then
407            Check_No_Identifier (Arg2);
408         else
409            Check_Arg_Count (1);
410         end if;
411
412      -------------------------------
413      -- Extensions_Allowed (GNAT) --
414      -------------------------------
415
416      --  pragma Extensions_Allowed (Off | On)
417
418      --  The processing for pragma Extensions_Allowed must be done at
419      --  parse time, since extensions mode may affect what is accepted.
420
421      when Pragma_Extensions_Allowed =>
422         Check_Arg_Count (1);
423         Check_No_Identifier (Arg1);
424         Check_Arg_Is_On_Or_Off (Arg1);
425
426         if Chars (Expression (Arg1)) = Name_On then
427            Extensions_Allowed := True;
428            Ada_Version := Ada_2012;
429         else
430            Extensions_Allowed := False;
431            Ada_Version := Ada_Version_Explicit;
432         end if;
433
434      -------------------
435      -- Ignore_Pragma --
436      -------------------
437
438      --  Processing for this pragma must be done at parse time, since we want
439      --  be able to ignore pragmas that are otherwise processed at parse time.
440
441      when Pragma_Ignore_Pragma => Ignore_Pragma : declare
442         A : Node_Id;
443
444      begin
445         Check_Arg_Count (1);
446         Check_No_Identifier (Arg1);
447         A := Expression (Arg1);
448
449         if Nkind (A) /= N_Identifier then
450            Error_Msg ("incorrect argument for pragma %", Sloc (A));
451         else
452            Set_Name_Table_Boolean3 (Chars (A), True);
453         end if;
454      end Ignore_Pragma;
455
456      ----------------
457      -- List (2.8) --
458      ----------------
459
460      --  pragma List (Off | On)
461
462      --  The processing for pragma List must be done at parse time, since a
463      --  listing can be generated in parse only mode.
464
465      when Pragma_List =>
466         Check_Arg_Count (1);
467         Check_No_Identifier (Arg1);
468         Check_Arg_Is_On_Or_Off (Arg1);
469
470         --  We unconditionally make a List_On entry for the pragma, so that
471         --  in the List (Off) case, the pragma will print even in a region
472         --  of code with listing turned off (this is required).
473
474         Add_List_Pragma_Entry (List_On, Sloc (Pragma_Node));
475
476         --  Now generate the list off entry for pragma List (Off)
477
478         if Chars (Expression (Arg1)) = Name_Off then
479            Add_List_Pragma_Entry (List_Off, Semi);
480         end if;
481
482      ----------------
483      -- Page (2.8) --
484      ----------------
485
486      --  pragma Page;
487
488      --  Processing for this pragma must be done at parse time, since a
489      --  listing can be generated in parse only mode with semantics off.
490
491      when Pragma_Page =>
492         Check_Arg_Count (0);
493         Add_List_Pragma_Entry (Page, Semi);
494
495      ------------------
496      -- Restrictions --
497      ------------------
498
499      --  pragma Restrictions (RESTRICTION {, RESTRICTION});
500
501      --  RESTRICTION ::=
502      --    restriction_IDENTIFIER
503      --  | restriction_parameter_IDENTIFIER => EXPRESSION
504
505      --  We process the case of No_Obsolescent_Features, since this has
506      --  a syntactic effect that we need to detect at parse time (the use
507      --  of replacement characters such as colon for pound sign).
508
509      when Pragma_Restrictions =>
510         Process_Restrictions_Or_Restriction_Warnings;
511
512      --------------------------
513      -- Restriction_Warnings --
514      --------------------------
515
516      --  pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
517
518      --  RESTRICTION ::=
519      --    restriction_IDENTIFIER
520      --  | restriction_parameter_IDENTIFIER => EXPRESSION
521
522      --  See above comment for pragma Restrictions
523
524      when Pragma_Restriction_Warnings =>
525         Process_Restrictions_Or_Restriction_Warnings;
526
527      ----------------------------------------------------------
528      -- Source_File_Name and Source_File_Name_Project (GNAT) --
529      ----------------------------------------------------------
530
531      --  These two pragmas have the same syntax and semantics.
532      --  There are five forms of these pragmas:
533
534      --  pragma Source_File_Name[_Project] (
535      --    [UNIT_NAME      =>] unit_NAME,
536      --     BODY_FILE_NAME =>  STRING_LITERAL
537      --    [, [INDEX =>] INTEGER_LITERAL]);
538
539      --  pragma Source_File_Name[_Project] (
540      --    [UNIT_NAME      =>] unit_NAME,
541      --     SPEC_FILE_NAME =>  STRING_LITERAL
542      --    [, [INDEX =>] INTEGER_LITERAL]);
543
544      --  pragma Source_File_Name[_Project] (
545      --     BODY_FILE_NAME  => STRING_LITERAL
546      --  [, DOT_REPLACEMENT => STRING_LITERAL]
547      --  [, CASING          => CASING_SPEC]);
548
549      --  pragma Source_File_Name[_Project] (
550      --     SPEC_FILE_NAME  => STRING_LITERAL
551      --  [, DOT_REPLACEMENT => STRING_LITERAL]
552      --  [, CASING          => CASING_SPEC]);
553
554      --  pragma Source_File_Name[_Project] (
555      --     SUBUNIT_FILE_NAME  => STRING_LITERAL
556      --  [, DOT_REPLACEMENT    => STRING_LITERAL]
557      --  [, CASING             => CASING_SPEC]);
558
559      --  CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
560
561      --  Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
562      --  Source_File_Name (SFN), however their usage is exclusive:
563      --  SFN can only be used when no project file is used, while
564      --  SFNP can only be used when a project file is used.
565
566      --  The Project Manager produces a configuration pragmas file that
567      --  is communicated to the compiler with -gnatec switch. This file
568      --  contains only SFNP pragmas (at least two for the default naming
569      --  scheme. As this configuration pragmas file is always the first
570      --  processed by the compiler, it prevents the use of pragmas SFN in
571      --  other config files when a project file is in use.
572
573      --  Note: we process this during parsing, since we need to have the
574      --  source file names set well before the semantic analysis starts,
575      --  since we load the spec and with'ed packages before analysis.
576
577      when Pragma_Source_File_Name | Pragma_Source_File_Name_Project =>
578         Source_File_Name : declare
579            Unam  : Unit_Name_Type;
580            Expr1 : Node_Id;
581            Pat   : String_Ptr;
582            Typ   : Character;
583            Dot   : String_Ptr;
584            Cas   : Casing_Type;
585            Nast  : Nat;
586            Expr  : Node_Id;
587            Index : Nat;
588
589            function Get_Fname (Arg : Node_Id) return File_Name_Type;
590            --  Process file name from unit name form of pragma
591
592            function Get_String_Argument (Arg : Node_Id) return String_Ptr;
593            --  Process string literal value from argument
594
595            procedure Process_Casing (Arg : Node_Id);
596            --  Process Casing argument of pattern form of pragma
597
598            procedure Process_Dot_Replacement (Arg : Node_Id);
599            --  Process Dot_Replacement argument of pattern form of pragma
600
601            ---------------
602            -- Get_Fname --
603            ---------------
604
605            function Get_Fname (Arg : Node_Id) return File_Name_Type is
606            begin
607               String_To_Name_Buffer (Strval (Expression (Arg)));
608
609               for J in 1 .. Name_Len loop
610                  if Is_Directory_Separator (Name_Buffer (J)) then
611                     Error_Msg
612                       ("directory separator character not allowed",
613                        Sloc (Expression (Arg)) + Source_Ptr (J));
614                  end if;
615               end loop;
616
617               return Name_Find;
618            end Get_Fname;
619
620            -------------------------
621            -- Get_String_Argument --
622            -------------------------
623
624            function Get_String_Argument (Arg : Node_Id) return String_Ptr is
625               Str : String_Id;
626
627            begin
628               if Nkind (Expression (Arg)) /= N_String_Literal
629                 and then
630                  Nkind (Expression (Arg)) /= N_Operator_Symbol
631               then
632                  Error_Msg_N
633                    ("argument for pragma% must be string literal", Arg);
634                  raise Error_Resync;
635               end if;
636
637               Str := Strval (Expression (Arg));
638
639               --  Check string has no wide chars
640
641               for J in 1 .. String_Length (Str) loop
642                  if Get_String_Char (Str, J) > 255 then
643                     Error_Msg
644                       ("wide character not allowed in pattern for pragma%",
645                        Sloc (Expression (Arg2)) + Text_Ptr (J) - 1);
646                  end if;
647               end loop;
648
649               --  Acquire string
650
651               String_To_Name_Buffer (Str);
652               return new String'(Name_Buffer (1 .. Name_Len));
653            end Get_String_Argument;
654
655            --------------------
656            -- Process_Casing --
657            --------------------
658
659            procedure Process_Casing (Arg : Node_Id) is
660               Expr : constant Node_Id := Expression (Arg);
661
662            begin
663               Check_Required_Identifier (Arg, Name_Casing);
664
665               if Nkind (Expr) = N_Identifier then
666                  if Chars (Expr) = Name_Lowercase then
667                     Cas := All_Lower_Case;
668                     return;
669                  elsif Chars (Expr) = Name_Uppercase then
670                     Cas := All_Upper_Case;
671                     return;
672                  elsif Chars (Expr) = Name_Mixedcase then
673                     Cas := Mixed_Case;
674                     return;
675                  end if;
676               end if;
677
678               Error_Msg_N
679                 ("Casing argument for pragma% must be " &
680                  "one of Mixedcase, Lowercase, Uppercase",
681                  Arg);
682            end Process_Casing;
683
684            -----------------------------
685            -- Process_Dot_Replacement --
686            -----------------------------
687
688            procedure Process_Dot_Replacement (Arg : Node_Id) is
689            begin
690               Check_Required_Identifier (Arg, Name_Dot_Replacement);
691               Dot := Get_String_Argument (Arg);
692            end Process_Dot_Replacement;
693
694         --  Start of processing for Source_File_Name and
695         --  Source_File_Name_Project pragmas.
696
697         begin
698            if Prag_Id = Pragma_Source_File_Name then
699               if Project_File_In_Use = In_Use then
700                  Error_Msg
701                    ("pragma Source_File_Name cannot be used " &
702                     "with a project file", Pragma_Sloc);
703
704               else
705                  Project_File_In_Use := Not_In_Use;
706               end if;
707
708            else
709               if Project_File_In_Use = Not_In_Use then
710                  Error_Msg
711                    ("pragma Source_File_Name_Project should only be used " &
712                     "with a project file", Pragma_Sloc);
713               else
714                  Project_File_In_Use := In_Use;
715               end if;
716            end if;
717
718            --  We permit from 1 to 3 arguments
719
720            if Arg_Count not in 1 .. 3 then
721               Check_Arg_Count (1);
722            end if;
723
724            Expr1 := Expression (Arg1);
725
726            --  If first argument is identifier or selected component, then
727            --  we have the specific file case of the Source_File_Name pragma,
728            --  and the first argument is a unit name.
729
730            if Nkind (Expr1) = N_Identifier
731              or else
732                (Nkind (Expr1) = N_Selected_Component
733                  and then
734                 Nkind (Selector_Name (Expr1)) = N_Identifier)
735            then
736               if Nkind (Expr1) = N_Identifier
737                 and then Chars (Expr1) = Name_System
738               then
739                  Error_Msg_N
740                    ("pragma Source_File_Name may not be used for System",
741                     Arg1);
742                  return Error;
743               end if;
744
745               --  Process index argument if present
746
747               if Arg_Count = 3 then
748                  Expr := Expression (Arg3);
749
750                  if Nkind (Expr) /= N_Integer_Literal
751                    or else not UI_Is_In_Int_Range (Intval (Expr))
752                    or else Intval (Expr) > 999
753                    or else Intval (Expr) <= 0
754                  then
755                     Error_Msg
756                       ("pragma% index must be integer literal" &
757                        " in range 1 .. 999", Sloc (Expr));
758                     raise Error_Resync;
759                  else
760                     Index := UI_To_Int (Intval (Expr));
761                  end if;
762
763               --  No index argument present
764
765               else
766                  Check_Arg_Count (2);
767                  Index := 0;
768               end if;
769
770               Check_Optional_Identifier (Arg1, Name_Unit_Name);
771               Unam := Get_Unit_Name (Expr1);
772
773               Check_Arg_Is_String_Literal (Arg2);
774
775               if Chars (Arg2) = Name_Spec_File_Name then
776                  Set_File_Name
777                    (Get_Spec_Name (Unam), Get_Fname (Arg2), Index);
778
779               elsif Chars (Arg2) = Name_Body_File_Name then
780                  Set_File_Name
781                    (Unam, Get_Fname (Arg2), Index);
782
783               else
784                  Error_Msg_N
785                    ("pragma% argument has incorrect identifier", Arg2);
786                  return Pragma_Node;
787               end if;
788
789            --  If the first argument is not an identifier, then we must have
790            --  the pattern form of the pragma, and the first argument must be
791            --  the pattern string with an appropriate name.
792
793            else
794               if Chars (Arg1) = Name_Spec_File_Name then
795                  Typ := 's';
796
797               elsif Chars (Arg1) = Name_Body_File_Name then
798                  Typ := 'b';
799
800               elsif Chars (Arg1) = Name_Subunit_File_Name then
801                  Typ := 'u';
802
803               elsif Chars (Arg1) = Name_Unit_Name then
804                  Error_Msg_N
805                    ("Unit_Name parameter for pragma% must be an identifier",
806                     Arg1);
807                  raise Error_Resync;
808
809               else
810                  Error_Msg_N
811                    ("pragma% argument has incorrect identifier", Arg1);
812                  raise Error_Resync;
813               end if;
814
815               Pat := Get_String_Argument (Arg1);
816
817               --  Check pattern has exactly one asterisk
818
819               Nast := 0;
820               for J in Pat'Range loop
821                  if Pat (J) = '*' then
822                     Nast := Nast + 1;
823                  end if;
824               end loop;
825
826               if Nast /= 1 then
827                  Error_Msg_N
828                    ("file name pattern must have exactly one * character",
829                     Arg1);
830                  return Pragma_Node;
831               end if;
832
833               --  Set defaults for Casing and Dot_Separator parameters
834
835               Cas := All_Lower_Case;
836               Dot := new String'(".");
837
838               --  Process second and third arguments if present
839
840               if Arg_Count > 1 then
841                  if Chars (Arg2) = Name_Casing then
842                     Process_Casing (Arg2);
843
844                     if Arg_Count = 3 then
845                        Process_Dot_Replacement (Arg3);
846                     end if;
847
848                  else
849                     Process_Dot_Replacement (Arg2);
850
851                     if Arg_Count = 3 then
852                        Process_Casing (Arg3);
853                     end if;
854                  end if;
855               end if;
856
857               Set_File_Name_Pattern (Pat, Typ, Dot, Cas);
858            end if;
859         end Source_File_Name;
860
861      -----------------------------
862      -- Source_Reference (GNAT) --
863      -----------------------------
864
865      --  pragma Source_Reference
866      --    (INTEGER_LITERAL [, STRING_LITERAL] );
867
868      --  Processing for this pragma must be done at parse time, since error
869      --  messages needing the proper line numbers can be generated in parse
870      --  only mode with semantic checking turned off, and indeed we usually
871      --  turn off semantic checking anyway if any parse errors are found.
872
873      when Pragma_Source_Reference => Source_Reference : declare
874         Fname : File_Name_Type;
875
876      begin
877         if Arg_Count /= 1 then
878            Check_Arg_Count (2);
879            Check_No_Identifier (Arg2);
880         end if;
881
882         --  Check that this is first line of file. We skip this test if
883         --  we are in syntax check only mode, since we may be dealing with
884         --  multiple compilation units.
885
886         if Get_Physical_Line_Number (Pragma_Sloc) /= 1
887           and then Num_SRef_Pragmas (Current_Source_File) = 0
888           and then Operating_Mode /= Check_Syntax
889         then
890            Error_Msg -- CODEFIX
891              ("first % pragma must be first line of file", Pragma_Sloc);
892            raise Error_Resync;
893         end if;
894
895         Check_No_Identifier (Arg1);
896
897         if Arg_Count = 1 then
898            if Num_SRef_Pragmas (Current_Source_File) = 0 then
899               Error_Msg
900                 ("file name required for first % pragma in file",
901                  Pragma_Sloc);
902               raise Error_Resync;
903            else
904               Fname := No_File;
905            end if;
906
907         --  File name present
908
909         else
910            Check_Arg_Is_String_Literal (Arg2);
911            String_To_Name_Buffer (Strval (Expression (Arg2)));
912            Fname := Name_Find;
913
914            if Num_SRef_Pragmas (Current_Source_File) > 0 then
915               if Fname /= Full_Ref_Name (Current_Source_File) then
916                  Error_Msg
917                    ("file name must be same in all % pragmas", Pragma_Sloc);
918                  raise Error_Resync;
919               end if;
920            end if;
921         end if;
922
923         if Nkind (Expression (Arg1)) /= N_Integer_Literal then
924            Error_Msg
925              ("argument for pragma% must be integer literal",
926                Sloc (Expression (Arg1)));
927            raise Error_Resync;
928
929         --  OK, this source reference pragma is effective, however, we
930         --  ignore it if it is not in the first unit in the multiple unit
931         --  case. This is because the only purpose in this case is to
932         --  provide source pragmas for subsequent use by gnatchop.
933
934         else
935            if Num_Library_Units = 1 then
936               Register_Source_Ref_Pragma
937                 (Fname,
938                  Strip_Directory (Fname),
939                  UI_To_Int (Intval (Expression (Arg1))),
940                  Get_Physical_Line_Number (Pragma_Sloc) + 1);
941            end if;
942         end if;
943      end Source_Reference;
944
945      -------------------------
946      -- Style_Checks (GNAT) --
947      -------------------------
948
949      --  pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
950
951      --  This is processed by the parser since some of the style
952      --  checks take place during source scanning and parsing.
953
954      when Pragma_Style_Checks => Style_Checks : declare
955         A  : Node_Id;
956         S  : String_Id;
957         C  : Char_Code;
958         OK : Boolean := True;
959
960      begin
961         --  Two argument case is only for semantics
962
963         if Arg_Count = 2 then
964            null;
965
966         else
967            Check_Arg_Count (1);
968            Check_No_Identifier (Arg1);
969            A := Expression (Arg1);
970
971            if Nkind (A) = N_String_Literal then
972               S := Strval (A);
973
974               declare
975                  Slen    : constant Natural := Natural (String_Length (S));
976                  Options : String (1 .. Slen);
977                  J       : Natural;
978                  Ptr     : Natural;
979
980               begin
981                  J := 1;
982                  loop
983                     C := Get_String_Char (S, Int (J));
984
985                     if not In_Character_Range (C) then
986                        OK := False;
987                        Ptr := J;
988                        exit;
989
990                     else
991                        Options (J) := Get_Character (C);
992                     end if;
993
994                     if J = Slen then
995                        if not Ignore_Style_Checks_Pragmas then
996                           Set_Style_Check_Options (Options, OK, Ptr);
997                        end if;
998
999                        exit;
1000
1001                     else
1002                        J := J + 1;
1003                     end if;
1004                  end loop;
1005
1006                  if not OK then
1007                     Error_Msg
1008                       (Style_Msg_Buf (1 .. Style_Msg_Len),
1009                        Sloc (Expression (Arg1)) + Source_Ptr (Ptr));
1010                     raise Error_Resync;
1011                  end if;
1012               end;
1013
1014            elsif Nkind (A) /= N_Identifier then
1015               OK := False;
1016
1017            elsif Chars (A) = Name_All_Checks then
1018               if not Ignore_Style_Checks_Pragmas then
1019                  if GNAT_Mode then
1020                     Stylesw.Set_GNAT_Style_Check_Options;
1021                  else
1022                     Stylesw.Set_Default_Style_Check_Options;
1023                  end if;
1024               end if;
1025
1026            elsif Chars (A) = Name_On then
1027               if not Ignore_Style_Checks_Pragmas then
1028                  Style_Check := True;
1029               end if;
1030
1031            elsif Chars (A) = Name_Off then
1032               if not Ignore_Style_Checks_Pragmas then
1033                  Style_Check := False;
1034               end if;
1035
1036            else
1037               OK := False;
1038            end if;
1039
1040            if not OK then
1041               Error_Msg ("incorrect argument for pragma%", Sloc (A));
1042               raise Error_Resync;
1043            end if;
1044         end if;
1045      end Style_Checks;
1046
1047      -------------------------
1048      -- Suppress_All (GNAT) --
1049      -------------------------
1050
1051      --  pragma Suppress_All
1052
1053      --  This is a rather odd pragma, because other compilers allow it in
1054      --  strange places. DEC allows it at the end of units, and Rational
1055      --  allows it as a program unit pragma, when it would be more natural
1056      --  if it were a configuration pragma.
1057
1058      --  Since the reason we provide this pragma is for compatibility with
1059      --  these other compilers, we want to accommodate these strange placement
1060      --  rules, and the easiest thing is simply to allow it anywhere in a
1061      --  unit. If this pragma appears anywhere within a unit, then the effect
1062      --  is as though a pragma Suppress (All_Checks) had appeared as the first
1063      --  line of the current file, i.e. as the first configuration pragma in
1064      --  the current unit.
1065
1066      --  To get this effect, we set the flag Has_Pragma_Suppress_All in the
1067      --  compilation unit node for the current source file then in the last
1068      --  stage of parsing a file, if this flag is set, we materialize the
1069      --  Suppress (All_Checks) pragma, marked as not coming from Source.
1070
1071      when Pragma_Suppress_All =>
1072         Set_Has_Pragma_Suppress_All (Cunit (Current_Source_Unit));
1073
1074      ---------------------
1075      -- Warnings (GNAT) --
1076      ---------------------
1077
1078      --  pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
1079
1080      --  DETAILS ::= On | Off
1081      --  DETAILS ::= On | Off, local_NAME
1082      --  DETAILS ::= static_string_EXPRESSION
1083      --  DETAILS ::= On | Off, static_string_EXPRESSION
1084
1085      --  TOOL_NAME ::= GNAT | GNATProve
1086
1087      --  REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL}
1088
1089      --  Note: If the first argument matches an allowed tool name, it is
1090      --  always considered to be a tool name, even if there is a string
1091      --  variable of that name.
1092
1093      --  The one argument ON/OFF case is processed by the parser, since it may
1094      --  control parser warnings as well as semantic warnings, and in any case
1095      --  we want to be absolutely sure that the range in the warnings table is
1096      --  set well before any semantic analysis is performed. Note that we
1097      --  ignore this pragma if debug flag -gnatd.i is set.
1098
1099      --  Also note that the "one argument" case may have two or three
1100      --  arguments if the first one is a tool name, and/or the last one is a
1101      --  reason argument.
1102
1103      when Pragma_Warnings => Warnings : declare
1104         function First_Arg_Is_Matching_Tool_Name return Boolean;
1105         --  Returns True if the first argument is a tool name matching the
1106         --  current tool being run.
1107
1108         function Last_Arg return Node_Id;
1109         --  Returns the last argument
1110
1111         function Last_Arg_Is_Reason return Boolean;
1112         --  Returns True if the last argument is a reason argument
1113
1114         function Get_Reason return String_Id;
1115         --  Analyzes Reason argument and returns corresponding String_Id
1116         --  value, or null if there is no Reason argument, or if the
1117         --  argument is not of the required form.
1118
1119         -------------------------------------
1120         -- First_Arg_Is_Matching_Tool_Name --
1121         -------------------------------------
1122
1123         function First_Arg_Is_Matching_Tool_Name return Boolean is
1124         begin
1125            return Nkind (Arg1) = N_Identifier
1126
1127              --  Return True if the tool name is GNAT, and we're not in
1128              --  GNATprove or CodePeer or ASIS mode...
1129
1130              and then ((Chars (Arg1) = Name_Gnat
1131                          and then not
1132                            (CodePeer_Mode or GNATprove_Mode or ASIS_Mode))
1133
1134              --  or if the tool name is GNATprove, and we're in GNATprove
1135              --  mode.
1136
1137                        or else
1138                        (Chars (Arg1) = Name_Gnatprove
1139                          and then GNATprove_Mode));
1140         end First_Arg_Is_Matching_Tool_Name;
1141
1142         ----------------
1143         -- Get_Reason --
1144         ----------------
1145
1146         function Get_Reason return String_Id is
1147            Arg : constant Node_Id := Last_Arg;
1148         begin
1149            if Last_Arg_Is_Reason then
1150               Start_String;
1151               Get_Reason_String (Expression (Arg));
1152               return End_String;
1153            else
1154               return Null_String_Id;
1155            end if;
1156         end Get_Reason;
1157
1158         --------------
1159         -- Last_Arg --
1160         --------------
1161
1162         function Last_Arg return Node_Id is
1163               Last_Arg : Node_Id;
1164
1165         begin
1166            if Arg_Count = 1 then
1167               Last_Arg := Arg1;
1168            elsif Arg_Count = 2 then
1169               Last_Arg := Arg2;
1170            elsif Arg_Count = 3 then
1171               Last_Arg := Arg3;
1172            elsif Arg_Count = 4 then
1173               Last_Arg := Next (Arg3);
1174
1175            --  Illegal case, error issued in semantic analysis
1176
1177            else
1178               Last_Arg := Empty;
1179            end if;
1180
1181            return Last_Arg;
1182         end Last_Arg;
1183
1184         ------------------------
1185         -- Last_Arg_Is_Reason --
1186         ------------------------
1187
1188         function Last_Arg_Is_Reason return Boolean is
1189            Arg : constant Node_Id := Last_Arg;
1190         begin
1191            return Nkind (Arg) in N_Has_Chars
1192              and then Chars (Arg) = Name_Reason;
1193         end Last_Arg_Is_Reason;
1194
1195         The_Arg : Node_Id;  --  On/Off argument
1196         Argx    : Node_Id;
1197
1198      --  Start of processing for Warnings
1199
1200      begin
1201         if not Debug_Flag_Dot_I
1202           and then (Arg_Count = 1
1203                       or else (Arg_Count = 2
1204                                  and then (First_Arg_Is_Matching_Tool_Name
1205                                              or else
1206                                            Last_Arg_Is_Reason))
1207                       or else (Arg_Count = 3
1208                                  and then First_Arg_Is_Matching_Tool_Name
1209                                  and then Last_Arg_Is_Reason))
1210         then
1211            if First_Arg_Is_Matching_Tool_Name then
1212               The_Arg := Arg2;
1213            else
1214               The_Arg := Arg1;
1215            end if;
1216
1217            Check_No_Identifier (The_Arg);
1218            Argx := Expression (The_Arg);
1219
1220            if Nkind (Argx) = N_Identifier then
1221               if Chars (Argx) = Name_On then
1222                  Set_Warnings_Mode_On (Pragma_Sloc);
1223               elsif Chars (Argx) = Name_Off then
1224                  Set_Warnings_Mode_Off (Pragma_Sloc, Get_Reason);
1225               end if;
1226            end if;
1227         end if;
1228      end Warnings;
1229
1230      -----------------------------
1231      -- Wide_Character_Encoding --
1232      -----------------------------
1233
1234      --  pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
1235
1236      --  This is processed by the parser, since the scanner is affected
1237
1238      when Pragma_Wide_Character_Encoding => Wide_Character_Encoding : declare
1239         A : Node_Id;
1240
1241      begin
1242         Check_Arg_Count (1);
1243         Check_No_Identifier (Arg1);
1244         A := Expression (Arg1);
1245
1246         if Nkind (A) = N_Identifier then
1247            Get_Name_String (Chars (A));
1248            Wide_Character_Encoding_Method :=
1249              Get_WC_Encoding_Method (Name_Buffer (1 .. Name_Len));
1250
1251         elsif Nkind (A) = N_Character_Literal then
1252            declare
1253               R : constant Char_Code :=
1254                     Char_Code (UI_To_Int (Char_Literal_Value (A)));
1255            begin
1256               if In_Character_Range (R) then
1257                  Wide_Character_Encoding_Method :=
1258                    Get_WC_Encoding_Method (Get_Character (R));
1259               else
1260                  raise Constraint_Error;
1261               end if;
1262            end;
1263
1264         else
1265            raise Constraint_Error;
1266         end if;
1267
1268         Upper_Half_Encoding :=
1269           Wide_Character_Encoding_Method in
1270             WC_Upper_Half_Encoding_Method;
1271
1272      exception
1273         when Constraint_Error =>
1274            Error_Msg_N ("invalid argument for pragma%", Arg1);
1275      end Wide_Character_Encoding;
1276
1277      -----------------------
1278      -- All Other Pragmas --
1279      -----------------------
1280
1281      --  For all other pragmas, checking and processing is handled
1282      --  entirely in Sem_Prag, and no further checking is done by Par.
1283
1284      when Pragma_Abort_Defer                    |
1285           Pragma_Abstract_State                 |
1286           Pragma_Async_Readers                  |
1287           Pragma_Async_Writers                  |
1288           Pragma_Assertion_Policy               |
1289           Pragma_Assume                         |
1290           Pragma_Assume_No_Invalid_Values       |
1291           Pragma_All_Calls_Remote               |
1292           Pragma_Allow_Integer_Address          |
1293           Pragma_Annotate                       |
1294           Pragma_Assert                         |
1295           Pragma_Assert_And_Cut                 |
1296           Pragma_Asynchronous                   |
1297           Pragma_Atomic                         |
1298           Pragma_Atomic_Components              |
1299           Pragma_Attach_Handler                 |
1300           Pragma_Attribute_Definition           |
1301           Pragma_Check                          |
1302           Pragma_Check_Float_Overflow           |
1303           Pragma_Check_Name                     |
1304           Pragma_Check_Policy                   |
1305           Pragma_Compile_Time_Error             |
1306           Pragma_Compile_Time_Warning           |
1307           Pragma_Constant_After_Elaboration     |
1308           Pragma_Contract_Cases                 |
1309           Pragma_Convention_Identifier          |
1310           Pragma_CPP_Class                      |
1311           Pragma_CPP_Constructor                |
1312           Pragma_CPP_Virtual                    |
1313           Pragma_CPP_Vtable                     |
1314           Pragma_CPU                            |
1315           Pragma_C_Pass_By_Copy                 |
1316           Pragma_Comment                        |
1317           Pragma_Common_Object                  |
1318           Pragma_Complete_Representation        |
1319           Pragma_Complex_Representation         |
1320           Pragma_Component_Alignment            |
1321           Pragma_Controlled                     |
1322           Pragma_Convention                     |
1323           Pragma_Debug_Policy                   |
1324           Pragma_Depends                        |
1325           Pragma_Detect_Blocking                |
1326           Pragma_Default_Initial_Condition      |
1327           Pragma_Default_Scalar_Storage_Order   |
1328           Pragma_Default_Storage_Pool           |
1329           Pragma_Disable_Atomic_Synchronization |
1330           Pragma_Discard_Names                  |
1331           Pragma_Dispatching_Domain             |
1332           Pragma_Effective_Reads                |
1333           Pragma_Effective_Writes               |
1334           Pragma_Eliminate                      |
1335           Pragma_Elaborate                      |
1336           Pragma_Elaborate_All                  |
1337           Pragma_Elaborate_Body                 |
1338           Pragma_Elaboration_Checks             |
1339           Pragma_Enable_Atomic_Synchronization  |
1340           Pragma_Export                         |
1341           Pragma_Export_Function                |
1342           Pragma_Export_Object                  |
1343           Pragma_Export_Procedure               |
1344           Pragma_Export_Value                   |
1345           Pragma_Export_Valued_Procedure        |
1346           Pragma_Extend_System                  |
1347           Pragma_Extensions_Visible             |
1348           Pragma_External                       |
1349           Pragma_External_Name_Casing           |
1350           Pragma_Favor_Top_Level                |
1351           Pragma_Fast_Math                      |
1352           Pragma_Finalize_Storage_Only          |
1353           Pragma_Ghost                          |
1354           Pragma_Global                         |
1355           Pragma_Ident                          |
1356           Pragma_Implementation_Defined         |
1357           Pragma_Implemented                    |
1358           Pragma_Implicit_Packing               |
1359           Pragma_Import                         |
1360           Pragma_Import_Function                |
1361           Pragma_Import_Object                  |
1362           Pragma_Import_Procedure               |
1363           Pragma_Import_Valued_Procedure        |
1364           Pragma_Independent                    |
1365           Pragma_Independent_Components         |
1366           Pragma_Initial_Condition              |
1367           Pragma_Initialize_Scalars             |
1368           Pragma_Initializes                    |
1369           Pragma_Inline                         |
1370           Pragma_Inline_Always                  |
1371           Pragma_Inline_Generic                 |
1372           Pragma_Inspection_Point               |
1373           Pragma_Interface                      |
1374           Pragma_Interface_Name                 |
1375           Pragma_Interrupt_Handler              |
1376           Pragma_Interrupt_State                |
1377           Pragma_Interrupt_Priority             |
1378           Pragma_Invariant                      |
1379           Pragma_Keep_Names                     |
1380           Pragma_License                        |
1381           Pragma_Link_With                      |
1382           Pragma_Linker_Alias                   |
1383           Pragma_Linker_Constructor             |
1384           Pragma_Linker_Destructor              |
1385           Pragma_Linker_Options                 |
1386           Pragma_Linker_Section                 |
1387           Pragma_Lock_Free                      |
1388           Pragma_Locking_Policy                 |
1389           Pragma_Loop_Invariant                 |
1390           Pragma_Loop_Optimize                  |
1391           Pragma_Loop_Variant                   |
1392           Pragma_Machine_Attribute              |
1393           Pragma_Main                           |
1394           Pragma_Main_Storage                   |
1395           Pragma_Memory_Size                    |
1396           Pragma_No_Body                        |
1397           Pragma_No_Elaboration_Code_All        |
1398           Pragma_No_Inline                      |
1399           Pragma_No_Return                      |
1400           Pragma_No_Run_Time                    |
1401           Pragma_No_Strict_Aliasing             |
1402           Pragma_No_Tagged_Streams              |
1403           Pragma_Normalize_Scalars              |
1404           Pragma_Obsolescent                    |
1405           Pragma_Ordered                        |
1406           Pragma_Optimize                       |
1407           Pragma_Optimize_Alignment             |
1408           Pragma_Overflow_Mode                  |
1409           Pragma_Overriding_Renamings           |
1410           Pragma_Pack                           |
1411           Pragma_Part_Of                        |
1412           Pragma_Partition_Elaboration_Policy   |
1413           Pragma_Passive                        |
1414           Pragma_Preelaborable_Initialization   |
1415           Pragma_Polling                        |
1416           Pragma_Prefix_Exception_Messages      |
1417           Pragma_Persistent_BSS                 |
1418           Pragma_Post                           |
1419           Pragma_Postcondition                  |
1420           Pragma_Post_Class                     |
1421           Pragma_Pre                            |
1422           Pragma_Precondition                   |
1423           Pragma_Predicate                      |
1424           Pragma_Predicate_Failure              |
1425           Pragma_Preelaborate                   |
1426           Pragma_Pre_Class                      |
1427           Pragma_Priority                       |
1428           Pragma_Priority_Specific_Dispatching  |
1429           Pragma_Profile                        |
1430           Pragma_Profile_Warnings               |
1431           Pragma_Propagate_Exceptions           |
1432           Pragma_Provide_Shift_Operators        |
1433           Pragma_Psect_Object                   |
1434           Pragma_Pure                           |
1435           Pragma_Pure_Function                  |
1436           Pragma_Queuing_Policy                 |
1437           Pragma_Refined_Depends                |
1438           Pragma_Refined_Global                 |
1439           Pragma_Refined_Post                   |
1440           Pragma_Refined_State                  |
1441           Pragma_Relative_Deadline              |
1442           Pragma_Remote_Access_Type             |
1443           Pragma_Remote_Call_Interface          |
1444           Pragma_Remote_Types                   |
1445           Pragma_Restricted_Run_Time            |
1446           Pragma_Rational                       |
1447           Pragma_Ravenscar                      |
1448           Pragma_Reviewable                     |
1449           Pragma_Share_Generic                  |
1450           Pragma_Shared                         |
1451           Pragma_Shared_Passive                 |
1452           Pragma_Short_Circuit_And_Or           |
1453           Pragma_Short_Descriptors              |
1454           Pragma_Simple_Storage_Pool_Type       |
1455           Pragma_SPARK_Mode                     |
1456           Pragma_Storage_Size                   |
1457           Pragma_Storage_Unit                   |
1458           Pragma_Static_Elaboration_Desired     |
1459           Pragma_Stream_Convert                 |
1460           Pragma_Subtitle                       |
1461           Pragma_Suppress                       |
1462           Pragma_Suppress_Debug_Info            |
1463           Pragma_Suppress_Exception_Locations   |
1464           Pragma_Suppress_Initialization        |
1465           Pragma_System_Name                    |
1466           Pragma_Task_Dispatching_Policy        |
1467           Pragma_Task_Info                      |
1468           Pragma_Task_Name                      |
1469           Pragma_Task_Storage                   |
1470           Pragma_Test_Case                      |
1471           Pragma_Thread_Local_Storage           |
1472           Pragma_Time_Slice                     |
1473           Pragma_Title                          |
1474           Pragma_Type_Invariant                 |
1475           Pragma_Type_Invariant_Class           |
1476           Pragma_Unchecked_Union                |
1477           Pragma_Unevaluated_Use_Of_Old         |
1478           Pragma_Unimplemented_Unit             |
1479           Pragma_Universal_Aliasing             |
1480           Pragma_Universal_Data                 |
1481           Pragma_Unmodified                     |
1482           Pragma_Unreferenced                   |
1483           Pragma_Unreferenced_Objects           |
1484           Pragma_Unreserve_All_Interrupts       |
1485           Pragma_Unsuppress                     |
1486           Pragma_Use_VADS_Size                  |
1487           Pragma_Volatile                       |
1488           Pragma_Volatile_Components            |
1489           Pragma_Volatile_Full_Access           |
1490           Pragma_Volatile_Function              |
1491           Pragma_Warning_As_Error               |
1492           Pragma_Weak_External                  |
1493           Pragma_Validity_Checks                =>
1494         null;
1495
1496      --------------------
1497      -- Unknown_Pragma --
1498      --------------------
1499
1500      --  Should be impossible, since we excluded this case earlier on
1501
1502      when Unknown_Pragma =>
1503         raise Program_Error;
1504
1505   end case;
1506
1507   return Pragma_Node;
1508
1509   --------------------
1510   -- Error Handling --
1511   --------------------
1512
1513exception
1514   when Error_Resync =>
1515      return Error;
1516
1517end Prag;
1518