From: Robert Dewar Date: Tue, 25 Feb 2014 15:19:43 +0000 (+0000) Subject: binde.adb: Change messages to mention -gnatel instead of -gnatwl. X-Git-Tag: releases/gcc-4.9.0~682 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe2194dfff5f72512520193c39566b875f0a3ae7;p=thirdparty%2Fgcc.git binde.adb: Change messages to mention -gnatel instead of -gnatwl. 2014-02-25 Robert Dewar * 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 From-SVN: r208139 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 91cf5aeefee1..27060c7aebdc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2014-02-25 Robert Dewar + + * 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 * einfo.ads, einfo.adb (Has_Shift_Operator): New flag. diff --git a/gcc/ada/binde.adb b/gcc/ada/binde.adb index 1e79756de4ee..935e09e9d73f 100644 --- a/gcc/ada/binde.adb +++ b/gcc/ada/binde.adb @@ -1023,7 +1023,7 @@ package body Binde is Info => True); Error_Msg_Output - (" recompile $ with -gnatwl for full details", + (" recompile $ with -gnatel for full details", Info => True); when Elab_Desirable => @@ -1032,7 +1032,7 @@ package body Binde is Info => True); Error_Msg_Output - (" recompile $ with -gnatwl for full details", + (" recompile $ with -gnatel for full details", Info => True); when Spec_First => diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 54a0a5c01e38..dddd827017bf 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -3822,6 +3822,21 @@ Indicates that the source is a multi-unit source and that the index of the 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 @@ -4922,7 +4937,7 @@ gnat_rm, GNAT Reference manual}. 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) @@ -5280,32 +5295,19 @@ is defined in package Standard. @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.} @@ -25046,7 +25048,7 @@ elaboration code in your own application). * 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:: @@ -25913,8 +25915,8 @@ guaranteed. 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: @@ -25938,8 +25940,8 @@ likely that the binder will be able to honor it. However, if you want 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 @@ -25948,8 +25950,8 @@ switch, then the compiler outputs a warning: 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 @@ -25957,10 +25959,10 @@ switch, then the compiler outputs a warning: @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. @@ -26471,7 +26473,7 @@ diagnostics. For example: 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: @@ -26631,7 +26633,7 @@ the following diagnostics: 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)" @@ -26672,9 +26674,9 @@ It is certainly simple enough to use 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^} @@ -26704,9 +26706,10 @@ elaboration switch if your code is correct, and we assume that the 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 @@ -26719,7 +26722,15 @@ Access-to-subprogram types, however, are handled conservatively, and 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 @@ -26731,9 +26742,9 @@ the special elaboration control switches. If the binder successfully 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 diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index c52435b31a5b..4031121bde95 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -509,9 +509,13 @@ package Opt is -- 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 diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 87db5eee60df..6fb1c856696a 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -867,7 +867,7 @@ package body Sem_Elab is 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 @@ -877,8 +877,9 @@ package body Sem_Elab is 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 -- @@ -890,12 +891,21 @@ package body Sem_Elab is 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; @@ -907,15 +917,15 @@ package body Sem_Elab is 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 @@ -926,13 +936,13 @@ package body Sem_Elab is 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; @@ -942,13 +952,13 @@ package body Sem_Elab is 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; @@ -1018,17 +1028,17 @@ package body Sem_Elab is -- 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 @@ -2540,13 +2550,13 @@ package body Sem_Elab is 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; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index d61c02bf90c2..96bd85b3e273 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -13333,8 +13333,8 @@ package body Sem_Prag is 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 diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index 201a99d1619c..6848d61652ff 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -588,6 +588,18 @@ package body Switch.C is 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' => diff --git a/gcc/ada/switch-m.adb b/gcc/ada/switch-m.adb index c9ac972dda7d..575b1aad634a 100644 --- a/gcc/ada/switch-m.adb +++ b/gcc/ada/switch-m.adb @@ -331,6 +331,7 @@ package body Switch.M is when 'i' | 'I' => declare First : constant Positive := Ptr; + begin Ptr := Ptr + 1; @@ -354,6 +355,14 @@ package body Switch.M is 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; diff --git a/gcc/ada/ug_words b/gcc/ada/ug_words index c16da0402079..d8d7f45342e7 100644 --- a/gcc/ada/ug_words +++ b/gcc/ada/ug_words @@ -68,6 +68,8 @@ gcc -c ^ GNAT COMPILE -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 diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index 0b50555c2466..79aa648c636b 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -218,6 +218,16 @@ begin 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=?"); @@ -512,10 +522,8 @@ begin 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 " & diff --git a/gcc/ada/vms_data.ads b/gcc/ada/vms_data.ads index 42aaffe4955d..f28b9bf07323 100644 --- a/gcc/ada/vms_data.ads +++ b/gcc/ada/vms_data.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- --- -- +-- -- -- V M S _ D A T A -- -- -- -- S p e c -- @@ -1570,7 +1570,20 @@ package VMS_Data is 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#"; @@ -3822,6 +3835,7 @@ package VMS_Data is 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, @@ -3857,6 +3871,7 @@ package VMS_Data is 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, diff --git a/gcc/ada/warnsw.adb b/gcc/ada/warnsw.adb index 009b450784c5..5cb12ad860c7 100644 --- a/gcc/ada/warnsw.adb +++ b/gcc/ada/warnsw.adb @@ -47,6 +47,8 @@ package body Warnsw is 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 := @@ -141,6 +143,8 @@ package body Warnsw is 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 := diff --git a/gcc/ada/warnsw.ads b/gcc/ada/warnsw.ads index 0358fd77d4fb..fd6027b6e9ec 100644 --- a/gcc/ada/warnsw.ads +++ b/gcc/ada/warnsw.ads @@ -65,6 +65,7 @@ package Warnsw is 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;