+2019-08-14 Bob Duff <duff@adacore.com>
+
+ * sem_prag.ads, sem_prag.adb
+ (Process_Compile_Time_Warning_Or_Error): In parameterless
+ version, improve detection of whether we are in a generic unit
+ to cover the case of an instance within a generic unit.
+ (Process_Compile_Time_Warning_Or_Error): Rename the
+ two-parameter version to be
+ Validate_Compile_Time_Warning_Or_Error, and do not export it.
+ Issue a warning if the condition is not known at compile time.
+ The key point is that the warning must be given only for pragmas
+ deferred to the back end, because the back end discovers
+ additional values that are known at compile time. Previous
+ changes in this ticket have enabled this by deferring to the
+ back end without checking for special cases such as 'Size.
+ (Validate_Compile_Time_Warning_Or_Error): Rename to be
+ Defer_Compile_Time_Warning_Error_To_BE.
+ * warnsw.ads, warnsw.adb (Warn_On_Unknown_Compile_Time_Warning):
+ Add new switches -gnatw_c and -gnatw_C to control the above
+ warning.
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst:
+ Document new switches.
+ * gnat_ugn.texi: Regenerate.
+
2019-08-14 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch12.adb (Might_Inline_Subp): Rework comment and restrict
component for which no component clause is present.
-.. index:: -gnatwC (gcc)
+.. index:: -gnatw.C (gcc)
:switch:`-gnatw.C`
*Suppress warnings on missing component clauses.*
missing a component clause in the situation described above.
+.. index:: -gnatw_c (gcc)
+
+:switch:`-gnatw_c`
+ *Activate warnings on unknown condition in Compile_Time_Warning.*
+
+ .. index:: Compile_Time_Warning
+ .. index:: Compile_Time_Error
+
+ This switch activates warnings on a pragma Compile_Time_Warning
+ or Compile_Time_Error whose condition has a value that is not
+ known at compile time.
+ The default is that such warnings are generated.
+
+
+.. index:: -gnatw_C (gcc)
+
+:switch:`-gnatw_C`
+ *Suppress warnings on missing component clauses.*
+
+ This switch supresses warnings on a pragma Compile_Time_Warning
+ or Compile_Time_Error whose condition has a value that is not
+ known at compile time.
+
+
.. index:: -gnatwd (gcc)
:switch:`-gnatwd`
@copying
@quotation
-GNAT User's Guide for Native Platforms , Jul 31, 2019
+GNAT User's Guide for Native Platforms , Aug 01, 2019
AdaCore
component for which no component clause is present.
@end table
-@geindex -gnatwC (gcc)
+@geindex -gnatw.C (gcc)
@table @asis
missing a component clause in the situation described above.
@end table
+@geindex -gnatw_c (gcc)
+
+
+@table @asis
+
+@item @code{-gnatw_c}
+
+@emph{Activate warnings on unknown condition in Compile_Time_Warning.}
+
+@geindex Compile_Time_Warning
+
+@geindex Compile_Time_Error
+
+This switch activates warnings on a pragma Compile_Time_Warning
+or Compile_Time_Error whose condition has a value that is not
+known at compile time.
+The default is that such warnings are generated.
+@end table
+
+@geindex -gnatw_C (gcc)
+
+
+@table @asis
+
+@item @code{-gnatw_C}
+
+@emph{Suppress warnings on missing component clauses.}
+
+This switch supresses warnings on a pragma Compile_Time_Warning
+or Compile_Time_Error whose condition has a value that is not
+known at compile time.
+@end table
+
@geindex -gnatwd (gcc)
It first describes some of the tradeoffs that need to be considered
and some of the techniques for making your program run faster.
-
It then documents the unused subprogram/data elimination feature,
which can reduce the size of program executables.
@geindex Checks (overflow)
-
@node Overflow Check Handling in GNAT,Performing Dimensionality Analysis in GNAT,Improving Performance,GNAT and Program Execution
-@anchor{gnat_ugn/gnat_and_program_execution id50}@anchor{169}@anchor{gnat_ugn/gnat_and_program_execution overflow-check-handling-in-gnat}@anchor{27}
+@anchor{gnat_ugn/gnat_and_program_execution id45}@anchor{169}@anchor{gnat_ugn/gnat_and_program_execution overflow-check-handling-in-gnat}@anchor{27}
@section Overflow Check Handling in GNAT
@end menu
@node Background,Management of Overflows in GNAT,,Overflow Check Handling in GNAT
-@anchor{gnat_ugn/gnat_and_program_execution id51}@anchor{1bb}@anchor{gnat_ugn/gnat_and_program_execution background}@anchor{1bc}
+@anchor{gnat_ugn/gnat_and_program_execution id46}@anchor{1bb}@anchor{gnat_ugn/gnat_and_program_execution background}@anchor{1bc}
@subsection Background
would prefer this precondition to be considered True at run time).
@node Management of Overflows in GNAT,Specifying the Desired Mode,Background,Overflow Check Handling in GNAT
-@anchor{gnat_ugn/gnat_and_program_execution management-of-overflows-in-gnat}@anchor{1bd}@anchor{gnat_ugn/gnat_and_program_execution id52}@anchor{1be}
+@anchor{gnat_ugn/gnat_and_program_execution id47}@anchor{1bd}@anchor{gnat_ugn/gnat_and_program_execution management-of-overflows-in-gnat}@anchor{1be}
@subsection Management of Overflows in GNAT
range checks).
@node Specifying the Desired Mode,Default Settings,Management of Overflows in GNAT,Overflow Check Handling in GNAT
-@anchor{gnat_ugn/gnat_and_program_execution specifying-the-desired-mode}@anchor{f8}@anchor{gnat_ugn/gnat_and_program_execution id53}@anchor{1bf}
+@anchor{gnat_ugn/gnat_and_program_execution specifying-the-desired-mode}@anchor{f8}@anchor{gnat_ugn/gnat_and_program_execution id48}@anchor{1bf}
@subsection Specifying the Desired Mode
type (@code{STRICT} mode).
@node Default Settings,Implementation Notes,Specifying the Desired Mode,Overflow Check Handling in GNAT
-@anchor{gnat_ugn/gnat_and_program_execution id54}@anchor{1c0}@anchor{gnat_ugn/gnat_and_program_execution default-settings}@anchor{1c1}
+@anchor{gnat_ugn/gnat_and_program_execution id49}@anchor{1c0}@anchor{gnat_ugn/gnat_and_program_execution default-settings}@anchor{1c1}
@subsection Default Settings
intermediate results.
@node Implementation Notes,,Default Settings,Overflow Check Handling in GNAT
-@anchor{gnat_ugn/gnat_and_program_execution id55}@anchor{1c2}@anchor{gnat_ugn/gnat_and_program_execution implementation-notes}@anchor{1c3}
+@anchor{gnat_ugn/gnat_and_program_execution implementation-notes}@anchor{1c2}@anchor{gnat_ugn/gnat_and_program_execution id50}@anchor{1c3}
@subsection Implementation Notes
platforms).
@node Performing Dimensionality Analysis in GNAT,Stack Related Facilities,Overflow Check Handling in GNAT,GNAT and Program Execution
-@anchor{gnat_ugn/gnat_and_program_execution id56}@anchor{16a}@anchor{gnat_ugn/gnat_and_program_execution performing-dimensionality-analysis-in-gnat}@anchor{28}
+@anchor{gnat_ugn/gnat_and_program_execution performing-dimensionality-analysis-in-gnat}@anchor{28}@anchor{gnat_ugn/gnat_and_program_execution id51}@anchor{16a}
@section Performing Dimensionality Analysis in GNAT
dimension vector for the formal parameter).
@node Stack Related Facilities,Memory Management Issues,Performing Dimensionality Analysis in GNAT,GNAT and Program Execution
-@anchor{gnat_ugn/gnat_and_program_execution id57}@anchor{16b}@anchor{gnat_ugn/gnat_and_program_execution stack-related-facilities}@anchor{29}
+@anchor{gnat_ugn/gnat_and_program_execution stack-related-facilities}@anchor{29}@anchor{gnat_ugn/gnat_and_program_execution id52}@anchor{16b}
@section Stack Related Facilities
@end menu
@node Stack Overflow Checking,Static Stack Usage Analysis,,Stack Related Facilities
-@anchor{gnat_ugn/gnat_and_program_execution id58}@anchor{1c4}@anchor{gnat_ugn/gnat_and_program_execution stack-overflow-checking}@anchor{f4}
+@anchor{gnat_ugn/gnat_and_program_execution id53}@anchor{1c4}@anchor{gnat_ugn/gnat_and_program_execution stack-overflow-checking}@anchor{f4}
@subsection Stack Overflow Checking
operating system documentation.
@node Static Stack Usage Analysis,Dynamic Stack Usage Analysis,Stack Overflow Checking,Stack Related Facilities
-@anchor{gnat_ugn/gnat_and_program_execution static-stack-usage-analysis}@anchor{f5}@anchor{gnat_ugn/gnat_and_program_execution id59}@anchor{1c5}
+@anchor{gnat_ugn/gnat_and_program_execution id54}@anchor{1c5}@anchor{gnat_ugn/gnat_and_program_execution static-stack-usage-analysis}@anchor{f5}
@subsection Static Stack Usage Analysis
bytes. The wording is in keeping with the qualifier documented above.
@node Dynamic Stack Usage Analysis,,Static Stack Usage Analysis,Stack Related Facilities
-@anchor{gnat_ugn/gnat_and_program_execution dynamic-stack-usage-analysis}@anchor{122}@anchor{gnat_ugn/gnat_and_program_execution id60}@anchor{1c6}
+@anchor{gnat_ugn/gnat_and_program_execution id55}@anchor{1c6}@anchor{gnat_ugn/gnat_and_program_execution dynamic-stack-usage-analysis}@anchor{122}
@subsection Dynamic Stack Usage Analysis
stack-usage reports at run time. See its body for the details.
@node Memory Management Issues,,Stack Related Facilities,GNAT and Program Execution
-@anchor{gnat_ugn/gnat_and_program_execution id61}@anchor{16c}@anchor{gnat_ugn/gnat_and_program_execution memory-management-issues}@anchor{2a}
+@anchor{gnat_ugn/gnat_and_program_execution id56}@anchor{16c}@anchor{gnat_ugn/gnat_and_program_execution memory-management-issues}@anchor{2a}
@section Memory Management Issues
@end menu
@node Some Useful Memory Pools,The GNAT Debug Pool Facility,,Memory Management Issues
-@anchor{gnat_ugn/gnat_and_program_execution id62}@anchor{1c7}@anchor{gnat_ugn/gnat_and_program_execution some-useful-memory-pools}@anchor{1c8}
+@anchor{gnat_ugn/gnat_and_program_execution id57}@anchor{1c7}@anchor{gnat_ugn/gnat_and_program_execution some-useful-memory-pools}@anchor{1c8}
@subsection Some Useful Memory Pools
@end quotation
@node The GNAT Debug Pool Facility,,Some Useful Memory Pools,Memory Management Issues
-@anchor{gnat_ugn/gnat_and_program_execution id63}@anchor{1c9}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debug-pool-facility}@anchor{1ca}
+@anchor{gnat_ugn/gnat_and_program_execution id58}@anchor{1c9}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debug-pool-facility}@anchor{1ca}
@subsection The GNAT Debug Pool Facility
-- pragma. Entity name for unit and its parents is taken from item in
-- previous with_clause that mentions the unit.
- procedure Validate_Compile_Time_Warning_Error (N : Node_Id);
+ procedure Validate_Compile_Time_Warning_Or_Error
+ (N : Node_Id;
+ Eloc : Source_Ptr);
+ -- Common processing for Compile_Time_Error and Compile_Time_Warning of
+ -- pragma N. Called when the pragma is processed as part of its regular
+ -- analysis but also called after calling the back end to validate these
+ -- pragmas for size and alignment appropriateness.
+
+ procedure Defer_Compile_Time_Warning_Error_To_BE (N : Node_Id);
-- N is a pragma Compile_Time_Error or Compile_Warning_Error whose boolean
- -- expression is not known at compile time. This procedure makes an entry
- -- in a table. The actual checking is performed by Validate_Compile_Time_
- -- Warning_Errors, which is invoked after calling the back end.
+ -- expression is not known at compile time during the front end. This
+ -- procedure makes an entry in a table. The actual checking is performed by
+ -- Validate_Compile_Time_Warning_Errors, which is invoked after calling the
+ -- back end.
Dummy : Integer := 0;
pragma Volatile (Dummy);
-- pragma in the source program, a breakpoint on rv catches this place in
-- the source, allowing convenient stepping to the point of interest.
- ---------------------------------------------------
- -- Table for Validate_Compile_Time_Warning_Error --
- ---------------------------------------------------
+ ------------------------------------------------------
+ -- Table for Defer_Compile_Time_Warning_Error_To_BE --
+ ------------------------------------------------------
-- The following table collects pragmas Compile_Time_Error and Compile_
-- Time_Warning for validation. Entries are made by calls to subprogram
- -- Validate_Compile_Time_Warning_Error, and the call to the procedure
+ -- Defer_Compile_Time_Warning_Error_To_BE, and the call to the procedure
-- Validate_Compile_Time_Warning_Errors does the actual error checking
-- and posting of warning and error messages. The reason for this delayed
-- processing is to take advantage of back-annotations of attributes size
-------------------------------------------
procedure Process_Compile_Time_Warning_Or_Error is
+ P : Node_Id := Parent (N);
Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
begin
-- In GNATprove mode, pragmas Compile_Time_Error and
Check_Arg_Is_OK_Static_Expression (Arg2, Standard_String);
Analyze_And_Resolve (Arg1x, Standard_Boolean);
- -- If the condition is known at compile time (now), process it now.
+ -- If the condition is known at compile time (now), validate it now.
-- Otherwise, register the expression for validation after the back
-- end has been called, because it might be known at compile time
-- then. For example, if the expression is "Record_Type'Size /= 32"
-- it might be known after the back end has determined the size of
- -- Record_Type. We do not defer processing if we're inside a generic
+ -- Record_Type. We do not defer validation if we're inside a generic
-- unit, because we will have more information in the instances.
if Compile_Time_Known_Value (Arg1x) then
- Process_Compile_Time_Warning_Or_Error (N, Sloc (Arg1));
- elsif not Inside_A_Generic then
- Validate_Compile_Time_Warning_Error (N);
+ Validate_Compile_Time_Warning_Or_Error (N, Sloc (Arg1));
+ else
+ while Present (P) and then Nkind (P) not in N_Generic_Declaration
+ loop
+ if Nkind_In (P, N_Package_Body, N_Subprogram_Body) then
+ P := Corresponding_Spec (P);
+ else
+ P := Parent (P);
+ end if;
+ end loop;
+
+ if No (P) then
+ Defer_Compile_Time_Warning_Error_To_BE (N);
+ end if;
end if;
end Process_Compile_Time_Warning_Or_Error;
end Process_Compilation_Unit_Pragmas;
- -------------------------------------------
- -- Process_Compile_Time_Warning_Or_Error --
- -------------------------------------------
+ --------------------------------------------
+ -- Validate_Compile_Time_Warning_Or_Error --
+ --------------------------------------------
- procedure Process_Compile_Time_Warning_Or_Error
+ procedure Validate_Compile_Time_Warning_Or_Error
(N : Node_Id;
Eloc : Source_Ptr)
is
end loop;
end;
end if;
+
+ -- Arg1x is not known at compile time, so issue a warning. This can
+ -- happen only if the pragma's processing was deferred until after the
+ -- back end is run (see Process_Compile_Time_Warning_Or_Error).
+ -- Note that the warning control switch applies to both pragmas.
+
+ elsif Warn_On_Unknown_Compile_Time_Warning then
+ Error_Msg_N ("?condition is not known at compile time", Arg1x);
end if;
- end Process_Compile_Time_Warning_Or_Error;
+ end Validate_Compile_Time_Warning_Or_Error;
------------------------------------
-- Record_Possible_Body_Reference --
end Test_Case_Arg;
-----------------------------------------
- -- Validate_Compile_Time_Warning_Error --
+ -- Defer_Compile_Time_Warning_Error_To_BE --
-----------------------------------------
- procedure Validate_Compile_Time_Warning_Error (N : Node_Id) is
+ procedure Defer_Compile_Time_Warning_Error_To_BE (N : Node_Id) is
Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
begin
Compile_Time_Warnings_Errors.Append
(New_Val => CTWE_Entry'(Eloc => Sloc (Arg1),
Scope => Current_Scope,
Prag => N));
- end Validate_Compile_Time_Warning_Error;
+ end Defer_Compile_Time_Warning_Error_To_BE;
------------------------------------------
-- Validate_Compile_Time_Warning_Errors --
begin
Set_Scope (T.Scope);
Reset_Analyzed_Flags (T.Prag);
- Process_Compile_Time_Warning_Or_Error (T.Prag, T.Eloc);
+ Validate_Compile_Time_Warning_Or_Error (T.Prag, T.Eloc);
Unset_Scope (T.Scope);
end;
end loop;
-- Name_uInvariant, and Name_uType_Invariant (_Pre, _Post, _Invariant,
-- and _Type_Invariant).
- procedure Process_Compile_Time_Warning_Or_Error
- (N : Node_Id;
- Eloc : Source_Ptr);
- -- Common processing for Compile_Time_Error and Compile_Time_Warning of
- -- pragma N. Called when the pragma is processed as part of its regular
- -- analysis but also called after calling the back end to validate these
- -- pragmas for size and alignment appropriateness.
-
procedure Process_Compilation_Unit_Pragmas (N : Node_Id);
-- Called at the start of processing compilation unit N to deal with any
-- special issues regarding pragmas. In particular, we have to deal with
procedure All_Warnings (Setting : Boolean) is
begin
- Address_Clause_Overlay_Warnings := Setting;
- Check_Unreferenced := Setting;
- Check_Unreferenced_Formals := Setting;
- Check_Withs := Setting;
- Constant_Condition_Warnings := Setting;
- Elab_Warnings := Setting;
- Implementation_Unit_Warnings := Setting;
- Ineffective_Inline_Warnings := Setting;
- List_Body_Required_Info := Setting;
- List_Inherited_Aspects := Setting;
- Warn_On_Ada_2005_Compatibility := Setting;
- Warn_On_Ada_2012_Compatibility := Setting;
- Warn_On_All_Unread_Out_Parameters := Setting;
- Warn_On_Anonymous_Allocators := Setting;
- Warn_On_Assertion_Failure := Setting;
- Warn_On_Assumed_Low_Bound := Setting;
- Warn_On_Atomic_Synchronization := Setting;
- Warn_On_Bad_Fixed_Value := Setting;
- Warn_On_Biased_Representation := Setting;
- Warn_On_Constant := Setting;
- Warn_On_Deleted_Code := Setting;
- Warn_On_Dereference := Setting;
- Warn_On_Export_Import := Setting;
- Warn_On_Hiding := Setting;
- Warn_On_Late_Primitives := Setting;
- Warn_On_Modified_Unread := Setting;
- Warn_On_No_Value_Assigned := Setting;
- Warn_On_Non_Local_Exception := Setting;
- Warn_On_Object_Renames_Function := Setting;
- Warn_On_Obsolescent_Feature := Setting;
- Warn_On_Overlap := Setting;
- Warn_On_Overridden_Size := Setting;
- Warn_On_Parameter_Order := Setting;
- Warn_On_Questionable_Layout := Setting;
- Warn_On_Questionable_Missing_Parens := Setting;
- Warn_On_Record_Holes := Setting;
- Warn_On_Redundant_Constructs := Setting;
- Warn_On_Reverse_Bit_Order := Setting;
- Warn_On_Size_Alignment := Setting;
- Warn_On_Standard_Redefinition := Setting;
- Warn_On_Suspicious_Contract := Setting;
- Warn_On_Suspicious_Modulus_Value := Setting;
- Warn_On_Unchecked_Conversion := Setting;
- Warn_On_Unordered_Enumeration_Type := Setting;
- Warn_On_Unrecognized_Pragma := Setting;
- Warn_On_Unrepped_Components := Setting;
- Warn_On_Warnings_Off := Setting;
+ Address_Clause_Overlay_Warnings := Setting;
+ Check_Unreferenced := Setting;
+ Check_Unreferenced_Formals := Setting;
+ Check_Withs := Setting;
+ Constant_Condition_Warnings := Setting;
+ Elab_Warnings := Setting;
+ Implementation_Unit_Warnings := Setting;
+ Ineffective_Inline_Warnings := Setting;
+ List_Body_Required_Info := Setting;
+ List_Inherited_Aspects := Setting;
+ Warn_On_Ada_2005_Compatibility := Setting;
+ Warn_On_Ada_2012_Compatibility := Setting;
+ Warn_On_All_Unread_Out_Parameters := Setting;
+ Warn_On_Anonymous_Allocators := Setting;
+ Warn_On_Assertion_Failure := Setting;
+ Warn_On_Assumed_Low_Bound := Setting;
+ Warn_On_Atomic_Synchronization := Setting;
+ Warn_On_Bad_Fixed_Value := Setting;
+ Warn_On_Biased_Representation := Setting;
+ Warn_On_Constant := Setting;
+ Warn_On_Deleted_Code := Setting;
+ Warn_On_Dereference := Setting;
+ Warn_On_Export_Import := Setting;
+ Warn_On_Hiding := Setting;
+ Warn_On_Late_Primitives := Setting;
+ Warn_On_Modified_Unread := Setting;
+ Warn_On_No_Value_Assigned := Setting;
+ Warn_On_Non_Local_Exception := Setting;
+ Warn_On_Object_Renames_Function := Setting;
+ Warn_On_Obsolescent_Feature := Setting;
+ Warn_On_Overlap := Setting;
+ Warn_On_Overridden_Size := Setting;
+ Warn_On_Parameter_Order := Setting;
+ Warn_On_Questionable_Layout := Setting;
+ Warn_On_Questionable_Missing_Parens := Setting;
+ Warn_On_Record_Holes := Setting;
+ Warn_On_Redundant_Constructs := Setting;
+ Warn_On_Reverse_Bit_Order := Setting;
+ Warn_On_Size_Alignment := Setting;
+ Warn_On_Standard_Redefinition := Setting;
+ Warn_On_Suspicious_Contract := Setting;
+ Warn_On_Suspicious_Modulus_Value := Setting;
+ Warn_On_Unchecked_Conversion := Setting;
+ Warn_On_Unknown_Compile_Time_Warning := Setting;
+ Warn_On_Unordered_Enumeration_Type := Setting;
+ Warn_On_Unrecognized_Pragma := Setting;
+ Warn_On_Unrepped_Components := Setting;
+ Warn_On_Warnings_Off := Setting;
end All_Warnings;
----------------------
procedure Restore_Warnings (W : Warning_Record) is
begin
- Address_Clause_Overlay_Warnings :=
+ Address_Clause_Overlay_Warnings :=
W.Address_Clause_Overlay_Warnings;
- Check_Unreferenced :=
+ Check_Unreferenced :=
W.Check_Unreferenced;
- Check_Unreferenced_Formals :=
+ Check_Unreferenced_Formals :=
W.Check_Unreferenced_Formals;
- Check_Withs :=
+ Check_Withs :=
W.Check_Withs;
- Constant_Condition_Warnings :=
+ Constant_Condition_Warnings :=
W.Constant_Condition_Warnings;
- Elab_Warnings :=
+ Elab_Warnings :=
W.Elab_Warnings;
- Elab_Info_Messages :=
+ Elab_Info_Messages :=
W.Elab_Info_Messages;
- Implementation_Unit_Warnings :=
+ Implementation_Unit_Warnings :=
W.Implementation_Unit_Warnings;
- Ineffective_Inline_Warnings :=
+ Ineffective_Inline_Warnings :=
W.Ineffective_Inline_Warnings;
- List_Body_Required_Info :=
+ List_Body_Required_Info :=
W.List_Body_Required_Info;
- List_Inherited_Aspects :=
+ List_Inherited_Aspects :=
W.List_Inherited_Aspects;
- No_Warn_On_Non_Local_Exception :=
+ No_Warn_On_Non_Local_Exception :=
W.No_Warn_On_Non_Local_Exception;
- Warning_Doc_Switch :=
+ Warning_Doc_Switch :=
W.Warning_Doc_Switch;
- Warn_On_Ada_2005_Compatibility :=
+ Warn_On_Ada_2005_Compatibility :=
W.Warn_On_Ada_2005_Compatibility;
- Warn_On_Ada_2012_Compatibility :=
+ Warn_On_Ada_2012_Compatibility :=
W.Warn_On_Ada_2012_Compatibility;
- Warn_On_All_Unread_Out_Parameters :=
+ Warn_On_All_Unread_Out_Parameters :=
W.Warn_On_All_Unread_Out_Parameters;
- Warn_On_Anonymous_Allocators :=
+ Warn_On_Anonymous_Allocators :=
W.Warn_On_Anonymous_Allocators;
- Warn_On_Assertion_Failure :=
+ Warn_On_Assertion_Failure :=
W.Warn_On_Assertion_Failure;
- Warn_On_Assumed_Low_Bound :=
+ Warn_On_Assumed_Low_Bound :=
W.Warn_On_Assumed_Low_Bound;
- Warn_On_Atomic_Synchronization :=
+ Warn_On_Atomic_Synchronization :=
W.Warn_On_Atomic_Synchronization;
- Warn_On_Bad_Fixed_Value :=
+ Warn_On_Bad_Fixed_Value :=
W.Warn_On_Bad_Fixed_Value;
- Warn_On_Biased_Representation :=
+ Warn_On_Biased_Representation :=
W.Warn_On_Biased_Representation;
- Warn_On_Constant :=
+ Warn_On_Constant :=
W.Warn_On_Constant;
- Warn_On_Deleted_Code :=
+ Warn_On_Deleted_Code :=
W.Warn_On_Deleted_Code;
- Warn_On_Dereference :=
+ Warn_On_Dereference :=
W.Warn_On_Dereference;
- Warn_On_Export_Import :=
+ Warn_On_Export_Import :=
W.Warn_On_Export_Import;
- Warn_On_Hiding :=
+ Warn_On_Hiding :=
W.Warn_On_Hiding;
- Warn_On_Late_Primitives :=
+ Warn_On_Late_Primitives :=
W.Warn_On_Late_Primitives;
- Warn_On_Modified_Unread :=
+ Warn_On_Modified_Unread :=
W.Warn_On_Modified_Unread;
- Warn_On_No_Value_Assigned :=
+ Warn_On_No_Value_Assigned :=
W.Warn_On_No_Value_Assigned;
- Warn_On_Non_Local_Exception :=
+ Warn_On_Non_Local_Exception :=
W.Warn_On_Non_Local_Exception;
- Warn_On_Object_Renames_Function :=
+ Warn_On_Object_Renames_Function :=
W.Warn_On_Object_Renames_Function;
- Warn_On_Obsolescent_Feature :=
+ Warn_On_Obsolescent_Feature :=
W.Warn_On_Obsolescent_Feature;
- Warn_On_Overlap :=
+ Warn_On_Overlap :=
W.Warn_On_Overlap;
- Warn_On_Overridden_Size :=
+ Warn_On_Overridden_Size :=
W.Warn_On_Overridden_Size;
- Warn_On_Parameter_Order :=
+ Warn_On_Parameter_Order :=
W.Warn_On_Parameter_Order;
- Warn_On_Questionable_Layout :=
+ Warn_On_Questionable_Layout :=
W.Warn_On_Questionable_Layout;
- Warn_On_Questionable_Missing_Parens :=
+ Warn_On_Questionable_Missing_Parens :=
W.Warn_On_Questionable_Missing_Parens;
- Warn_On_Record_Holes :=
+ Warn_On_Record_Holes :=
W.Warn_On_Record_Holes;
- Warn_On_Redundant_Constructs :=
+ Warn_On_Redundant_Constructs :=
W.Warn_On_Redundant_Constructs;
- Warn_On_Reverse_Bit_Order :=
+ Warn_On_Reverse_Bit_Order :=
W.Warn_On_Reverse_Bit_Order;
- Warn_On_Size_Alignment :=
+ Warn_On_Size_Alignment :=
W.Warn_On_Size_Alignment;
- Warn_On_Standard_Redefinition :=
+ Warn_On_Standard_Redefinition :=
W.Warn_On_Standard_Redefinition;
- Warn_On_Suspicious_Contract :=
+ Warn_On_Suspicious_Contract :=
W.Warn_On_Suspicious_Contract;
- Warn_On_Unchecked_Conversion :=
+ Warn_On_Unchecked_Conversion :=
W.Warn_On_Unchecked_Conversion;
- Warn_On_Unordered_Enumeration_Type :=
+ Warn_On_Unknown_Compile_Time_Warning :=
+ W.Warn_On_Unknown_Compile_Time_Warning;
+ Warn_On_Unordered_Enumeration_Type :=
W.Warn_On_Unordered_Enumeration_Type;
- Warn_On_Unrecognized_Pragma :=
+ Warn_On_Unrecognized_Pragma :=
W.Warn_On_Unrecognized_Pragma;
- Warn_On_Unrepped_Components :=
+ Warn_On_Unrepped_Components :=
W.Warn_On_Unrepped_Components;
- Warn_On_Warnings_Off :=
+ Warn_On_Warnings_Off :=
W.Warn_On_Warnings_Off;
end Restore_Warnings;
W : Warning_Record;
begin
- W.Address_Clause_Overlay_Warnings :=
+ W.Address_Clause_Overlay_Warnings :=
Address_Clause_Overlay_Warnings;
- W.Check_Unreferenced :=
+ W.Check_Unreferenced :=
Check_Unreferenced;
- W.Check_Unreferenced_Formals :=
+ W.Check_Unreferenced_Formals :=
Check_Unreferenced_Formals;
- W.Check_Withs :=
+ W.Check_Withs :=
Check_Withs;
- W.Constant_Condition_Warnings :=
+ W.Constant_Condition_Warnings :=
Constant_Condition_Warnings;
- W.Elab_Info_Messages :=
+ W.Elab_Info_Messages :=
Elab_Info_Messages;
- W.Elab_Warnings :=
+ W.Elab_Warnings :=
Elab_Warnings;
- W.Implementation_Unit_Warnings :=
+ W.Implementation_Unit_Warnings :=
Implementation_Unit_Warnings;
- W.Ineffective_Inline_Warnings :=
+ W.Ineffective_Inline_Warnings :=
Ineffective_Inline_Warnings;
- W.List_Body_Required_Info :=
+ W.List_Body_Required_Info :=
List_Body_Required_Info;
- W.List_Inherited_Aspects :=
+ W.List_Inherited_Aspects :=
List_Inherited_Aspects;
- W.No_Warn_On_Non_Local_Exception :=
+ W.No_Warn_On_Non_Local_Exception :=
No_Warn_On_Non_Local_Exception;
- W.Warning_Doc_Switch :=
+ W.Warning_Doc_Switch :=
Warning_Doc_Switch;
- W.Warn_On_Ada_2005_Compatibility :=
+ W.Warn_On_Ada_2005_Compatibility :=
Warn_On_Ada_2005_Compatibility;
- W.Warn_On_Ada_2012_Compatibility :=
+ W.Warn_On_Ada_2012_Compatibility :=
Warn_On_Ada_2012_Compatibility;
- W.Warn_On_All_Unread_Out_Parameters :=
+ W.Warn_On_All_Unread_Out_Parameters :=
Warn_On_All_Unread_Out_Parameters;
- W.Warn_On_Anonymous_Allocators :=
+ W.Warn_On_Anonymous_Allocators :=
Warn_On_Anonymous_Allocators;
- W.Warn_On_Assertion_Failure :=
+ W.Warn_On_Assertion_Failure :=
Warn_On_Assertion_Failure;
- W.Warn_On_Assumed_Low_Bound :=
+ W.Warn_On_Assumed_Low_Bound :=
Warn_On_Assumed_Low_Bound;
- W.Warn_On_Atomic_Synchronization :=
+ W.Warn_On_Atomic_Synchronization :=
Warn_On_Atomic_Synchronization;
- W.Warn_On_Bad_Fixed_Value :=
+ W.Warn_On_Bad_Fixed_Value :=
Warn_On_Bad_Fixed_Value;
- W.Warn_On_Biased_Representation :=
+ W.Warn_On_Biased_Representation :=
Warn_On_Biased_Representation;
- W.Warn_On_Constant :=
+ W.Warn_On_Constant :=
Warn_On_Constant;
- W.Warn_On_Deleted_Code :=
+ W.Warn_On_Deleted_Code :=
Warn_On_Deleted_Code;
- W.Warn_On_Dereference :=
+ W.Warn_On_Dereference :=
Warn_On_Dereference;
- W.Warn_On_Export_Import :=
+ W.Warn_On_Export_Import :=
Warn_On_Export_Import;
- W.Warn_On_Hiding :=
+ W.Warn_On_Hiding :=
Warn_On_Hiding;
- W.Warn_On_Late_Primitives :=
+ W.Warn_On_Late_Primitives :=
Warn_On_Late_Primitives;
- W.Warn_On_Modified_Unread :=
+ W.Warn_On_Modified_Unread :=
Warn_On_Modified_Unread;
- W.Warn_On_No_Value_Assigned :=
+ W.Warn_On_No_Value_Assigned :=
Warn_On_No_Value_Assigned;
- W.Warn_On_Non_Local_Exception :=
+ W.Warn_On_Non_Local_Exception :=
Warn_On_Non_Local_Exception;
- W.Warn_On_Object_Renames_Function :=
+ W.Warn_On_Object_Renames_Function :=
Warn_On_Object_Renames_Function;
- W.Warn_On_Obsolescent_Feature :=
+ W.Warn_On_Obsolescent_Feature :=
Warn_On_Obsolescent_Feature;
- W.Warn_On_Overlap :=
+ W.Warn_On_Overlap :=
Warn_On_Overlap;
- W.Warn_On_Overridden_Size :=
+ W.Warn_On_Overridden_Size :=
Warn_On_Overridden_Size;
- W.Warn_On_Parameter_Order :=
+ W.Warn_On_Parameter_Order :=
Warn_On_Parameter_Order;
- W.Warn_On_Questionable_Layout :=
+ W.Warn_On_Questionable_Layout :=
Warn_On_Questionable_Layout;
- W.Warn_On_Questionable_Missing_Parens :=
+ W.Warn_On_Questionable_Missing_Parens :=
Warn_On_Questionable_Missing_Parens;
- W.Warn_On_Record_Holes :=
+ W.Warn_On_Record_Holes :=
Warn_On_Record_Holes;
- W.Warn_On_Redundant_Constructs :=
+ W.Warn_On_Redundant_Constructs :=
Warn_On_Redundant_Constructs;
- W.Warn_On_Reverse_Bit_Order :=
+ W.Warn_On_Reverse_Bit_Order :=
Warn_On_Reverse_Bit_Order;
- W.Warn_On_Size_Alignment :=
+ W.Warn_On_Size_Alignment :=
Warn_On_Size_Alignment;
- W.Warn_On_Standard_Redefinition :=
+ W.Warn_On_Standard_Redefinition :=
Warn_On_Standard_Redefinition;
- W.Warn_On_Suspicious_Contract :=
+ W.Warn_On_Suspicious_Contract :=
Warn_On_Suspicious_Contract;
- W.Warn_On_Unchecked_Conversion :=
+ W.Warn_On_Unchecked_Conversion :=
Warn_On_Unchecked_Conversion;
- W.Warn_On_Unordered_Enumeration_Type :=
+ W.Warn_On_Unknown_Compile_Time_Warning :=
+ Warn_On_Unknown_Compile_Time_Warning;
+ W.Warn_On_Unordered_Enumeration_Type :=
Warn_On_Unordered_Enumeration_Type;
- W.Warn_On_Unrecognized_Pragma :=
+ W.Warn_On_Unrecognized_Pragma :=
Warn_On_Unrecognized_Pragma;
- W.Warn_On_Unrepped_Components :=
+ W.Warn_On_Unrepped_Components :=
Warn_On_Unrepped_Components;
- W.Warn_On_Warnings_Off :=
+ W.Warn_On_Warnings_Off :=
Warn_On_Warnings_Off;
return W;
end Save_Warnings;
when 'A' =>
Warn_On_Anonymous_Allocators := False;
+ when 'c' =>
+ Warn_On_Unknown_Compile_Time_Warning := True;
+
+ when 'C' =>
+ Warn_On_Unknown_Compile_Time_Warning := False;
+
when others =>
if Ignore_Unrecognized_VWY_Switches then
Write_Line ("unrecognized switch -gnatw_" & C & " ignored");
-- Warn when tagged type public primitives are defined after its private
-- extensions.
+ Warn_On_Unknown_Compile_Time_Warning : Boolean := True;
+ -- Warn on a pragma Compile_Time_Warning or Compile_Time_Error whose
+ -- condition has a value that is not known at compile time.
+
Warn_On_Overridden_Size : Boolean := False;
-- Warn when explicit record component clause or array component_size
-- clause specifies a size that overrides a size for the type which was
-- Type used to save and restore warnings
type Warning_Record is record
- Address_Clause_Overlay_Warnings : Boolean;
- Check_Unreferenced : Boolean;
- 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;
- List_Body_Required_Info : Boolean;
- List_Inherited_Aspects : Boolean;
- No_Warn_On_Non_Local_Exception : Boolean;
- Warning_Doc_Switch : Boolean;
- Warn_On_Ada_2005_Compatibility : Boolean;
- Warn_On_Ada_2012_Compatibility : Boolean;
- Warn_On_All_Unread_Out_Parameters : Boolean;
- Warn_On_Anonymous_Allocators : Boolean;
- Warn_On_Assertion_Failure : Boolean;
- Warn_On_Assumed_Low_Bound : Boolean;
- Warn_On_Atomic_Synchronization : Boolean;
- Warn_On_Bad_Fixed_Value : Boolean;
- Warn_On_Biased_Representation : Boolean;
- Warn_On_Constant : Boolean;
- Warn_On_Deleted_Code : Boolean;
- Warn_On_Dereference : Boolean;
- Warn_On_Export_Import : Boolean;
- Warn_On_Hiding : Boolean;
- Warn_On_Late_Primitives : Boolean;
- Warn_On_Modified_Unread : Boolean;
- Warn_On_No_Value_Assigned : Boolean;
- Warn_On_Non_Local_Exception : Boolean;
- Warn_On_Object_Renames_Function : Boolean;
- Warn_On_Obsolescent_Feature : Boolean;
- Warn_On_Overlap : Boolean;
- Warn_On_Overridden_Size : Boolean;
- Warn_On_Parameter_Order : Boolean;
- Warn_On_Questionable_Layout : Boolean;
- Warn_On_Questionable_Missing_Parens : Boolean;
- Warn_On_Record_Holes : Boolean;
- Warn_On_Redundant_Constructs : Boolean;
- Warn_On_Reverse_Bit_Order : Boolean;
- Warn_On_Size_Alignment : Boolean;
- Warn_On_Standard_Redefinition : Boolean;
- Warn_On_Suspicious_Contract : Boolean;
- Warn_On_Suspicious_Modulus_Value : Boolean;
- Warn_On_Unchecked_Conversion : Boolean;
- Warn_On_Unordered_Enumeration_Type : Boolean;
- Warn_On_Unrecognized_Pragma : Boolean;
- Warn_On_Unrepped_Components : Boolean;
- Warn_On_Warnings_Off : Boolean;
+ Address_Clause_Overlay_Warnings : Boolean;
+ Check_Unreferenced : Boolean;
+ 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;
+ List_Body_Required_Info : Boolean;
+ List_Inherited_Aspects : Boolean;
+ No_Warn_On_Non_Local_Exception : Boolean;
+ Warning_Doc_Switch : Boolean;
+ Warn_On_Ada_2005_Compatibility : Boolean;
+ Warn_On_Ada_2012_Compatibility : Boolean;
+ Warn_On_All_Unread_Out_Parameters : Boolean;
+ Warn_On_Anonymous_Allocators : Boolean;
+ Warn_On_Assertion_Failure : Boolean;
+ Warn_On_Assumed_Low_Bound : Boolean;
+ Warn_On_Atomic_Synchronization : Boolean;
+ Warn_On_Bad_Fixed_Value : Boolean;
+ Warn_On_Biased_Representation : Boolean;
+ Warn_On_Constant : Boolean;
+ Warn_On_Deleted_Code : Boolean;
+ Warn_On_Dereference : Boolean;
+ Warn_On_Export_Import : Boolean;
+ Warn_On_Hiding : Boolean;
+ Warn_On_Late_Primitives : Boolean;
+ Warn_On_Modified_Unread : Boolean;
+ Warn_On_No_Value_Assigned : Boolean;
+ Warn_On_Non_Local_Exception : Boolean;
+ Warn_On_Object_Renames_Function : Boolean;
+ Warn_On_Obsolescent_Feature : Boolean;
+ Warn_On_Overlap : Boolean;
+ Warn_On_Overridden_Size : Boolean;
+ Warn_On_Parameter_Order : Boolean;
+ Warn_On_Questionable_Layout : Boolean;
+ Warn_On_Questionable_Missing_Parens : Boolean;
+ Warn_On_Record_Holes : Boolean;
+ Warn_On_Redundant_Constructs : Boolean;
+ Warn_On_Reverse_Bit_Order : Boolean;
+ Warn_On_Size_Alignment : Boolean;
+ Warn_On_Standard_Redefinition : Boolean;
+ Warn_On_Suspicious_Contract : Boolean;
+ Warn_On_Suspicious_Modulus_Value : Boolean;
+ Warn_On_Unchecked_Conversion : Boolean;
+ Warn_On_Unknown_Compile_Time_Warning : Boolean;
+ Warn_On_Unordered_Enumeration_Type : Boolean;
+ Warn_On_Unrecognized_Pragma : Boolean;
+ Warn_On_Unrepped_Components : Boolean;
+ Warn_On_Warnings_Off : Boolean;
end record;
function Save_Warnings return Warning_Record;
+2019-08-14 Bob Duff <duff@adacore.com>
+
+ * gnat.dg/warn27.adb: New testcase.
+
2019-08-14 Bob Duff <duff@adacore.com>
* gnat.dg/inline19.adb, gnat.dg/inline19.ads: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+procedure Warn27 is
+ Dummy : Boolean;
+
+ pragma Compile_Time_Warning (Dummy, "warning"); -- { dg-warning "condition is not known at compile time" }
+ pragma Compile_Time_Error (Dummy, "error"); -- { dg-warning "condition is not known at compile time" }
+begin
+ pragma Unreferenced (Dummy);
+end Warn27;