OSDN Git Service

* sem_prag.adb: Add processing for pragma External.
[pf3gnuchains/gcc-fork.git] / gcc / ada / par-prag.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             P A R . P R A G                              --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                            $Revision$
10 --                                                                          --
11 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 --  Generally the parser checks the basic syntax of pragmas, but does not
30 --  do specialized syntax checks for individual pragmas, these are deferred
31 --  to semantic analysis time (see unit Sem_Prag). There are some pragmas
32 --  which require recognition and either partial or complete processing
33 --  during parsing, and this unit performs this required processing.
34
35 with Fname.UF; use Fname.UF;
36 with Osint;    use Osint;
37 with Stringt;  use Stringt;
38 with Stylesw;  use Stylesw;
39 with Uintp;    use Uintp;
40 with Uname;    use Uname;
41
42 separate (Par)
43
44 function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
45    Pragma_Name : constant Name_Id    := Chars (Pragma_Node);
46    Pragma_Sloc : constant Source_Ptr := Sloc (Pragma_Node);
47    Arg_Count   : Nat;
48    Arg_Node    : Node_Id;
49
50    -----------------------
51    -- Local Subprograms --
52    -----------------------
53
54    function Arg1 return Node_Id;
55    function Arg2 return Node_Id;
56    function Arg3 return Node_Id;
57    function Arg4 return Node_Id;
58    --  Obtain specified Pragma_Argument_Association. It is allowable to call
59    --  the routine for the argument one past the last present argument, but
60    --  that is the only case in which a non-present argument can be referenced.
61
62    procedure Check_Arg_Count (Required : Int);
63    --  Check argument count for pragma = Required.
64    --  If not give error and raise Error_Resync.
65
66    procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
67    --  Check the expression of the specified argument to make sure that it
68    --  is a string literal. If not give error and raise Error_Resync.
69
70    procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id);
71    --  Check the expression of the specified argument to make sure that it
72    --  is an identifier which is either ON or OFF, and if not, then issue
73    --  an error message and raise Error_Resync.
74
75    procedure Check_No_Identifier (Arg : Node_Id);
76    --  Checks that the given argument does not have an identifier. If an
77    --  identifier is present, then an error message is issued, and
78    --  Error_Resync is raised.
79
80    procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
81    --  Checks if the given argument has an identifier, and if so, requires
82    --  it to match the given identifier name. If there is a non-matching
83    --  identifier, then an error message is given and Error_Resync raised.
84
85    procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id);
86    --  Same as Check_Optional_Identifier, except that the name is required
87    --  to be present and to match the given Id value.
88
89    ----------
90    -- Arg1 --
91    ----------
92
93    function Arg1 return Node_Id is
94    begin
95       return First (Pragma_Argument_Associations (Pragma_Node));
96    end Arg1;
97
98    ----------
99    -- Arg2 --
100    ----------
101
102    function Arg2 return Node_Id is
103    begin
104       return Next (Arg1);
105    end Arg2;
106
107    ----------
108    -- Arg3 --
109    ----------
110
111    function Arg3 return Node_Id is
112    begin
113       return Next (Arg2);
114    end Arg3;
115
116    ----------
117    -- Arg4 --
118    ----------
119
120    function Arg4 return Node_Id is
121    begin
122       return Next (Arg3);
123    end Arg4;
124
125    ---------------------
126    -- Check_Arg_Count --
127    ---------------------
128
129    procedure Check_Arg_Count (Required : Int) is
130    begin
131       if Arg_Count /= Required then
132          Error_Msg ("wrong number of arguments for pragma%", Pragma_Sloc);
133          raise Error_Resync;
134       end if;
135    end Check_Arg_Count;
136
137    ----------------------------
138    -- Check_Arg_Is_On_Or_Off --
139    ----------------------------
140
141    procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id) is
142       Argx : constant Node_Id := Expression (Arg);
143
144    begin
145       if Nkind (Expression (Arg)) /= N_Identifier
146         or else (Chars (Argx) /= Name_On
147                    and then
148                  Chars (Argx) /= Name_Off)
149       then
150          Error_Msg_Name_2 := Name_On;
151          Error_Msg_Name_3 := Name_Off;
152
153          Error_Msg
154            ("argument for pragma% must be% or%", Sloc (Argx));
155          raise Error_Resync;
156       end if;
157    end Check_Arg_Is_On_Or_Off;
158
159    ---------------------------------
160    -- Check_Arg_Is_String_Literal --
161    ---------------------------------
162
163    procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
164    begin
165       if Nkind (Expression (Arg)) /= N_String_Literal then
166          Error_Msg
167            ("argument for pragma% must be string literal",
168              Sloc (Expression (Arg)));
169          raise Error_Resync;
170       end if;
171    end Check_Arg_Is_String_Literal;
172
173    -------------------------
174    -- Check_No_Identifier --
175    -------------------------
176
177    procedure Check_No_Identifier (Arg : Node_Id) is
178    begin
179       if Chars (Arg) /= No_Name then
180          Error_Msg_N ("pragma% does not permit named arguments", Arg);
181          raise Error_Resync;
182       end if;
183    end Check_No_Identifier;
184
185    -------------------------------
186    -- Check_Optional_Identifier --
187    -------------------------------
188
189    procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
190    begin
191       if Present (Arg) and then Chars (Arg) /= No_Name then
192          if Chars (Arg) /= Id then
193             Error_Msg_Name_2 := Id;
194             Error_Msg_N ("pragma% argument expects identifier%", Arg);
195          end if;
196       end if;
197    end Check_Optional_Identifier;
198
199    -------------------------------
200    -- Check_Required_Identifier --
201    -------------------------------
202
203    procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id) is
204    begin
205       if Chars (Arg) /= Id then
206          Error_Msg_Name_2 := Id;
207          Error_Msg_N ("pragma% argument must have identifier%", Arg);
208       end if;
209    end Check_Required_Identifier;
210
211    ----------
212    -- Prag --
213    ----------
214
215 begin
216    Error_Msg_Name_1 := Pragma_Name;
217
218    --  Count number of arguments. This loop also checks if any of the arguments
219    --  are Error, indicating a syntax error as they were parsed. If so, we
220    --  simply return, because we get into trouble with cascaded errors if we
221    --  try to perform our error checks on junk arguments.
222
223    Arg_Count := 0;
224
225    if Present (Pragma_Argument_Associations (Pragma_Node)) then
226       Arg_Node := Arg1;
227
228       while Arg_Node /= Empty loop
229          Arg_Count := Arg_Count + 1;
230
231          if Expression (Arg_Node) = Error then
232             return Error;
233          end if;
234
235          Next (Arg_Node);
236       end loop;
237    end if;
238
239    --  Remaining processing is pragma dependent
240
241    case Get_Pragma_Id (Pragma_Name) is
242
243       ------------
244       -- Ada_83 --
245       ------------
246
247       --  This pragma must be processed at parse time, since we want to set
248       --  the Ada 83 and Ada 95 switches properly at parse time to recognize
249       --  Ada 83 syntax or Ada 95 syntax as appropriate.
250
251       when Pragma_Ada_83 =>
252          Ada_83 := True;
253          Ada_95 := False;
254
255       ------------
256       -- Ada_95 --
257       ------------
258
259       --  This pragma must be processed at parse time, since we want to set
260       --  the Ada 83 and Ada_95 switches properly at parse time to recognize
261       --  Ada 83 syntax or Ada 95 syntax as appropriate.
262
263       when Pragma_Ada_95 =>
264          Ada_83 := False;
265          Ada_95 := True;
266
267       -----------
268       -- Debug --
269       -----------
270
271       --  pragma Debug (PROCEDURE_CALL_STATEMENT);
272
273       --  This has to be processed by the parser because of the very peculiar
274       --  form of the second parameter, which is syntactically from a formal
275       --  point of view a function call (since it must be an expression), but
276       --  semantically we treat it as a procedure call (which has exactly the
277       --  same syntactic form, so that's why we can get away with this!)
278
279       when Pragma_Debug =>
280          Check_Arg_Count (1);
281          Check_No_Identifier (Arg1);
282
283          declare
284             Expr : constant Node_Id := New_Copy (Expression (Arg1));
285
286          begin
287             if Nkind (Expr) /= N_Indexed_Component
288               and then Nkind (Expr) /= N_Function_Call
289               and then Nkind (Expr) /= N_Identifier
290               and then Nkind (Expr) /= N_Selected_Component
291             then
292                Error_Msg
293                  ("argument of pragma% is not procedure call", Sloc (Expr));
294                raise Error_Resync;
295             else
296                Set_Debug_Statement
297                  (Pragma_Node, P_Statement_Name (Expr));
298             end if;
299          end;
300
301       -------------------------------
302       -- Extensions_Allowed (GNAT) --
303       -------------------------------
304
305       --  pragma Extensions_Allowed (Off | On)
306
307       --  The processing for pragma Extensions_Allowed must be done at
308       --  parse time, since extensions mode may affect what is accepted.
309
310       when Pragma_Extensions_Allowed =>
311          Check_Arg_Count (1);
312          Check_No_Identifier (Arg1);
313          Check_Arg_Is_On_Or_Off (Arg1);
314          Opt.Extensions_Allowed := (Chars (Expression (Arg1)) = Name_On);
315
316       ----------------
317       -- List (2.8) --
318       ----------------
319
320       --  pragma List (Off | On)
321
322       --  The processing for pragma List must be done at parse time,
323       --  since a listing can be generated in parse only mode.
324
325       when Pragma_List =>
326          Check_Arg_Count (1);
327          Check_No_Identifier (Arg1);
328          Check_Arg_Is_On_Or_Off (Arg1);
329
330          --  We unconditionally make a List_On entry for the pragma, so that
331          --  in the List (Off) case, the pragma will print even in a region
332          --  of code with listing turned off (this is required!)
333
334          List_Pragmas.Increment_Last;
335          List_Pragmas.Table (List_Pragmas.Last) :=
336            (Ptyp => List_On, Ploc => Sloc (Pragma_Node));
337
338          --  Now generate the list off entry for pragma List (Off)
339
340          if Chars (Expression (Arg1)) = Name_Off then
341             List_Pragmas.Increment_Last;
342             List_Pragmas.Table (List_Pragmas.Last) :=
343               (Ptyp => List_Off, Ploc => Semi);
344          end if;
345
346       ----------------
347       -- Page (2.8) --
348       ----------------
349
350       --  pragma Page;
351
352       --  Processing for this pragma must be done at parse time, since a
353       --  listing can be generated in parse only mode with semantics off.
354
355       when Pragma_Page =>
356          Check_Arg_Count (0);
357          List_Pragmas.Increment_Last;
358          List_Pragmas.Table (List_Pragmas.Last) := (Page, Semi);
359
360       -----------------------------
361       -- Source_File_Name (GNAT) --
362       -----------------------------
363
364       --  There are five forms of this pragma:
365
366       --  pragma Source_File_Name (
367       --    [UNIT_NAME      =>] unit_NAME,
368       --     BODY_FILE_NAME =>  STRING_LITERAL);
369
370       --  pragma Source_File_Name (
371       --    [UNIT_NAME      =>] unit_NAME,
372       --     SPEC_FILE_NAME =>  STRING_LITERAL);
373
374       --  pragma Source_File_Name (
375       --     BODY_FILE_NAME  => STRING_LITERAL
376       --  [, DOT_REPLACEMENT => STRING_LITERAL]
377       --  [, CASING          => CASING_SPEC]);
378
379       --  pragma Source_File_Name (
380       --     SPEC_FILE_NAME  => STRING_LITERAL
381       --  [, DOT_REPLACEMENT => STRING_LITERAL]
382       --  [, CASING          => CASING_SPEC]);
383
384       --  pragma Source_File_Name (
385       --     SUBUNIT_FILE_NAME  => STRING_LITERAL
386       --  [, DOT_REPLACEMENT    => STRING_LITERAL]
387       --  [, CASING             => CASING_SPEC]);
388
389       --  CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
390
391       --  Note: we process this during parsing, since we need to have the
392       --  source file names set well before the semantic analysis starts,
393       --  since we load the spec and with'ed packages before analysis.
394
395       when Pragma_Source_File_Name => Source_File_Name : declare
396          Unam  : Unit_Name_Type;
397          Expr1 : Node_Id;
398          Pat   : String_Ptr;
399          Typ   : Character;
400          Dot   : String_Ptr;
401          Cas   : Casing_Type;
402          Nast  : Nat;
403
404          function Get_Fname (Arg : Node_Id) return Name_Id;
405          --  Process file name from unit name form of pragma
406
407          function Get_String_Argument (Arg : Node_Id) return String_Ptr;
408          --  Process string literal value from argument
409
410          procedure Process_Casing (Arg : Node_Id);
411          --  Process Casing argument of pattern form of pragma
412
413          procedure Process_Dot_Replacement (Arg : Node_Id);
414          --  Process Dot_Replacement argument of patterm form of pragma
415
416          ---------------
417          -- Get_Fname --
418          ---------------
419
420          function Get_Fname (Arg : Node_Id) return Name_Id is
421          begin
422             String_To_Name_Buffer (Strval (Expression (Arg)));
423
424             for J in 1 .. Name_Len loop
425                if Is_Directory_Separator (Name_Buffer (J)) then
426                   Error_Msg
427                     ("directory separator character not allowed",
428                      Sloc (Expression (Arg)) + Source_Ptr (J));
429                end if;
430             end loop;
431
432             return Name_Find;
433          end Get_Fname;
434
435          -------------------------
436          -- Get_String_Argument --
437          -------------------------
438
439          function Get_String_Argument (Arg : Node_Id) return String_Ptr is
440             Str : String_Id;
441
442          begin
443             if Nkind (Expression (Arg)) /= N_String_Literal
444               and then
445                Nkind (Expression (Arg)) /= N_Operator_Symbol
446             then
447                Error_Msg_N
448                  ("argument for pragma% must be string literal", Arg);
449                raise Error_Resync;
450             end if;
451
452             Str := Strval (Expression (Arg));
453
454             --  Check string has no wide chars
455
456             for J in 1 .. String_Length (Str) loop
457                if Get_String_Char (Str, J) > 255 then
458                   Error_Msg
459                     ("wide character not allowed in pattern for pragma%",
460                      Sloc (Expression (Arg2)) + Text_Ptr (J) - 1);
461                end if;
462             end loop;
463
464             --  Acquire string
465
466             String_To_Name_Buffer (Str);
467             return new String'(Name_Buffer (1 .. Name_Len));
468          end Get_String_Argument;
469
470          --------------------
471          -- Process_Casing --
472          --------------------
473
474          procedure Process_Casing (Arg : Node_Id) is
475             Expr : constant Node_Id := Expression (Arg);
476
477          begin
478             Check_Required_Identifier (Arg, Name_Casing);
479
480             if Nkind (Expr) = N_Identifier then
481                if Chars (Expr) = Name_Lowercase then
482                   Cas := All_Lower_Case;
483                   return;
484                elsif Chars (Expr) = Name_Uppercase then
485                   Cas := All_Upper_Case;
486                   return;
487                elsif Chars (Expr) = Name_Mixedcase then
488                   Cas := Mixed_Case;
489                   return;
490                end if;
491             end if;
492
493             Error_Msg_N
494               ("Casing argument for pragma% must be " &
495                "one of Mixedcase, Lowercase, Uppercase",
496                Arg);
497          end Process_Casing;
498
499          -----------------------------
500          -- Process_Dot_Replacement --
501          -----------------------------
502
503          procedure Process_Dot_Replacement (Arg : Node_Id) is
504          begin
505             Check_Required_Identifier (Arg, Name_Dot_Replacement);
506             Dot := Get_String_Argument (Arg);
507          end Process_Dot_Replacement;
508
509       --  Start of processing for Source_File_Name pragma
510
511       begin
512          --  We permit from 1 to 3 arguments
513
514          if Arg_Count not in 1 .. 3 then
515             Check_Arg_Count (1);
516          end if;
517
518          Expr1 := Expression (Arg1);
519
520          --  If first argument is identifier or selected component, then
521          --  we have the specific file case of the Source_File_Name pragma,
522          --  and the first argument is a unit name.
523
524          if Nkind (Expr1) = N_Identifier
525            or else
526              (Nkind (Expr1) = N_Selected_Component
527                and then
528               Nkind (Selector_Name (Expr1)) = N_Identifier)
529          then
530             Check_Arg_Count (2);
531
532             Check_Optional_Identifier (Arg1, Name_Unit_Name);
533             Unam := Get_Unit_Name (Expr1);
534
535             Check_Arg_Is_String_Literal (Arg2);
536
537             if Chars (Arg2) = Name_Spec_File_Name then
538                Set_File_Name (Get_Spec_Name (Unam), Get_Fname (Arg2));
539
540             elsif Chars (Arg2) = Name_Body_File_Name then
541                Set_File_Name (Unam, Get_Fname (Arg2));
542
543             else
544                Error_Msg_N ("pragma% argument has incorrect identifier", Arg2);
545                return Pragma_Node;
546             end if;
547
548          --  If the first argument is not an identifier, then we must have
549          --  the pattern form of the pragma, and the first argument must be
550          --  the pattern string with an appropriate name.
551
552          else
553             if Chars (Arg1) = Name_Spec_File_Name then
554                Typ := 's';
555
556             elsif Chars (Arg1) = Name_Body_File_Name then
557                Typ := 'b';
558
559             elsif Chars (Arg1) = Name_Subunit_File_Name then
560                Typ := 'u';
561
562             elsif Chars (Arg1) = Name_Unit_Name then
563                Error_Msg_N
564                  ("Unit_Name parameter for pragma% must be an identifier",
565                   Arg1);
566                raise Error_Resync;
567
568             else
569                Error_Msg_N ("pragma% argument has incorrect identifier", Arg1);
570                raise Error_Resync;
571             end if;
572
573             Pat := Get_String_Argument (Arg1);
574
575             --  Check pattern has exactly one asterisk
576
577             Nast := 0;
578             for J in Pat'Range loop
579                if Pat (J) = '*' then
580                   Nast := Nast + 1;
581                end if;
582             end loop;
583
584             if Nast /= 1 then
585                Error_Msg_N
586                  ("file name pattern must have exactly one * character",
587                   Arg2);
588                return Pragma_Node;
589             end if;
590
591             --  Set defaults for Casing and Dot_Separator parameters
592
593             Cas := All_Lower_Case;
594
595             Dot := new String'(".");
596
597             --  Process second and third arguments if present
598
599             if Arg_Count > 1 then
600                if Chars (Arg2) = Name_Casing then
601                   Process_Casing (Arg2);
602
603                   if Arg_Count = 3 then
604                      Process_Dot_Replacement (Arg3);
605                   end if;
606
607                else
608                   Process_Dot_Replacement (Arg2);
609
610                   if Arg_Count = 3 then
611                      Process_Casing (Arg3);
612                   end if;
613                end if;
614             end if;
615
616             Set_File_Name_Pattern (Pat, Typ, Dot, Cas);
617          end if;
618       end Source_File_Name;
619
620       -----------------------------
621       -- Source_Reference (GNAT) --
622       -----------------------------
623
624       --  pragma Source_Reference
625       --    (INTEGER_LITERAL [, STRING_LITERAL] );
626
627       --  Processing for this pragma must be done at parse time, since error
628       --  messages needing the proper line numbers can be generated in parse
629       --  only mode with semantic checking turned off, and indeed we usually
630       --  turn off semantic checking anyway if any parse errors are found.
631
632       when Pragma_Source_Reference => Source_Reference : declare
633          Fname : Name_Id;
634
635       begin
636          if Arg_Count /= 1 then
637             Check_Arg_Count (2);
638             Check_No_Identifier (Arg2);
639          end if;
640
641          --  Check that this is first line of file. We skip this test if
642          --  we are in syntax check only mode, since we may be dealing with
643          --  multiple compilation units.
644
645          if Get_Physical_Line_Number (Pragma_Sloc) /= 1
646            and then Num_SRef_Pragmas (Current_Source_File) = 0
647            and then Operating_Mode /= Check_Syntax
648          then
649             Error_Msg
650               ("first % pragma must be first line of file", Pragma_Sloc);
651             raise Error_Resync;
652          end if;
653
654          Check_No_Identifier (Arg1);
655
656          if Arg_Count = 1 then
657             if Num_SRef_Pragmas (Current_Source_File) = 0 then
658                Error_Msg
659                  ("file name required for first % pragma in file",
660                   Pragma_Sloc);
661                raise Error_Resync;
662
663             else
664                Fname := No_Name;
665             end if;
666
667          --  File name present
668
669          else
670             Check_Arg_Is_String_Literal (Arg2);
671             String_To_Name_Buffer (Strval (Expression (Arg2)));
672             Fname := Name_Find;
673
674             if Num_SRef_Pragmas (Current_Source_File) > 0 then
675                if Fname /= Full_Ref_Name (Current_Source_File) then
676                   Error_Msg
677                     ("file name must be same in all % pragmas", Pragma_Sloc);
678                   raise Error_Resync;
679                end if;
680             end if;
681          end if;
682
683          if Nkind (Expression (Arg1)) /= N_Integer_Literal then
684             Error_Msg
685               ("argument for pragma% must be integer literal",
686                 Sloc (Expression (Arg1)));
687             raise Error_Resync;
688
689          --  OK, this source reference pragma is effective, however, we
690          --  ignore it if it is not in the first unit in the multiple unit
691          --  case. This is because the only purpose in this case is to
692          --  provide source pragmas for subsequent use by gnatchop.
693
694          else
695             if Num_Library_Units = 1 then
696                Register_Source_Ref_Pragma
697                  (Fname,
698                   Strip_Directory (Fname),
699                   UI_To_Int (Intval (Expression (Arg1))),
700                   Get_Physical_Line_Number (Pragma_Sloc) + 1);
701             end if;
702          end if;
703       end Source_Reference;
704
705       -------------------------
706       -- Style_Checks (GNAT) --
707       -------------------------
708
709       --  pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
710
711       --  This is processed by the parser since some of the style
712       --  checks take place during source scanning and parsing.
713
714       when Pragma_Style_Checks => Style_Checks : declare
715          A  : Node_Id;
716          S  : String_Id;
717          C  : Char_Code;
718          OK : Boolean := True;
719
720       begin
721          --  Two argument case is only for semantics
722
723          if Arg_Count = 2 then
724             null;
725
726          else
727             Check_Arg_Count (1);
728             Check_No_Identifier (Arg1);
729             A := Expression (Arg1);
730
731             if Nkind (A) = N_String_Literal then
732                S   := Strval (A);
733
734                declare
735                   Slen    : Natural := Natural (String_Length (S));
736                   Options : String (1 .. Slen);
737                   J       : Natural;
738                   Ptr     : Natural;
739
740                begin
741                   J := 1;
742                   loop
743                      C := Get_String_Char (S, Int (J));
744
745                      if not In_Character_Range (C) then
746                         OK := False;
747                         Ptr := J;
748                         exit;
749
750                      else
751                         Options (J) := Get_Character (C);
752                      end if;
753
754                      if J = Slen then
755                         Set_Style_Check_Options (Options, OK, Ptr);
756                         exit;
757
758                      else
759                         J := J + 1;
760                      end if;
761                   end loop;
762
763                   if not OK then
764                      Error_Msg
765                        ("invalid style check option",
766                         Sloc (Expression (Arg1)) + Source_Ptr (Ptr));
767                      raise Error_Resync;
768                   end if;
769                end;
770
771             elsif Nkind (A) /= N_Identifier then
772                OK := False;
773
774             elsif Chars (A) = Name_All_Checks then
775                Stylesw.Set_Default_Style_Check_Options;
776
777             elsif Chars (A) = Name_On then
778                Style_Check := True;
779
780             elsif Chars (A) = Name_Off then
781                Style_Check := False;
782
783             else
784                OK := False;
785             end if;
786
787             if not OK then
788                Error_Msg ("incorrect argument for pragma%", Sloc (A));
789                raise Error_Resync;
790             end if;
791          end if;
792       end Style_Checks;
793
794       ---------------------
795       -- Warnings (GNAT) --
796       ---------------------
797
798       --  pragma Warnings (On | Off, [LOCAL_NAME])
799
800       --  The one argument case is processed by the parser, since it may
801       --  control parser warnings as well as semantic warnings, and in any
802       --  case we want to be absolutely sure that the range in the warnings
803       --  table is set well before any semantic analysis is performed.
804
805       when Pragma_Warnings =>
806          if Arg_Count = 1 then
807             Check_No_Identifier (Arg1);
808             Check_Arg_Is_On_Or_Off (Arg1);
809
810             if Chars (Expression (Arg1)) = Name_On then
811                Set_Warnings_Mode_On (Pragma_Sloc);
812             else
813                Set_Warnings_Mode_Off (Pragma_Sloc);
814             end if;
815          end if;
816
817       -----------------------
818       -- All Other Pragmas --
819       -----------------------
820
821       --  For all other pragmas, checking and processing is handled
822       --  entirely in Sem_Prag, and no further checking is done by Par.
823
824       when Pragma_Abort_Defer              |
825            Pragma_AST_Entry                |
826            Pragma_All_Calls_Remote         |
827            Pragma_Annotate                 |
828            Pragma_Assert                   |
829            Pragma_Asynchronous             |
830            Pragma_Atomic                   |
831            Pragma_Atomic_Components        |
832            Pragma_Attach_Handler           |
833            Pragma_CPP_Class                |
834            Pragma_CPP_Constructor          |
835            Pragma_CPP_Virtual              |
836            Pragma_CPP_Vtable               |
837            Pragma_C_Pass_By_Copy           |
838            Pragma_Comment                  |
839            Pragma_Common_Object            |
840            Pragma_Complex_Representation   |
841            Pragma_Component_Alignment      |
842            Pragma_Controlled               |
843            Pragma_Convention               |
844            Pragma_Discard_Names            |
845            Pragma_Eliminate                |
846            Pragma_Elaborate                |
847            Pragma_Elaborate_All            |
848            Pragma_Elaborate_Body           |
849            Pragma_Elaboration_Checks       |
850            Pragma_Export                   |
851            Pragma_Export_Exception         |
852            Pragma_Export_Function          |
853            Pragma_Export_Object            |
854            Pragma_Export_Procedure         |
855            Pragma_Export_Valued_Procedure  |
856            Pragma_Extend_System            |
857            Pragma_External                 |
858            Pragma_External_Name_Casing     |
859            Pragma_Finalize_Storage_Only    |
860            Pragma_Float_Representation     |
861            Pragma_Ident                    |
862            Pragma_Import                   |
863            Pragma_Import_Exception         |
864            Pragma_Import_Function          |
865            Pragma_Import_Object            |
866            Pragma_Import_Procedure         |
867            Pragma_Import_Valued_Procedure  |
868            Pragma_Initialize_Scalars       |
869            Pragma_Inline                   |
870            Pragma_Inline_Always            |
871            Pragma_Inline_Generic           |
872            Pragma_Inspection_Point         |
873            Pragma_Interface                |
874            Pragma_Interface_Name           |
875            Pragma_Interrupt_Handler        |
876            Pragma_Interrupt_Priority       |
877            Pragma_Java_Constructor         |
878            Pragma_Java_Interface           |
879            Pragma_License                  |
880            Pragma_Link_With                |
881            Pragma_Linker_Alias             |
882            Pragma_Linker_Options           |
883            Pragma_Linker_Section           |
884            Pragma_Locking_Policy           |
885            Pragma_Long_Float               |
886            Pragma_Machine_Attribute        |
887            Pragma_Main                     |
888            Pragma_Main_Storage             |
889            Pragma_Memory_Size              |
890            Pragma_No_Return                |
891            Pragma_No_Run_Time              |
892            Pragma_Normalize_Scalars        |
893            Pragma_Optimize                 |
894            Pragma_Pack                     |
895            Pragma_Passive                  |
896            Pragma_Polling                  |
897            Pragma_Preelaborate             |
898            Pragma_Priority                 |
899            Pragma_Propagate_Exceptions     |
900            Pragma_Psect_Object             |
901            Pragma_Pure                     |
902            Pragma_Pure_Function            |
903            Pragma_Queuing_Policy           |
904            Pragma_Remote_Call_Interface    |
905            Pragma_Remote_Types             |
906            Pragma_Restrictions             |
907            Pragma_Restricted_Run_Time      |
908            Pragma_Ravenscar                |
909            Pragma_Reviewable               |
910            Pragma_Share_Generic            |
911            Pragma_Shared                   |
912            Pragma_Shared_Passive           |
913            Pragma_Storage_Size             |
914            Pragma_Storage_Unit             |
915            Pragma_Stream_Convert           |
916            Pragma_Subtitle                 |
917            Pragma_Suppress                 |
918            Pragma_Suppress_All             |
919            Pragma_Suppress_Debug_Info      |
920            Pragma_Suppress_Initialization  |
921            Pragma_System_Name              |
922            Pragma_Task_Dispatching_Policy  |
923            Pragma_Task_Info                |
924            Pragma_Task_Name                |
925            Pragma_Task_Storage             |
926            Pragma_Time_Slice               |
927            Pragma_Title                    |
928            Pragma_Unchecked_Union          |
929            Pragma_Unimplemented_Unit       |
930            Pragma_Unreserve_All_Interrupts |
931            Pragma_Unsuppress               |
932            Pragma_Use_VADS_Size            |
933            Pragma_Volatile                 |
934            Pragma_Volatile_Components      |
935            Pragma_Weak_External            |
936            Pragma_Validity_Checks          =>
937          null;
938
939    end case;
940
941    return Pragma_Node;
942
943    --------------------
944    -- Error Handling --
945    --------------------
946
947 exception
948    when Error_Resync =>
949       return Error;
950
951 end Prag;