+2014-02-25 Robert Dewar <dewar@adacore.com>
+
+ * binde.adb: Change messages to mention -gnatel instead of -gnatwl.
+ * gnat_ugn.texi: Update documentation of -gnatwl Add documentation
+ of -gnatel/-gnateL.
+ * opt.ads (Warn_Info_Messages): New flag.
+ * sem_elab.adb: Use Elab_Warnings, Elab_Info_Messages to control
+ messages.
+ * sem_prag.adb: Use Elab_Warnings, Elab_Info_Messages to control
+ messages.
+ * switch-m.ad, switch-c.adb: Recognize new -gnatel/EL switches.
+ * usage.adb: Add documentation of -gnatel/-gnateL Update
+ documentation of -gnatwl/-gnatwL.
+ * warnsw.adb: New handling of Elab_Warnings, Elab_Info_Messages
+ * warnsw.ads (Elab_Info_Messages): New field in Warning_Record
+
2014-02-25 Robert Dewar <dewar@adacore.com>
* einfo.ads, einfo.adb (Has_Shift_Operator): New flag.
Info => True);
Error_Msg_Output
- (" recompile $ with -gnatwl for full details",
+ (" recompile $ with -gnatel for full details",
Info => True);
when Elab_Desirable =>
Info => True);
Error_Msg_Output
- (" recompile $ with -gnatwl for full details",
+ (" recompile $ with -gnatel for full details",
Info => True);
when Spec_First =>
unit to compile is @var{nnn}. @var{nnn} needs to be a positive number and need
to be a valid index in the multi-unit source.
+@item -gnatel
+@cindex @option{-gnatel} (@command{gcc})
+This switch can be used with the static elaboration model to issue info
+messages showing
+where implicit @code{pragma Elaborate} and @code{pragma Elaborate_All}
+are generated. This is useful in diagnosing elaboration circularities
+caused by these implicit pragmas when using the static elaboration
+model. See See the section in this guide on elaboration checking for
+further details. These messages are not generated by default, and are
+intended only for temporary use when debugging circularity problems.
+
+@item -gnateL
+@cindex @option{-gnatel} (@command{gcc})
+This switch turns off the info messages about implicit elaboration pragmas.
+
@item -gnatem=@var{path}
@cindex @option{-gnatem} (@command{gcc})
Specify a mapping file
This switch activates most optional warning messages. See the remaining list
in this section for details on optional warning messages that can be
individually controlled. The warnings that are not turned on by this
-switch are
+switch are:
@option{-gnatwd} (implicit dereferencing),
@option{-gnatwh} (hiding),
@option{-gnatw.d} (tag warnings with -gnatw switch)
@cindex @option{-gnatwl} (@command{gcc})
@cindex Elaboration, warnings
This switch activates warnings on missing
-@code{Elaborate_All} and @code{Elaborate} pragmas.
-See the section in this guide on elaboration checking for details on
-when such pragmas should be used. In dynamic elaboration mode, this switch
-generations warnings about the need to add elaboration pragmas. Note however,
-that if you blindly follow these warnings, and add @code{Elaborate_All}
-warnings wherever they are recommended, you basically end up with the
-equivalent of the static elaboration model, which may not be what you want for
-legacy code for which the static model does not work.
-
-For the static model, the messages generated are labeled "info:" (for
-information messages). They are not warnings to add elaboration pragmas,
-merely informational messages showing what implicit elaboration pragmas
-have been added, for use in analyzing elaboration circularity problems.
-
-Warnings are also generated if you
-are using the static mode of elaboration, and a @code{pragma Elaborate}
-is encountered. The default is that such warnings
+for possible elaboration problems, including suspicious use
+of @code{Elaborate} pragmas, when using the static elaboration model, and
+possible situations that may raise @code{Program_Error} when using the
+dynamic elaboration model.
+See the section in this guide on elaboration checking for further details.
+The default is that such warnings
are not generated.
This warning is not automatically turned on by the use of @option{-gnatwa}.
@item -gnatwL
@emph{Suppress warnings for elaboration pragmas.}
@cindex @option{-gnatwL} (@command{gcc})
-This switch suppresses warnings on missing Elaborate and Elaborate_All pragmas.
-See the section in this guide on elaboration checking for details on
-when such pragmas should be used.
+This switch suppresses warnings for possible elaboration problems.
@item -gnatw.l
@emph{List inherited aspects.}
* Elaboration Issues for Library Tasks::
* Mixing Elaboration Models::
* What to Do If the Default Elaboration Behavior Fails::
-* Elaboration for Dispatching Calls::
+* Elaboration for Indirect Calls::
* Summary of Procedures for Elaboration Control::
* Other Elaboration Order Considerations::
* Determining the Chosen Elaboration Order::
If it is important to guarantee portability, then the compilations should
use the
-@option{-gnatwl}
-(warn on elaboration problems) switch. This will cause warning messages
+@option{-gnatel}
+(info messages for elaboration prag mas) switch. This will cause info messages
to be generated indicating the missing @code{Elaborate} and
@code{Elaborate_All} pragmas.
Consider the following source program:
to port this program to some other Ada compiler than GNAT.
it is safer to include the pragma explicitly in the source. If this
unit is compiled with the
-@option{-gnatwl}
-switch, then the compiler outputs a warning:
+@option{-gnatel}
+switch, then the compiler outputs an information message:
@smallexample
@group
2. package j is
3. m : integer := k.r;
|
- >>> warning: call to "r" may raise Program_Error
- >>> warning: missing pragma Elaborate_All for "k"
+ >>> info: call to "r" may raise Program_Error
+ >>> info: missing pragma Elaborate_All for "k"
4. end;
@end cartouche
@end smallexample
@noindent
-and these warnings can be used as a guide for supplying manually
-the missing pragmas. It is usually a bad idea to use this warning
-option during development. That's because it will warn you when
-you need to put in a pragma, but cannot warn you when it is time
+and these messages can be used as a guide for supplying manually
+the missing pragmas. It is usually a bad idea to use this
+option during development. That's because it will tell you when
+you need to put in a pragma, but cannot tell you when it is time
to take it out. So the use of pragma @code{Elaborate_All} may lead to
unnecessary dependencies and even false circularities.
error: elaboration circularity detected
info: "proc (body)" must be elaborated before "pack (body)"
info: reason: Elaborate_All probably needed in unit "pack (body)"
-info: recompile "pack (body)" with -gnatwl
+info: recompile "pack (body)" with -gnatel
info: for full details
info: "proc (body)"
info: is needed by its spec:
error: elaboration circularity detected
info: "pack1 (body)" must be elaborated before "pack1 (body)"
info: reason: Elaborate_All probably needed in unit "pack1 (body)"
-info: recompile "pack1 (body)" with -gnatwl for full details
+info: recompile "pack1 (body)" with -gnatel for full details
info: "pack1 (body)"
info: must be elaborated along with its spec:
info: "pack1 (spec)"
but the danger in this case is that, even if the GNAT binder
finds a correct elaboration order, it may not always do so,
and certainly a binder from another Ada compiler might not. A
-combination of testing and analysis (for which the warnings generated
-with the
-@option{-gnatwl}
+combination of testing and analysis (for which the
+information messages generated with the
+@option{-gnatel}
switch can be useful) must be used to ensure that the program is free
of errors. One switch that is useful in this testing is the
@option{^-p (pessimistic elaboration order)^/PESSIMISTIC_ELABORATION_ORDER^}
C-tests are indeed correct (it is less efficient, but efficiency is
not a factor in running the ACVC tests.)
-@node Elaboration for Dispatching Calls
-@section Elaboration for Dispatching Calls
+@node Elaboration for Indirect Calls
+@section Elaboration for Indirect Calls
@cindex Dispatching calls
+@cindex Indirect calls
@noindent
In rare cases, the static elaboration model fails to prevent
do not require run-time checks. This was not true in earlier versions
of the compiler; you can use the @option{-gnatd.U} debug switch to
revert to the old behavior if the new conservative behavior causes
-elaboration cycles.
+elaboration cycles. Here, ``conservative'' means that if you do
+@code{P'Access} during elaboration, the compiler will assume that you
+might call @code{P} indirectly during elaboration, so it adds an
+implicit @code{pragma Elaborate_All} on the library unit containing
+@code{P}. The @option{-gnatd.U} switch is safe if you know there are
+no such calls. If the program worked before, it will continue to work
+with @option{-gnatd.U}. But beware that code modifications such as
+adding an indirect call can cause erroneous behavior in the presence
+of @option{-gnatd.U}.
@node Summary of Procedures for Elaboration Control
@section Summary of Procedures for Elaboration Control
binds your program, then you can be confident that, apart from issues
raised by the use of access-to-subprogram types and dynamic dispatching,
the program is free of elaboration errors. If it is important that the
-program be portable, then use the
-@option{-gnatwl}
-switch to generate warnings about missing @code{Elaborate} or
+program be portable to other compilers than GNAT, then use the
+@option{-gnatel}
+switch to generate messages about missing @code{Elaborate} or
@code{Elaborate_All} pragmas, and supply the missing pragmas.
If the program fails to bind using the default static elaboration
-- GNATBIND
-- Set to True to output chosen elaboration order
+ Elab_Info_Messages : Boolean := False;
+ -- GNAT
+ -- Set to True to output info messages for static elabmodel (-gnatel)
+
Elab_Warnings : Boolean := False;
-- GNAT
- -- Set to True to generate full elaboration warnings (-gnatwl)
+ -- Set to True to generate elaboration warnings (-gnatwl)
Error_Msg_Line_Length : Nat := 0;
-- GNAT
and then not Elaboration_Checks_Suppressed (Ent)
and then not Suppress_Elaboration_Warnings (E_Scope)
and then not Elaboration_Checks_Suppressed (E_Scope)
- and then Elab_Warnings
+ and then (Elab_Warnings or Elab_Info_Messages)
and then Generate_Warnings
then
Generate_Elab_Warnings : declare
Ent : Node_Or_Entity_Id);
-- Generate a call to Error_Msg_NE with parameters Msg_D or
-- Msg_S (for dynamic or static elaboration model), N and Ent.
- -- Msg_D is suppressed for the attribute reference case, since
- -- we never raise Program_Error for an attribute reference.
+ -- Msg_D is a real warning (output if Msg_D is non-null and
+ -- Elab_Warnings is set), Msg_S is an info message (output if
+ -- Elab_Info_Messages is set.
------------------
-- Elab_Warning --
Ent : Node_Or_Entity_Id)
is
begin
+ -- Dynamic elaboration checks, real warning
+
if Dynamic_Elaboration_Checks then
if not Access_Case then
- Error_Msg_NE (Msg_D, N, Ent);
+ if Msg_D /= "" and then Elab_Warnings then
+ Error_Msg_NE (Msg_D, N, Ent);
+ end if;
end if;
+
+ -- Static elaboration checks, info message
+
else
- Error_Msg_NE (Msg_S, N, Ent);
+ if Elab_Info_Messages then
+ Error_Msg_NE (Msg_S, N, Ent);
+ end if;
end if;
end Elab_Warning;
if Inst_Case then
Elab_Warning
("instantiation of& may raise Program_Error?l?",
- "info: instantiation of& during elaboration?l?", Ent);
+ "info: instantiation of& during elaboration?", Ent);
- -- Indirect call case, warning only in static elaboration
+ -- Indirect call case, info message only in static elaboration
-- case, because the attribute reference itself cannot raise
-- an exception.
elsif Access_Case then
Elab_Warning
- ("", "info: access to& during elaboration?l?", Ent);
+ ("", "info: access to& during elaboration?", Ent);
-- Subprogram call case
then
Elab_Warning
("implicit call to & may raise Program_Error?l?",
- "info: implicit call to & during elaboration?l?",
+ "info: implicit call to & during elaboration?",
Ent);
else
Elab_Warning
("call to & may raise Program_Error?l?",
- "info: call to & during elaboration?l?",
+ "info: call to & during elaboration?",
Ent);
end if;
end if;
if Nkind (N) in N_Subprogram_Instantiation then
Elab_Warning
("\missing pragma Elaborate for&?l?",
- "\info: implicit pragma Elaborate for& generated?l?",
+ "\info: implicit pragma Elaborate for& generated?",
W_Scope);
else
Elab_Warning
("\missing pragma Elaborate_All for&?l?",
- "\info: implicit pragma Elaborate_All for & generated?l?",
+ "\info: implicit pragma Elaborate_All for & generated?",
W_Scope);
end if;
end Generate_Elab_Warnings;
-- Here we need to generate an implicit elaborate all
else
- -- Generate elaborate_all warning unless suppressed
+ -- Generate Elaborate_all warning unless suppressed
- if (Elab_Warnings and Generate_Warnings and not Inst_Case)
+ if (Elab_Info_Messages and Generate_Warnings and not Inst_Case)
and then not Suppress_Elaboration_Warnings (Ent)
and then not Suppress_Elaboration_Warnings (E_Scope)
and then not Suppress_Elaboration_Warnings (W_Scope)
then
Error_Msg_Node_2 := W_Scope;
Error_Msg_NE
- ("call to& in elaboration code " &
- "requires pragma Elaborate_All on&?l?", N, E);
+ ("info: call to& in elaboration code " &
+ "requires pragma Elaborate_All on&?", N, E);
end if;
-- Set indication for binder to generate Elaborate_All
if not Suppress_Elaboration_Warnings (Ent)
and then not Elaboration_Checks_Suppressed (Ent)
- and then Elab_Warnings
+ and then Elab_Info_Messages
and then not Suppress_Elaboration_Warnings (Task_Scope)
and then not Elaboration_Checks_Suppressed (Task_Scope)
then
Error_Msg_Node_2 := Task_Scope;
Error_Msg_NE
- ("activation of an instance of task type&" &
+ ("info: activation of an instance of task type&" &
" requires pragma Elaborate_All on &?l?", N, Ent);
end if;
Next (Arg);
end loop Outer;
- -- Give a warning if operating in static mode with -gnatwl
- -- (elaboration warnings enabled) switch set.
+ -- Give a warning if operating in static mode with one of the
+ -- gnatwl/-gnatwE (elaboration warnings enabled) switches set.
if Elab_Warnings and not Dynamic_Elaboration_Checks then
Error_Msg_N
Ptr := Ptr + 1;
Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
+ -- -gnatel
+
+ when 'l' =>
+ Ptr := Ptr + 1;
+ Elab_Info_Messages := True;
+
+ -- -gnateL
+
+ when 'L' =>
+ Ptr := Ptr + 1;
+ Elab_Info_Messages := False;
+
-- -gnatem (mapping file)
when 'm' =>
when 'i' | 'I' =>
declare
First : constant Positive := Ptr;
+
begin
Ptr := Ptr + 1;
First_Stored + Ptr - First));
end;
+ when 'l' =>
+ Ptr := Ptr + 1;
+ Add_Switch_Component ("-gnatel");
+
+ when 'L' =>
+ Ptr := Ptr + 1;
+ Add_Switch_Component ("-gnateL");
+
when 'p' =>
Ptr := Ptr + 1;
-gnateG ^ /GENERATE_PROCESSED_SOURCE
-gnatei ^ /MAX_INSTANTIATIONS=
-gnateI ^ /MULTI_UNIT_INDEX=
+-gnatel ^ /ELABORATION_INFO_MESSAGES
+-gnateL ^ /NOELABORATION_INFO_MESSAGES
-gnatem ^ /MAPPING_FILE
-gnatep ^ /DATA_PREPROCESSING
-gnateP ^ /CATEGORIZATION_WARNINGS
Write_Switch_Char ("eInn");
Write_Line ("Index in multi-unit source, e.g. -gnateI2");
+ -- Line for -gnatel switch
+
+ Write_Switch_Char ("el");
+ Write_Line ("Turn on info messages on generated Elaborate[_All] pragmas");
+
+ -- Line for -gnateL switch
+
+ Write_Switch_Char ("eL");
+ Write_Line ("Turn off info messages on generated Elaborate[_All] pragmas");
+
-- Line for -gnatem switch
Write_Switch_Char ("em=?");
Write_Line (" K* turn off warnings on constant variable");
Write_Line (" .k turn on warnings for standard redefinition");
Write_Line (" .K* turn off warnings for standard redefinition");
- Write_Line (" l turn on warnings for missing " &
- "elaboration pragma");
- Write_Line (" L* turn off warnings for missing " &
- "elaboration pragma");
+ Write_Line (" l turn on warnings for elaboration problems");
+ Write_Line (" L* turn off warnings for elaboration problems");
Write_Line (" .l turn on info messages for inherited aspects");
Write_Line (" .L* turn off info messages for inherited aspects");
Write_Line (" m+ turn on warnings for variable assigned " &
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
--- --
+-- --
-- V M S _ D A T A --
-- --
-- S p e c --
S_GCC_DistX : aliased constant S := "/NODISTRIBUTION_STUBS " &
"!-gnatzr,!-gnatzc";
- -- NODOC (see /DISTRIBUTION_STUBS)
+ -- NODISTRIBUTION_STUBS (see /DISTRIBUTION_STUBS)
+
+ S_GCC_ElabI : aliased constant S := "/ELABORATION_INFO_MESSAGES " &
+ "-gnatel";
+ -- ELABORATION_INFO_MESSAGES
+ --
+ -- Causes the compiler to output INFO messages that show where implicit
+ -- Elaborate and Elaborate_All pragmas are added when using the static
+ -- elaboration model. Used to diagnose binder circularities when this
+ -- elaboration model is used.
+
+ S_GCC_NoElabI : aliased constant S := "/NOELABORATION_INFO_MESSAGES " &
+ "-gnateL";
+ -- Turns off elaboration info messages (see ELABORATION_INFO_MESSAGES)
S_GCC_Error : aliased constant S := "/ERROR_LIMIT=#" &
"-gnatm#";
S_GCC_DisAtom 'Access,
S_GCC_Dist 'Access,
S_GCC_DistX 'Access,
+ S_GCC_ElabI 'Access,
S_GCC_Error 'Access,
S_GCC_ErrorX 'Access,
S_GCC_Expand 'Access,
S_GCC_Mess 'Access,
S_GCC_Nesting 'Access,
S_GCC_Noadc 'Access,
+ S_GCC_NoElabI 'Access,
S_GCC_Noload 'Access,
S_GCC_Nostinc 'Access,
S_GCC_Nostlib 'Access,
W.Constant_Condition_Warnings;
Elab_Warnings :=
W.Elab_Warnings;
+ Elab_Info_Messages :=
+ W.Elab_Info_Messages;
Implementation_Unit_Warnings :=
W.Implementation_Unit_Warnings;
Ineffective_Inline_Warnings :=
Check_Withs;
W.Constant_Condition_Warnings :=
Constant_Condition_Warnings;
+ W.Elab_Info_Messages :=
+ Elab_Info_Messages;
W.Elab_Warnings :=
Elab_Warnings;
W.Implementation_Unit_Warnings :=
Check_Unreferenced_Formals : Boolean;
Check_Withs : Boolean;
Constant_Condition_Warnings : Boolean;
+ Elab_Info_Messages : Boolean;
Elab_Warnings : Boolean;
Implementation_Unit_Warnings : Boolean;
Ineffective_Inline_Warnings : Boolean;