* config/mips/mips.c (function_arg): Where one part of a
[official-gcc.git] / gcc / ada / sem_warn.ads
blobbe2fd6f11af06539d201254314cc9c3d4a7f7a1f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ W A R N --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1999-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This package contains the routines used to deal with issuing warnings
28 -- about uses of uninitialized variables and unused with's. It also has
29 -- some unrelated routines related to the generation of warnings.
31 with Types; use Types;
33 package Sem_Warn is
35 --------------------
36 -- Initialization --
37 --------------------
39 function Set_Warning_Switch (C : Character) return Boolean;
40 -- This function sets the warning switch or switches corresponding to
41 -- the given character. It is used for processing a -gnatw switch on the
42 -- command line, or a string literal in pragma Warnings.
44 ------------------------------------------
45 -- Routines to Handle Unused References --
46 ------------------------------------------
48 procedure Check_References (E : Entity_Id; Anod : Node_Id := Empty);
49 -- Called at the end of processing a declarative region. The entity E
50 -- is the entity for the scope. All entities declared in the region,
51 -- as indicated by First_Entity and the entity chain, are checked to
52 -- see if they are variables for which warnings need to be posted for
53 -- either no assignments, or a use before an assignment or no references
54 -- at all. The Anod node is present for the case of an accept statement,
55 -- and references the accept statement. This is used to place the warning
56 -- messages in the right place.
58 procedure Check_Unset_Reference (N : Node_Id);
59 -- N is the node for an expression which occurs in a reference position,
60 -- e.g. as the right side of an assignment. This procedure checks to see
61 -- if the node is a reference to a variable entity where the entity has
62 -- Not_Assigned set. If so, the Unset_Reference field is set if it is not
63 -- the first occurrence. No warning is posted, instead warnings will be
64 -- posted later by Check_References. The reason we do things that
65 -- way is that if there are no assignments anywhere, we prefer to flag
66 -- the entity, rather than a reference to it. Note that for the purposes
67 -- of this routine, a type conversion or qualified expression whose
68 -- expression is an entity is also processed. The reason that we do not
69 -- process these at the point of occurrence is that both these constructs
70 -- can occur in non-reference positions (e.g. as out parameters).
72 procedure Check_Unused_Withs (Spec_Unit : Unit_Number_Type := No_Unit);
73 -- This routine performs two kinds of checks. It checks that all with'ed
74 -- units are referenced, and that at least one entity of each with'ed
75 -- unit is referenced (the latter check catches units that are only
76 -- referenced in a use or package renaming statement). Appropriate
77 -- warning messages are generated if either of these situations is
78 -- detected.
80 -- A special case arises when a package body or a subprogram body with
81 -- a separate spec is being compiled. In this case, a with may appear
82 -- on the spec, but be needed only by the body. This still generates
83 -- a warning, but the text is different (the with is not redundant,
84 -- it is misplaced).
86 -- This special case is implemented by making an initial call to this
87 -- procedure with Spec_Unit set to the unit number of the separate spec.
88 -- This call does not generate any warning messages, but instead may
89 -- result in flags being set in the N_With_Clause node that record that
90 -- there was no use in the spec.
92 -- The main call (made after all units have been analyzed, with Spec_Unit
93 -- set to the default value of No_Unit) generates the required warnings
94 -- using the flags set by the initial call where appropriate to specialize
95 -- the text of the warning messages.
97 ---------------------
98 -- Output Routines --
99 ---------------------
101 procedure Output_Unreferenced_Messages;
102 -- Warnings about unreferenced entities are collected till the end of
103 -- the compilation process (see Check_Unset_Reference for further
104 -- details). This procedure outputs waiting warnings, if any.
106 ----------------------------
107 -- Other Warning Routines --
108 ----------------------------
110 procedure Warn_On_Known_Condition (C : Node_Id);
111 -- C is a node for a boolean expression resluting from a relational
112 -- or membership operation. If the expression has a compile time known
113 -- value, then a warning is output if all the following conditions hold:
115 -- 1. Original expression comes from source. We don't want to generate
116 -- warnings for internally generated conditionals.
118 -- 2. As noted above, the expression is a relational or membership
119 -- test, we don't want to generate warnings for boolean variables
120 -- since this is typical of conditional compilation in Ada.
122 -- 3. The expression appears in a statement, rather than a declaration.
123 -- In practice, most occurrences in declarations are legitimate
124 -- conditionalizations, but occurrences in statements are often
125 -- errors for which the warning is useful.
127 -- 4. The expression does not occur within an instantiation. A non-
128 -- static expression in a generic may become constant because of
129 -- the attributes of the actuals, and we do not want to warn on
130 -- these legitimate constant foldings.
132 -- If all these conditions are met, the warning is issued noting that
133 -- the result of the test is always false or always true as appropriate.
135 end Sem_Warn;