1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1999-2001 Free Software Foundation, Inc. --
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. --
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). --
27 ------------------------------------------------------------------------------
30 with Atree; use Atree;
31 with Einfo; use Einfo;
32 with Errout; use Errout;
33 with Fname; use Fname;
35 with Nlists; use Nlists;
38 with Sem_Util; use Sem_Util;
39 with Sinfo; use Sinfo;
40 with Sinput; use Sinput;
41 with Snames; use Snames;
42 with Stand; use Stand;
45 package body Sem_Warn is
47 -- The following table collects Id's of entities that are potentially
48 -- unreferenced. See Check_Unset_Reference for further details.
50 package Unreferenced_Entities is new Table.Table (
51 Table_Component_Type => Entity_Id,
52 Table_Index_Type => Nat,
54 Table_Initial => Alloc.Unreferenced_Entities_Initial,
55 Table_Increment => Alloc.Unreferenced_Entities_Increment,
56 Table_Name => "Unreferenced_Entities");
58 -- One entry is made in the following table for each branch of
59 -- a conditional, e.g. an if-then-elsif-else-endif structure
60 -- creates three entries in this table.
62 type Branch_Entry is record
64 -- Location for warnings associated with this branch
67 -- List of entities defined for the first time in this branch. On
68 -- exit from a conditional structure, any entity that is in the
69 -- list of all branches is removed (and the entity flagged as
70 -- defined by the conditional as a whole). Thus after processing
71 -- a conditional, Defs contains a list of entities defined in this
72 -- branch for the first time, but not defined at all in some other
73 -- branch of the same conditional. A value of No_Elist is used to
74 -- represent the initial empty list.
77 -- Index of next branch for this conditional, zero = last branch
80 package Branch_Table is new Table.Table (
81 Table_Component_Type => Branch_Entry,
82 Table_Index_Type => Nat,
84 Table_Initial => Alloc.Branches_Initial,
85 Table_Increment => Alloc.Branches_Increment,
86 Table_Name => "Branches");
88 -- The following table is used to represent conditionals, there is
89 -- one entry in this table for each conditional structure.
91 type Conditional_Entry is record
93 -- True for IF statement, False for CASE statement
96 -- Index in Branch table of first branch, zero = none yet
99 -- Index in Branch table of current branch, zero = none yet
102 package Conditional_Table is new Table.Table (
103 Table_Component_Type => Conditional_Entry,
104 Table_Index_Type => Nat,
105 Table_Low_Bound => 1,
106 Table_Initial => Alloc.Conditionals_Initial,
107 Table_Increment => Alloc.Conditionals_Increment,
108 Table_Name => "Conditionals");
110 -- The following table is a stack that keeps track of the current
111 -- conditional. The Last entry is the top of the stack. An Empty
112 -- entry represents the start of a compilation unit. Non-zero
113 -- entries in the stack are indexes into the conditional table.
115 package Conditional_Stack is new Table.Table (
116 Table_Component_Type => Nat,
117 Table_Index_Type => Nat,
118 Table_Low_Bound => 1,
119 Table_Initial => Alloc.Conditional_Stack_Initial,
120 Table_Increment => Alloc.Conditional_Stack_Increment,
121 Table_Name => "Conditional_Stack");
123 Current_Entity_List : Elist_Id := No_Elist;
124 -- This is a copy of the Defs list of the current branch of the current
125 -- conditional. It could be accessed by taking the top element of the
126 -- Conditional_Stack, and going to te Current_Branch entry of this
127 -- conditional, but we keep it precomputed for rapid access.
129 ----------------------
130 -- Check_References --
131 ----------------------
133 procedure Check_References (E : Entity_Id; Anod : Node_Id := Empty) is
138 procedure Output_Reference_Error (M : String);
139 -- Used to output an error message. Deals with posting the error on
140 -- the body formal in the accept case.
142 function Publicly_Referenceable (Ent : Entity_Id) return Boolean;
143 -- This is true if the entity in question is potentially referenceable
144 -- from another unit. This is true for entities in packages that are
145 -- at the library level, or for entities in tasks or protected objects
146 -- that are themselves publicly visible.
148 ----------------------------
149 -- Output_Reference_Error --
150 ----------------------------
152 procedure Output_Reference_Error (M : String) is
154 -- Other than accept case, post error on defining identifier
159 -- Accept case, find body formal to post the message
170 if Present (Parameter_Specifications (Anod)) then
171 Parm := First (Parameter_Specifications (Anod));
173 while Present (Parm) loop
174 Defid := Defining_Identifier (Parm);
176 if Chars (E1) = Chars (Defid) then
185 Error_Msg_NE (M, Enod, E1);
188 end Output_Reference_Error;
190 ----------------------------
191 -- Publicly_Referenceable --
192 ----------------------------
194 function Publicly_Referenceable (Ent : Entity_Id) return Boolean is
198 -- Any entity in a generic package is considered to be publicly
199 -- referenceable, since it could be referenced in an instantiation
201 if Ekind (E) = E_Generic_Package then
205 -- Otherwise look up the scope stack
209 if Is_Package (S) then
210 return Is_Library_Level_Entity (S);
212 elsif Ekind (S) = E_Task_Type
213 or else Ekind (S) = E_Protected_Type
214 or else Ekind (S) = E_Entry
222 end Publicly_Referenceable;
224 -- Start of processing for Check_References
227 -- No messages if warnings are suppressed, or if we have detected
228 -- any real errors so far (this last check avoids junk messages
229 -- resulting from errors, e.g. a subunit that is not loaded).
231 -- We also skip the messages if any subunits were not loaded (see
232 -- comment in Sem_Ch10 to understand how this is set, and why it is
233 -- necessary to suppress the warnings in this case).
235 if Warning_Mode = Suppress
236 or else Errors_Detected /= 0
237 or else Unloaded_Subunits
242 -- Otherwise loop through entities, looking for suspicious stuff
244 E1 := First_Entity (E);
245 while Present (E1) loop
247 -- We only look at source entities with warning flag off
249 if Comes_From_Source (E1) and then not Warnings_Off (E1) then
251 -- We are interested in variables and out parameters, but we
252 -- exclude protected types, too complicated to worry about.
254 if Ekind (E1) = E_Variable
256 (Ekind (E1) = E_Out_Parameter
257 and then not Is_Protected_Type (Current_Scope))
259 -- Post warning if this object not assigned. Note that we
260 -- do not consider the implicit initialization of an access
261 -- type to be the assignment of a value for this purpose.
262 -- If the entity is an out parameter of the current subprogram
263 -- body, check the warning status of the parameter in the spec.
265 if Ekind (E1) = E_Out_Parameter
266 and then Present (Spec_Entity (E1))
267 and then Warnings_Off (Spec_Entity (E1))
271 elsif Not_Source_Assigned (E1) then
272 Output_Reference_Error ("& is never assigned a value?");
274 -- Deal with special case where this variable is hidden
275 -- by a loop variable
277 if Ekind (E1) = E_Variable
278 and then Present (Hiding_Loop_Variable (E1))
280 Error_Msg_Sloc := Sloc (E1);
282 ("declaration hides &#?",
283 Hiding_Loop_Variable (E1));
285 ("for loop implicitly declares loop variable?",
286 Hiding_Loop_Variable (E1));
292 -- Check for unset reference, note that we exclude access
293 -- types from this check, since access types do always have
294 -- a null value, and that seems legitimate in this case.
296 UR := Unset_Reference (E1);
299 -- For access types, the only time we complain is when
300 -- we have a dereference (of a null value)
302 if Is_Access_Type (Etype (E1)) then
305 if (Nkind (PU) = N_Selected_Component
307 Nkind (PU) = N_Explicit_Dereference
309 Nkind (PU) = N_Indexed_Component)
313 Error_Msg_N ("& may be null?", UR);
317 -- For other than access type, go back to original node
318 -- to deal with case where original unset reference
319 -- has been rewritten during expansion.
322 UR := Original_Node (UR);
324 -- In some cases, the original node may be a type
325 -- conversion or qualification, and in this case
326 -- we want the object entity inside.
328 while Nkind (UR) = N_Type_Conversion
329 or else Nkind (UR) = N_Qualified_Expression
331 UR := Expression (UR);
335 ("& may be referenced before it has a value?", UR);
341 -- Then check for unreferenced variables
343 if Check_Unreferenced
345 -- Check entity is flagged as not referenced and that
346 -- warnings are not suppressed for this entity
348 and then not Referenced (E1)
349 and then not Warnings_Off (E1)
351 -- Warnings are placed on objects, types, subprograms,
352 -- labels, and enumeration literals.
354 and then (Is_Object (E1)
360 Ekind (E1) = E_Named_Integer
362 Ekind (E1) = E_Named_Real
364 Is_Overloadable (E1))
366 -- We only place warnings for the main unit
368 and then In_Extended_Main_Source_Unit (E1)
370 -- Exclude instantiations, since there is no reason why
371 -- every entity in an instantiation should be referenced.
373 and then Instantiation_Location (Sloc (E1)) = No_Location
375 -- Exclude formal parameters from bodies (in the case
376 -- where there is a separate spec, it is the spec formals
377 -- that are of interest).
379 and then (not Is_Formal (E1)
381 Ekind (Scope (E1)) /= E_Subprogram_Body)
383 -- Consider private type referenced if full view is
386 and then not (Is_Private_Type (E1)
388 Referenced (Full_View (E1)))
390 -- Don't worry about full view, only about private type
392 and then not Has_Private_Declaration (E1)
394 -- Eliminate dispatching operations from consideration, we
395 -- cannot tell if these are referenced or not in any easy
396 -- manner (note this also catches Adjust/Finalize/Initialize)
398 and then not Is_Dispatching_Operation (E1)
400 -- Check entity that can be publicly referenced (we do not
401 -- give messages for such entities, since there could be
402 -- other units, not involved in this compilation, that
403 -- contain relevant references.
405 and then not Publicly_Referenceable (E1)
407 -- Class wide types are marked as source entities, but
408 -- they are not really source entities, and are always
409 -- created, so we do not care if they are not referenced.
411 and then Ekind (E1) /= E_Class_Wide_Type
413 -- Objects other than parameters of task types are allowed
414 -- to be non-referenced, since they start up tasks!
416 and then ((Ekind (E1) /= E_Variable
417 and then Ekind (E1) /= E_Constant
418 and then Ekind (E1) /= E_Component)
419 or else not Is_Task_Type (Etype (E1)))
421 -- Suppress warnings in internal units if not in -gnatg
422 -- mode (these would be junk warnings for an applications
423 -- program, since they refer to problems in internal units)
427 Is_Internal_File_Name
428 (Unit_File_Name (Get_Source_Unit (E1)))
430 -- We do not immediately flag the error. This is because
431 -- we have not expanded generic bodies yet, and they may
432 -- have the missing reference. So instead we park the
433 -- entity on a list, for later processing. However, for
434 -- the accept case, post the error right here, since we
435 -- have the information now in this case.
437 if Present (Anod) then
438 Output_Reference_Error ("& is not referenced?");
441 Unreferenced_Entities.Increment_Last;
442 Unreferenced_Entities.Table
443 (Unreferenced_Entities.Last) := E1;
449 -- Recurse into nested package or block
452 if (Ekind (E1) = E_Package
453 and then Nkind (Parent (E1)) = N_Package_Specification)
454 or else Ekind (E1) = E_Block
456 Check_References (E1);
461 end Check_References;
463 ---------------------------
464 -- Check_Unset_Reference --
465 ---------------------------
467 procedure Check_Unset_Reference (N : Node_Id) is
469 -- Nothing to do if warnings suppressed
471 if Warning_Mode = Suppress then
475 -- Otherwise see what kind of node we have. If the entity already
476 -- has an unset reference, it is not necessarily the earliest in
477 -- the text, because resolution of the prefix of selected components
478 -- is completed before the resolution of the selected component itself.
479 -- as a result, given (R /= null and then R.X > 0), the occurrences
480 -- of R are examined in right-to-left order. If there is already an
481 -- unset reference, we check whether N is earlier before proceeding.
485 when N_Identifier | N_Expanded_Name =>
487 E : constant Entity_Id := Entity (N);
490 if (Ekind (E) = E_Variable
491 or else Ekind (E) = E_Out_Parameter)
492 and then Not_Source_Assigned (E)
493 and then (No (Unset_Reference (E))
494 or else Earlier_In_Extended_Unit
495 (Sloc (N), Sloc (Unset_Reference (E))))
496 and then not Warnings_Off (E)
498 -- Here we have a potential unset reference. But before we
499 -- get worried about it, we have to make sure that the
500 -- entity declaration is in the same procedure as the
501 -- reference, since if they are in separate procedures,
502 -- then we have no idea about sequential execution.
504 -- The tests in the loop below catch all such cases, but
505 -- do allow the reference to appear in a loop, block, or
506 -- package spec that is nested within the declaring scope.
507 -- As always, it is possible to construct cases where the
508 -- warning is wrong, that is why it is a warning!
510 -- If the entity is an out_parameter, it is ok to read its
511 -- its discriminants (that was true in Ada83) so suppress
512 -- the message in that case as well.
514 if Ekind (E) = E_Out_Parameter
515 and then Nkind (Parent (N)) = N_Selected_Component
516 and then Ekind (Entity (Selector_Name (Parent (N))))
524 SE : constant Entity_Id := Scope (E);
529 if SR = Standard_Standard
530 or else Is_Subprogram (SR)
531 or else Is_Concurrent_Body (SR)
532 or else Is_Concurrent_Type (SR)
540 if Nkind (N) = N_Identifier then
541 Set_Unset_Reference (E, N);
543 Set_Unset_Reference (E, Selector_Name (N));
549 when N_Indexed_Component | N_Selected_Component | N_Slice =>
550 Check_Unset_Reference (Prefix (N));
553 when N_Type_Conversion | N_Qualified_Expression =>
554 Check_Unset_Reference (Expression (N));
560 end Check_Unset_Reference;
562 ------------------------
563 -- Check_Unused_Withs --
564 ------------------------
566 procedure Check_Unused_Withs (Spec_Unit : Unit_Number_Type := No_Unit) is
572 Munite : constant Entity_Id := Cunit_Entity (Main_Unit);
573 -- This is needed for checking the special renaming case
575 procedure Check_One_Unit (Unit : Unit_Number_Type);
576 -- Subsidiary procedure, performs checks for specified unit
582 procedure Check_One_Unit (Unit : Unit_Number_Type) is
583 Is_Visible_Renaming : Boolean := False;
586 function Find_Package_Renaming
588 L : Entity_Id) return Entity_Id;
589 -- The only reference to a context unit may be in a renaming
590 -- declaration. If this renaming declares a visible entity, do
591 -- not warn that the context clause could be moved to the body,
592 -- because the renaming may be intented to re-export the unit.
594 ---------------------------
595 -- Find_Package_Renaming --
596 ---------------------------
598 function Find_Package_Renaming
600 L : Entity_Id) return Entity_Id
606 Is_Visible_Renaming := False;
607 E1 := First_Entity (P);
609 while Present (E1) loop
610 if Ekind (E1) = E_Package
611 and then Renamed_Object (E1) = L
613 Is_Visible_Renaming := not Is_Hidden (E1);
616 elsif Ekind (E1) = E_Package
617 and then No (Renamed_Object (E1))
618 and then not Is_Generic_Instance (E1)
620 R := Find_Package_Renaming (E1, L);
623 Is_Visible_Renaming := not Is_Hidden (R);
632 end Find_Package_Renaming;
634 -- Start of processing for Check_One_Unit
637 Cnode := Cunit (Unit);
639 -- Only do check in units that are part of the extended main
640 -- unit. This is actually a necessary restriction, because in
641 -- the case of subprogram acting as its own specification,
642 -- there can be with's in subunits that we will not see.
644 if not In_Extended_Main_Source_Unit (Cnode) then
648 -- Loop through context items in this unit
650 Item := First (Context_Items (Cnode));
651 while Present (Item) loop
653 if Nkind (Item) = N_With_Clause
654 and then not Implicit_With (Item)
655 and then In_Extended_Main_Source_Unit (Item)
657 Lunit := Entity (Name (Item));
659 -- Check if this unit is referenced
661 if not Referenced (Lunit) then
663 -- Suppress warnings in internal units if not in -gnatg
664 -- mode (these would be junk warnings for an applications
665 -- program, since they refer to problems in internal units)
668 or else not Is_Internal_File_Name (Unit_File_Name (Unit))
670 -- Here we definitely have a non-referenced unit. If
671 -- it is the special call for a spec unit, then just
672 -- set the flag to be read later.
674 if Unit = Spec_Unit then
675 Set_Unreferenced_In_Spec (Item);
677 -- Otherwise simple unreferenced message
681 ("unit& is not referenced?", Name (Item));
685 -- If main unit is a renaming of this unit, then we consider
686 -- the with to be OK (obviously it is needed in this case!)
688 elsif Present (Renamed_Entity (Munite))
689 and then Renamed_Entity (Munite) = Lunit
693 -- If this unit is referenced, and it is a package, we
694 -- do another test, to see if any of the entities in the
695 -- package are referenced. If none of the entities are
696 -- referenced, we still post a warning. This occurs if
697 -- the only use of the package is in a use clause, or
698 -- in a package renaming declaration.
700 elsif Ekind (Lunit) = E_Package then
702 -- If Is_Instantiated is set, it means that the package
703 -- is implicitly instantiated (this is the case of a
704 -- parent instance or an actual for a generic package
705 -- formal), and this counts as a reference.
707 if Is_Instantiated (Lunit) then
710 -- If no entities in package, and there is a pragma
711 -- Elaborate_Body present, then assume that this with
712 -- is done for purposes of this elaboration.
714 elsif No (First_Entity (Lunit))
715 and then Has_Pragma_Elaborate_Body (Lunit)
719 -- Otherwise see if any entities have been referenced
722 Ent := First_Entity (Lunit);
725 -- No more entities, and we did not find one
726 -- that was referenced. Means we have a definite
727 -- case of a with none of whose entities was
732 -- If in spec, just set the flag
734 if Unit = Spec_Unit then
735 Set_No_Entities_Ref_In_Spec (Item);
737 -- Else give the warning
741 ("no entities of & are referenced?",
744 -- Look for renamings of this package, and
745 -- flag them as well. If the original package
746 -- has warnings off, we suppress the warning
747 -- on the renaming as well.
749 Pack := Find_Package_Renaming (Munite, Lunit);
752 and then not Warnings_Off (Lunit)
755 ("no entities of & are referenced?",
756 Unit_Declaration_Node (Pack),
763 -- Case of next entity is referenced
765 elsif Referenced (Ent) then
767 -- This means that the with is indeed fine, in
768 -- that it is definitely needed somewhere, and
769 -- we can quite worrying about this one.
771 -- Except for one little detail, if either of
772 -- the flags was set during spec processing,
773 -- this is where we complain that the with
774 -- could be moved from the spec. If the spec
775 -- contains a visible renaming of the package,
776 -- inhibit warning to move with_clause to body.
778 if Ekind (Munite) = E_Package_Body then
780 Find_Package_Renaming
781 (Spec_Entity (Munite), Lunit);
784 if Unreferenced_In_Spec (Item) then
786 ("unit& is not referenced in spec?",
789 elsif No_Entities_Ref_In_Spec (Item) then
791 ("no entities of & are referenced in spec?",
798 if not Is_Visible_Renaming then
800 ("\with clause might be moved to body?",
806 -- Move to next entity to continue search
814 -- For a generic package, the only interesting kind of
815 -- reference is an instantiation, since entities cannot
816 -- be referenced directly.
818 elsif Is_Generic_Unit (Lunit) then
820 -- Unit was never instantiated, set flag for case of spec
821 -- call, or give warning for normal call.
823 if not Is_Instantiated (Lunit) then
824 if Unit = Spec_Unit then
825 Set_Unreferenced_In_Spec (Item);
828 ("unit& is never instantiated?", Name (Item));
831 -- If unit was indeed instantiated, make sure that
832 -- flag is not set showing it was uninstantiated in
833 -- the spec, and if so, give warning.
835 elsif Unreferenced_In_Spec (Item) then
837 ("unit& is not instantiated in spec?", Name (Item));
839 ("\with clause can be moved to body?", Name (Item));
849 -- Start of processing for Check_Unused_Withs
852 if not Opt.Check_Withs
853 or else Operating_Mode = Check_Syntax
858 -- Flag any unused with clauses, but skip this step if we are
859 -- compiling a subunit on its own, since we do not have enough
860 -- information to determine whether with's are used. We will get
861 -- the relevant warnings when we compile the parent. This is the
862 -- normal style of GNAT compilation in any case.
864 if Nkind (Unit (Cunit (Main_Unit))) = N_Subunit then
868 -- Process specified units
870 if Spec_Unit = No_Unit then
872 -- For main call, check all units
874 for Unit in Main_Unit .. Last_Unit loop
875 Check_One_Unit (Unit);
879 -- For call for spec, check only the spec
881 Check_One_Unit (Spec_Unit);
883 end Check_Unused_Withs;
885 ---------------------
886 -- End_Conditional --
887 ---------------------
889 procedure End_Conditional is
898 procedure End_Unit is
903 ----------------------------------
904 -- Output_Unreferenced_Messages --
905 ----------------------------------
907 procedure Output_Unreferenced_Messages is
911 for J in Unreferenced_Entities.First ..
912 Unreferenced_Entities.Last
914 E := Unreferenced_Entities.Table (J);
916 if not Referenced (E) and then not Warnings_Off (E) then
920 if Present (Renamed_Object (E))
921 and then Comes_From_Source (Renamed_Object (E))
923 Error_Msg_N ("renamed variable & is not referenced?", E);
925 Error_Msg_N ("variable & is not referenced?", E);
929 if Present (Renamed_Object (E))
930 and then Comes_From_Source (Renamed_Object (E))
932 Error_Msg_N ("renamed constant & is not referenced?", E);
934 Error_Msg_N ("constant & is not referenced?", E);
937 when E_In_Parameter |
939 E_In_Out_Parameter =>
941 -- Do not emit message for formals of a renaming, because
942 -- they are never referenced explicitly.
944 if Nkind (Original_Node (Unit_Declaration_Node (Scope (E))))
945 /= N_Subprogram_Renaming_Declaration
947 Error_Msg_N ("formal parameter & is not referenced?", E);
950 when E_Named_Integer |
952 Error_Msg_N ("named number & is not referenced?", E);
954 when E_Enumeration_Literal =>
955 Error_Msg_N ("literal & is not referenced?", E);
958 Error_Msg_N ("function & is not referenced?", E);
961 Error_Msg_N ("procedure & is not referenced?", E);
964 Error_Msg_N ("type & is not referenced?", E);
967 Error_Msg_N ("& is not referenced?", E);
970 Set_Warnings_Off (E);
973 end Output_Unreferenced_Messages;
979 procedure Start_Branch (Loc : Source_Ptr) is
984 -----------------------
985 -- Start_Conditional --
986 -----------------------
988 procedure Start_Conditional (If_Stmt : Boolean) is
991 end Start_Conditional;
997 procedure Start_Unit is
1002 -----------------------------
1003 -- Warn_On_Known_Condition --
1004 -----------------------------
1006 procedure Warn_On_Known_Condition (C : Node_Id) is
1010 if Constant_Condition_Warnings
1011 and then Nkind (C) = N_Identifier
1013 (Entity (C) = Standard_False or else Entity (C) = Standard_True)
1014 and then Comes_From_Source (Original_Node (C))
1015 and then not In_Instance
1017 -- See if this is in a statement or a declaration
1021 -- If tree is not attached, do not issue warning (this is very
1022 -- peculiar, and probably arises from some other error condition)
1027 -- If we are in a declaration, then no warning, since in practice
1028 -- conditionals in declarations are used for intended tests which
1029 -- may be known at compile time, e.g. things like
1031 -- x : constant Integer := 2 + (Word'Size = 32);
1033 -- And a warning is annoying in such cases
1035 elsif Nkind (P) in N_Declaration
1037 Nkind (P) in N_Later_Decl_Item
1041 -- Don't warn in assert pragma, since presumably tests in such
1042 -- a context are very definitely intended, and might well be
1043 -- known at compile time. Note that we have to test the original
1044 -- node, since assert pragmas get rewritten at analysis time.
1046 elsif Nkind (Original_Node (P)) = N_Pragma
1047 and then Chars (Original_Node (P)) = Name_Assert
1052 exit when Is_Statement (P);
1056 if Entity (C) = Standard_True then
1057 Error_Msg_N ("condition is always True?", C);
1059 Error_Msg_N ("condition is always False?", C);
1062 end Warn_On_Known_Condition;