Syntax:
pragma Unreferenced (LOCAL_NAME {, LOCAL_NAME}); pragma Unreferenced (library_unit_NAME {, library_unit_NAME});
This pragma signals that the entities whose names are listed are deliberately not referenced in the current source unit after the occurrence of the pragma. This suppresses warnings about the entities being unreferenced, and in addition a warning will be generated if one of these entities is in fact subsequently referenced in the same unit as the pragma (or in the corresponding body, or one of its subunits).
This is particularly useful for clearly signaling that a particular parameter is not referenced in some particular subprogram implementation and that this is deliberate. It can also be useful in the case of objects declared only for their initialization or finalization side effects.
If LOCAL_NAME
identifies more than one matching homonym in the
current scope, then the entity most recently declared is the one to which
the pragma applies. Note that in the case of accept formals, the pragma
Unreferenced may appear immediately after the keyword do
which
allows the indication of whether or not accept formals are referenced
or not to be given individually for each accept statement.
The left hand side of an assignment does not count as a reference for the purpose of this pragma. Thus it is fine to assign to an entity for which pragma Unreferenced is given.
Note that if a warning is desired for all calls to a given subprogram, regardless of whether they occur in the same unit as the subprogram declaration, then this pragma should not be used (calls from another unit would not be flagged); pragma Obsolescent can be used instead for this purpose, see Pragma Obsolescent.
The second form of pragma Unreferenced
is used within a context
clause. In this case the arguments must be unit names of units previously
mentioned in with
clauses (similar to the usage of pragma
Elaborate_All
. The effect is to suppress warnings about unreferenced
units and unreferenced entities within these units.
For the variable case, warnings are never given for unreferenced variables
whose name contains one of the substrings
DISCARD, DUMMY, IGNORE, JUNK, UNUSED
in any casing. Such names
are typically to be used in cases where such warnings are expected.
Thus it is never necessary to use pragma Unreferenced
for such
variables, though it is harmless to do so.