Debian Codegraph @

gcc/ada/par-util.adb

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P A R . U T I L --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2025, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
26 with Csets; use Csets;
27 with Namet.Sp; use Namet.Sp;
28 with Stylesw; use Stylesw;
29 with Uintp; use Uintp;
30 with Warnsw; use Warnsw;
31
32 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
33
34 separate (Par)
35 package body Util is
36
37 ---------------------
38 -- Bad_Spelling_Of --
39 ---------------------
40
41 function Bad_Spelling_Of (T : Token_Type) return Boolean is
42 Tname : constant String := Token_Type'Image (T);
43 -- Characters of token name
44
45 S : String (1 .. Tname'Last - 4);
46 -- Characters of token name folded to lower case, omitting TOK_ at start
47
48 M1 : String (1 .. 42) := "incorrect spelling of keyword ************";
49 M2 : String (1 .. 44) := "illegal abbreviation of keyword ************";
50 -- Buffers used to construct error message
51
52 P1 : constant := 30;
53 P2 : constant := 32;
54 -- Starting subscripts in M1, M2 for keyword name
55
56 SL : constant Natural := S'Length;
57 -- Length of expected token name excluding TOK_ at start
58
59 begin
60 if Token /= Tok_Identifier then
61 return False;
62 end if;
63
64 for J in S'Range loop
65 S (J) := Fold_Lower (Tname (J + 4));
66 end loop;
67
68 Get_Name_String (Token_Name);
69
70 -- A special check for case of PROGRAM used for PROCEDURE
71
72 if T = Tok_Procedure
73 and then Name_Len = 7
74 and then Name_Buffer (1 .. 7) = "program"
75 then
76 Error_Msg_SC -- CODEFIX
77 ("PROCEDURE expected");
78 Token := T;
79 return True;
80
81 -- A special check for an illegal abbreviation
82
83 elsif Name_Len < S'Length
84 and then Name_Len >= 4
85 and then Name_Buffer (1 .. Name_Len) = S (1 .. Name_Len)
86 then
87 for J in 1 .. S'Last loop
88 M2 (P2 + J - 1) := Fold_Upper (S (J));
89 end loop;
90
91 Error_Msg_SC (M2 (1 .. P2 - 1 + S'Last));
92 Token := T;
93 return True;
94 end if;
95
96 -- Now we go into the full circuit to check for a misspelling
97
98 -- Never consider something a misspelling if either the actual or
99 -- expected string is less than 3 characters (before this check we
100 -- used to consider i to be a misspelled if in some cases).
101
102 if SL < 3 or else Name_Len < 3 then
103 return False;
104
105 -- Special case: prefix matches, i.e. the leading characters of the
106 -- token that we have exactly match the required keyword. If there
107 -- are at least two characters left over, assume that we have a case
108 -- of two keywords joined together which should not be joined.
109
110 elsif Name_Len > SL + 1
111 and then S = Name_Buffer (1 .. SL)
112 then
113 Scan_Ptr := Token_Ptr + S'Length;
114 Error_Msg_S ("|missing space");
115 Token := T;
116 return True;
117 end if;
118
119 if Is_Bad_Spelling_Of (Name_Buffer (1 .. Name_Len), S) then
120 for J in 1 .. S'Last loop
121 M1 (P1 + J - 1) := Fold_Upper (S (J));
122 end loop;
123
124 Error_Msg_SC -- CODFIX
125 (M1 (1 .. P1 - 1 + S'Last));
126 Token := T;
127 return True;
128
129 else
130 return False;
131 end if;
132 end Bad_Spelling_Of;
133
134 ----------------------
135 -- Check_95_Keyword --
136 ----------------------
137
138 -- On entry, the caller has checked that current token is an identifier
139 -- whose name matches the name of the 95 keyword New_Tok.
140
141 procedure Check_95_Keyword (Token_95, Next : Token_Type) is
142 Scan_State : Saved_Scan_State;
143
144 begin
145 Save_Scan_State (Scan_State); -- at identifier/keyword
146 Scan; -- past identifier/keyword
147
148 if Token = Next then
149 Restore_Scan_State (Scan_State); -- to identifier
150 Error_Msg_Name_1 := Token_Name;
151 Error_Msg_SC ("(Ada 83) keyword* cannot be used!");
152 Token := Token_95;
153 else
154 Restore_Scan_State (Scan_State); -- to identifier
155 end if;
156 end Check_95_Keyword;
157
158 ----------------------
159 -- Check_Bad_Layout --
160 ----------------------
161
162 procedure Check_Bad_Layout is
163 begin
164 if RM_Column_Check and then Token_Is_At_Start_Of_Line
165 and then Start_Column <= Scopes (Scope.Last).Ecol
166 then
167 Error_Msg_BC -- CODEFIX
168 ("(style) incorrect layout?l?");
169 end if;
170 end Check_Bad_Layout;
171
172 --------------------------
173 -- Check_Future_Keyword --
174 --------------------------
175
176 procedure Check_Future_Keyword is
177 begin
178 -- Ada 2005 (AI-284): Compiling in Ada 95 mode we warn that INTERFACE,
179 -- OVERRIDING, and SYNCHRONIZED are new reserved words.
180
181 if Ada_Version = Ada_95
182 and then Warn_On_Ada_2005_Compatibility
183 then
184 if Token_Name in Name_Overriding | Name_Synchronized
185 or else (Token_Name = Name_Interface
186 and then Prev_Token /= Tok_Pragma)
187 then
188 Error_Msg_N ("& is a reserved word in Ada 2005?y?", Token_Node);
189 end if;
190 end if;
191
192 -- Similarly, warn about Ada 2012 reserved words
193
194 if Ada_Version in Ada_95 .. Ada_2005
195 and then Warn_On_Ada_2012_Compatibility
196 then
197 if Token_Name = Name_Some then
198 Error_Msg_N ("& is a reserved word in Ada 2012?y?", Token_Node);
199 end if;
200 end if;
201
202 if Ada_Version < Ada_With_All_Extensions then
203 if Token_Name = Name_Finally then
204 Error_Msg_N
205 ("& is a reserved word with all extensions enabled?",
206 Token_Node);
207 end if;
208 end if;
209
210 -- Note: we deliberately do not emit these warnings when operating in
211 -- Ada 83 mode because in that case we assume the user is building
212 -- legacy code anyway and is not interested in updating Ada versions.
213
214 end Check_Future_Keyword;
215
216 --------------------------
217 -- Check_Misspelling_Of --
218 --------------------------
219
220 procedure Check_Misspelling_Of (T : Token_Type) is
221 begin
222 if Bad_Spelling_Of (T) then
223 null;
224 end if;
225 end Check_Misspelling_Of;
226
227 -----------------------------
228 -- Check_Simple_Expression --
229 -----------------------------
230
231 procedure Check_Simple_Expression (E : Node_Id) is
232 begin
233 if Expr_Form = EF_Non_Simple then
234 Error_Msg_N ("this expression must be parenthesized", E);
235 end if;
236 end Check_Simple_Expression;
237
238 ---------------------------------------
239 -- Check_Simple_Expression_In_Ada_83 --
240 ---------------------------------------
241
242 procedure Check_Simple_Expression_In_Ada_83 (E : Node_Id) is
243 begin
244 if Expr_Form = EF_Non_Simple then
245 if Ada_Version = Ada_83 then
246 Error_Msg_N ("(Ada 83) this expression must be parenthesized!", E);
247 end if;
248 end if;
249 end Check_Simple_Expression_In_Ada_83;
250
251 ------------------------
252 -- Check_Subtype_Mark --
253 ------------------------
254
255 function Check_Subtype_Mark (Mark : Node_Id) return Node_Id is
256 begin
257 if Nkind (Mark) = N_Identifier
258 or else Nkind (Mark) = N_Selected_Component
259 or else (Nkind (Mark) = N_Attribute_Reference
260 and then Is_Type_Attribute_Name (Attribute_Name (Mark)))
261 or else Mark = Error
262 then
263 return Mark;
264 else
265 Error_Msg_N ("subtype mark expected", Mark);
266 return Error;
267 end if;
268 end Check_Subtype_Mark;
269
270 -------------------
271 -- Comma_Present --
272 -------------------
273
274 function Comma_Present return Boolean is
275 Scan_State : Saved_Scan_State;
276 Paren_Count : Nat;
277
278 begin
279 -- First check, if a comma is present, then a comma is present
280
281 if Token = Tok_Comma then
282 T_Comma;
283 return True;
284
285 -- If we have a right paren, then that is taken as ending the list
286 -- i.e. no comma is present.
287 -- Ditto for a right bracket in Ada 2022.
288
289 elsif Token = Tok_Right_Paren
290 or else (Token = Tok_Right_Bracket and then Ada_Version >= Ada_2022)
291 then
292 return False;
293
294 -- If pragmas, then get rid of them and make a recursive call
295 -- to process what follows these pragmas.
296
297 elsif Token = Tok_Pragma then
298 P_Pragmas_Misplaced;
299 return Comma_Present;
300
301 -- At this stage we have an error, and the goal is to decide on whether
302 -- or not we should diagnose an error and report a (non-existent)
303 -- comma as being present, or simply to report no comma is present
304
305 -- If we are a semicolon, then the question is whether we have a missing
306 -- right paren, or whether the semicolon should have been a comma. To
307 -- guess the right answer, we scan ahead keeping track of the paren
308 -- level, looking for a clue that helps us make the right decision.
309
310 -- This approach is highly accurate in the single error case, and does
311 -- not make bad mistakes in the multiple error case (indeed we can't
312 -- really make a very bad decision at this point in any case).
313
314 elsif Token = Tok_Semicolon then
315 Save_Scan_State (Scan_State);
316 Scan; -- past semicolon
317
318 -- Check for being followed by identifier => which almost certainly
319 -- means we are still in a parameter list and the comma should have
320 -- been a semicolon (such a sequence could not follow a semicolon)
321
322 if Token = Tok_Identifier then
323 Scan;
324
325 if Token = Tok_Arrow then
326 goto Assume_Comma;
327 end if;
328 end if;
329
330 -- If that test didn't work, loop ahead looking for a comma or
331 -- semicolon at the same parenthesis level. Always remember that
332 -- we can't go badly wrong in an error situation like this.
333
334 Paren_Count := 0;
335
336 -- Here is the look ahead loop, Paren_Count tells us whether the
337 -- token we are looking at is at the same paren level as the
338 -- suspicious semicolon that we are trying to figure out.
339
340 loop
341
342 -- If we hit another semicolon or an end of file, and we have
343 -- not seen a right paren or another comma on the way, then
344 -- probably the semicolon did end the list. Indeed that is
345 -- certainly the only single error correction possible here.
346
347 if Token in Tok_Semicolon | Tok_EOF then
348 Restore_Scan_State (Scan_State);
349 return False;
350
351 -- A comma at the same paren level as the semicolon is a strong
352 -- indicator that the semicolon should have been a comma, indeed
353 -- again this is the only possible single error correction.
354
355 elsif Token = Tok_Comma then
356 exit when Paren_Count = 0;
357
358 -- A left paren just bumps the paren count
359
360 elsif Token = Tok_Left_Paren then
361 Paren_Count := Paren_Count + 1;
362
363 -- A right paren that is at the same paren level as the semicolon
364 -- also means that the only possible single error correction is
365 -- to assume that the semicolon should have been a comma. If we
366 -- are not at the same paren level, then adjust the paren level.
367
368 elsif Token = Tok_Right_Paren then
369 exit when Paren_Count = 0;
370 Paren_Count := Paren_Count - 1;
371 end if;
372
373 -- Keep going, we haven't made a decision yet
374
375 Scan;
376 end loop;
377
378 -- If we fall through the loop, it means that we found a terminating
379 -- right paren or another comma. In either case it is reasonable to
380 -- assume that the semicolon was really intended to be a comma. Also
381 -- come here for the identifier arrow case.
382
383 <<Assume_Comma>>
384 Restore_Scan_State (Scan_State);
385 Error_Msg_SC -- CODEFIX
386 ("|"";"" should be "",""");
387 Scan; -- past the semicolon
388 return True;
389
390 -- If we are not at semicolon or a right paren, then we base the
391 -- decision on whether or not the next token can be part of an
392 -- expression. If not, then decide that no comma is present (the
393 -- caller will eventually generate a missing right parent message)
394
395 elsif Token in Token_Class_Eterm then
396 return False;
397
398 -- Otherwise we assume a comma is present, even if none is present,
399 -- since the next token must be part of an expression, so if we were
400 -- at the end of the list, then there is more than one error present.
401
402 else
403 T_Comma; -- to give error
404 return True;
405 end if;
406 end Comma_Present;
407
408 -----------------------
409 -- Discard_Junk_List --
410 -----------------------
411
412 procedure Discard_Junk_List (L : List_Id) is
413 pragma Warnings (Off, L);
414 begin
415 null;
416 end Discard_Junk_List;
417
418 -----------------------
419 -- Discard_Junk_Node --
420 -----------------------
421
422 procedure Discard_Junk_Node (N : Node_Id) is
423 pragma Warnings (Off, N);
424 begin
425 null;
426 end Discard_Junk_Node;
427
428 ------------
429 -- Ignore --
430 ------------
431
432 procedure Ignore (T : Token_Type) is
433 begin
434 while Token = T loop
435 if T = Tok_Comma then
436 Error_Msg_SC -- CODEFIX
437 ("|extra "","" ignored");
438
439 elsif T = Tok_Left_Paren then
440 Error_Msg_SC -- CODEFIX
441 ("|extra ""("" ignored");
442
443 -- Note: the following error used to be labeled as a non-serious
444 -- error like the other similar messages here (with a | at the start
445 -- of the message). But this caused some annoying cascaded errors
446 -- that were confusing, as shown by this example:
447
448 -- A : array (1 .. 9) of Integer :=
449 -- ((1 .. 2) => 0,
450 -- 1 2 3
451 -- >>> positional aggregate cannot have one component
452 -- >>> named association cannot follow positional association
453 -- >>> extra ")" ignored
454
455 -- So we decided to label it as serious after all
456
457 elsif T = Tok_Right_Paren then
458 Error_Msg_SC -- CODEFIX
459 ("extra "")"" ignored");
460
461 elsif T = Tok_Semicolon then
462 Error_Msg_SC -- CODEFIX
463 ("|extra "";"" ignored");
464
465 elsif T = Tok_Colon then
466 Error_Msg_SC -- CODEFIX
467 ("|extra "":"" ignored");
468
469 else
470 declare
471 Tname : constant String := Token_Type'Image (Token);
472 begin
473 Error_Msg_SC ("|extra " & Tname (5 .. Tname'Last) & " ignored");
474 end;
475 end if;
476
477 Scan; -- Scan past ignored token
478 end loop;
479 end Ignore;
480
481 ----------------------------
482 -- Is_Reserved_Identifier --
483 ----------------------------
484
485 function Is_Reserved_Identifier (C : Id_Check := None) return Boolean is
486 begin
487 if not Is_Reserved_Keyword (Token) then
488 return False;
489
490 else
491 declare
492 Ident_Casing : constant Casing_Type :=
493 Identifier_Casing (Current_Source_File);
494 Key_Casing : constant Casing_Type :=
495 Keyword_Casing (Current_Source_File);
496
497 begin
498 -- If the casing of identifiers and keywords is different in
499 -- this source file, and the casing of this token matches the
500 -- keyword casing, then we return False, since it is pretty
501 -- clearly intended to be a keyword.
502
503 if Ident_Casing = Unknown
504 or else Key_Casing = Unknown
505 or else Ident_Casing = Key_Casing
506 or else Determine_Token_Casing /= Key_Casing
507 then
508 return True;
509
510 -- Here we have a keyword written clearly with keyword casing.
511 -- In default mode, we would not be willing to consider this as
512 -- a reserved identifier, but if C is set, we may still accept it
513
514 elsif C /= None then
515 declare
516 Scan_State : Saved_Scan_State;
517 OK_Next_Tok : Boolean;
518
519 begin
520 Save_Scan_State (Scan_State);
521 Scan;
522
523 if Token_Is_At_Start_Of_Line then
524 return False;
525 end if;
526
527 case C is
528 when None =>
529 raise Program_Error;
530
531 when C_Comma_Right_Paren =>
532 OK_Next_Tok := Token in Tok_Comma | Tok_Right_Paren;
533
534 when C_Comma_Colon =>
535 OK_Next_Tok := Token in Tok_Comma | Tok_Colon;
536
537 when C_Do =>
538 OK_Next_Tok := Token = Tok_Do;
539
540 when C_Dot =>
541 OK_Next_Tok := Token = Tok_Dot;
542
543 when C_Greater_Greater =>
544 OK_Next_Tok := Token = Tok_Greater_Greater;
545
546 when C_In =>
547 OK_Next_Tok := Token = Tok_In;
548
549 when C_Is =>
550 OK_Next_Tok := Token = Tok_Is;
551
552 when C_Left_Paren_Semicolon =>
553 OK_Next_Tok := Token in Tok_Left_Paren | Tok_Semicolon;
554
555 when C_Use =>
556 OK_Next_Tok := Token = Tok_Use;
557
558 when C_Vertical_Bar_Arrow =>
559 OK_Next_Tok := Token in Tok_Vertical_Bar | Tok_Arrow;
560 end case;
561
562 Restore_Scan_State (Scan_State);
563
564 if OK_Next_Tok then
565 return True;
566 end if;
567 end;
568 end if;
569 end;
570 end if;
571
572 -- If we fall through it is not a reserved identifier
573
574 return False;
575 end Is_Reserved_Identifier;
576
577 ----------------------
578 -- Merge_Identifier --
579 ----------------------
580
581 procedure Merge_Identifier (Prev : Node_Id; Nxt : Token_Type) is
582 begin
583 if Token /= Tok_Identifier then
584 return;
585 end if;
586
587 declare
588 S : Saved_Scan_State;
589 T : Token_Type;
590
591 begin
592 Save_Scan_State (S);
593 Scan;
594 T := Token;
595 Restore_Scan_State (S);
596
597 if T /= Nxt then
598 return;
599 end if;
600 end;
601
602 -- Check exactly one space between identifiers
603
604 if Source (Token_Ptr - 1) /= ' '
605 or else Int (Token_Ptr) /=
606 Int (Prev_Token_Ptr) + Length_Of_Name (Chars (Prev)) + 1
607 then
608 return;
609 end if;
610
611 -- Do the merge
612
613 Get_Name_String (Chars (Token_Node));
614
615 declare
616 Buf : constant String (1 .. Name_Len) :=
617 Name_Buffer (1 .. Name_Len);
618
619 begin
620 Get_Name_String (Chars (Prev));
621 Add_Char_To_Name_Buffer ('_');
622 Add_Str_To_Name_Buffer (Buf);
623 Set_Chars (Prev, Name_Find);
624 end;
625
626 Error_Msg_Node_1 := Prev;
627 Error_Msg_SC ("unexpected identifier, possibly & was meant here");
628 Scan;
629 end Merge_Identifier;
630
631 -------------------------------
632 -- Missing_Semicolon_On_When --
633 -------------------------------
634
635 function Missing_Semicolon_On_When return Boolean is
636 State : Saved_Scan_State;
637
638 begin
639 if not Token_Is_At_Start_Of_Line then
640 return False;
641
642 elsif Scopes (Scope.Last).Etyp /= E_Case then
643 return False;
644
645 else
646 Save_Scan_State (State);
647 Scan; -- past WHEN
648 Scan; -- past token after WHEN
649
650 if Token = Tok_Arrow then
651 Restore_Scan_State (State);
652 return True;
653 else
654 Restore_Scan_State (State);
655 return False;
656 end if;
657 end if;
658 end Missing_Semicolon_On_When;
659
660 -------------------
661 -- Next_Token_Is --
662 -------------------
663
664 function Next_Token_Is (Tok : Token_Type) return Boolean is
665 Scan_State : Saved_Scan_State;
666 Result : Boolean;
667 begin
668 Save_Scan_State (Scan_State);
669 Scan;
670 Result := (Token = Tok);
671 Restore_Scan_State (Scan_State);
672 return Result;
673 end Next_Token_Is;
674
675 -------------------
676 -- No_Constraint --
677 -------------------
678
679 procedure No_Constraint is
680 begin
681 -- If we have a token that could start a constraint on the same line
682 -- then cnsider this an illegal constraint. It seems unlikely it could
683 -- be anything else if it is on the same line.
684
685 if Token in Token_Class_Consk then
686 Error_Msg_SC ("constraint not allowed here");
687 Discard_Junk_Node (P_Constraint_Opt);
688 end if;
689 end No_Constraint;
690
691 ---------------------
692 -- Pop_Scope_Stack --
693 ---------------------
694
695 procedure Pop_Scope_Stack is
696 begin
697 pragma Assert (Scope.Last > 0);
698 Scope.Decrement_Last;
699
700 if Debug_Flag_P then
701 Error_Msg_Uint_1 := UI_From_Int (Scope.Last);
702 Error_Msg_SC ("decrement scope stack ptr, new value = ^!");
703 end if;
704 end Pop_Scope_Stack;
705
706 ----------------------
707 -- Push_Scope_Stack --
708 ----------------------
709
710 procedure Push_Scope_Stack is
711 begin
712 Scope.Increment_Last;
713
714 if Style_Check_Max_Nesting_Level
715 and then Scope.Last = Style_Max_Nesting_Level + 1
716 then
717 Error_Msg
718 ("(style) maximum nesting level exceeded?L?",
719 First_Non_Blank_Location);
720 end if;
721
722 Scopes (Scope.Last).Junk := False;
723 Scopes (Scope.Last).Node := Empty;
724
725 if Debug_Flag_P then
726 Error_Msg_Uint_1 := UI_From_Int (Scope.Last);
727 Error_Msg_SC ("increment scope stack ptr, new value = ^!");
728 end if;
729 end Push_Scope_Stack;
730
731 ----------------------
732 -- Separate_Present --
733 ----------------------
734
735 function Separate_Present return Boolean is
736 Scan_State : Saved_Scan_State;
737
738 begin
739 if Token = Tok_Separate then
740 return True;
741
742 elsif Token /= Tok_Identifier then
743 return False;
744
745 else
746 Save_Scan_State (Scan_State);
747 Scan; -- past identifier
748
749 if Token = Tok_Semicolon then
750 Restore_Scan_State (Scan_State);
751 return Bad_Spelling_Of (Tok_Separate);
752
753 else
754 Restore_Scan_State (Scan_State);
755 return False;
756 end if;
757 end if;
758 end Separate_Present;
759
760 --------------------------
761 -- Signal_Bad_Attribute --
762 --------------------------
763
764 procedure Signal_Bad_Attribute is
765 begin
766 Bad_Attribute (Token_Node, Token_Name, Warn => False);
767 end Signal_Bad_Attribute;
768
769 -----------------------------
770 -- Token_Is_At_End_Of_Line --
771 -----------------------------
772
773 function Token_Is_At_End_Of_Line return Boolean is
774 S : Source_Ptr;
775
776 begin
777 -- Skip past blanks and horizontal tabs
778
779 S := Scan_Ptr;
780 while Source (S) = ' ' or else Source (S) = ASCII.HT loop
781 S := S + 1;
782 end loop;
783
784 -- We are at end of line if at a control character (CR/LF/VT/FF/EOF)
785 -- or if we are at the start of an end of line comment sequence.
786
787 return Source (S) < ' '
788 or else (Source (S) = '-' and then Source (S + 1) = '-');
789 end Token_Is_At_End_Of_Line;
790
791 -------------------------------
792 -- Token_Is_At_Start_Of_Line --
793 -------------------------------
794
795 function Token_Is_At_Start_Of_Line return Boolean is
796 begin
797 return Token_Ptr = First_Non_Blank_Location or else Token = Tok_EOF;
798 end Token_Is_At_Start_Of_Line;
799
800 -----------------------------------
801 -- Warn_If_Standard_Redefinition --
802 -----------------------------------
803
804 procedure Warn_If_Standard_Redefinition (N : Node_Id) is
805 begin
806 if Warn_On_Standard_Redefinition then
807 declare
808 C : constant Entity_Id := Current_Entity (N);
809 begin
810 if Present (C) and then Sloc (C) = Standard_Location then
811 Error_Msg_N ("redefinition of entity& in Standard?.k?", N);
812 end if;
813 end;
814 end if;
815 end Warn_If_Standard_Redefinition;
816
817 end Util;