Commit 874a0341 by Robert Dewar Committed by Arnaud Charlet

par-prag.adb (Prag): Add dummy entry for pragma Compile_Time_Error

2007-04-06  Robert Dewar  <dewar@adacore.com>
	    Javier Miranda  <miranda@adacore.com>
	    Bob Duff  <duff@adacore.com>
	    Vincent Celier  <celier@adacore.com>

	* par-prag.adb (Prag): Add dummy entry for pragma Compile_Time_Error
	(Extensions_Allowed): No longer sets Ada_Version
	Entry for pragma Unreferenced_Objects

	* sem_prag.adb (Analyze_Pragma, case Priority): Force with of
	system.tasking if pragma priority used in a procedure
	(Analyze_Pragma, case Warning): Handle dot warning switches
	(Process_Compile_Time_Warning_Or_Error): New procedure
	(Analyze_Pragma): Add processing for Compile_Time_Error
	Add support for extra arguments External_Name and Link_Name.
	Remove code associated with pragmas CPP_Virtual and CPP_Vtable.
	(Process_Import_Or_Interface): Add support for the use of pragma Import
	with tagged types.
	(Extensions_Allowed): No longer affects Ada_Version
	(Analyze_Pragma): Split Is_Abstract flag into Is_Abstract_Subprogram and
	Is_Abstract_Type. Make sure these are called only when appropriate.
	Add processing for pragma Unreferenced_Objects

	* snames.h, snames.ads, snames.adb: Add entry for pragma
	Compile_Time_Error
	Add new standard name Minimum_Binder_Options for new gprmake
	Add new standard names for gprmake: Archive_Suffix,
	Library_Auto_Init_Supported, Library_Major_Minor_Id_Supported,
	Library_Support, Library_Version_Options,
	Shared_Library_Minimum_Options,
	Shared_Library_Prefix, Shared_Library_Suffix, Symbolic_Link_Supported.
	Change Name_Call to Name_uCall so that it cannot clash with a legal
	subprogram name.
	Add new standard names Mapping_Spec_Suffix and Mapping_Body_Suffix
	Append C_Plus_Plus to convention identifiers as synonym for CPP
	Add new standard names Stack and Builder_Switches
	Add new standard names: Compiler_Minimum_Options, Global_Config_File,
	Library_Builder, Local_Config_File, Objects_Path, Objects_Path_File,
	Run_Path_Option, Toolchain_Version.
	Entry for pragma Unreferenced_Objects

	* switch-c.adb (Scan_Front_End_Switches): Store correct -gnateD
	switches, without repetition of "eD". Make sure that last character of
	-gnatep= switch is not taken as -gnat switch character.
	Complete rewrite of circuit for handling saving compilation options
	Occasioned by need to support dot switchs for -gnatw, but cleans up
	things in general.
	-gnatX does not affect Ada_Version
	Include -gnatyA in -gnatg style switches

	* sem_warn.ads, sem_warn.adb (Output_Unreferenced_Messages): Exclude
	warnings on return objects.
	(Warn_On_Useless_Assignment): Exclude warnings on return objects
	(Set_Dot_Warning_Switch): New procedure
	(Check_References): Add missing case of test for
	Has_Pragma_Unreferenced_Objects
	(Output_Unreferenced_Messages): Implement effect of new pragma
	Unreferenced_Objects, remove special casing of limited controlled
	variables.

From-SVN: r123588
parent 6c929a2e
...@@ -376,14 +376,10 @@ begin ...@@ -376,14 +376,10 @@ begin
if Chars (Expression (Arg1)) = Name_On then if Chars (Expression (Arg1)) = Name_On then
Extensions_Allowed := True; Extensions_Allowed := True;
Ada_Version := Ada_Version_Type'Last;
else else
Extensions_Allowed := False; Extensions_Allowed := False;
Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
end if; end if;
Ada_Version_Explicit := Ada_Version;
---------------- ----------------
-- List (2.8) -- -- List (2.8) --
---------------- ----------------
...@@ -1058,6 +1054,7 @@ begin ...@@ -1058,6 +1054,7 @@ begin
Pragma_Atomic | Pragma_Atomic |
Pragma_Atomic_Components | Pragma_Atomic_Components |
Pragma_Attach_Handler | Pragma_Attach_Handler |
Pragma_Compile_Time_Error |
Pragma_Compile_Time_Warning | Pragma_Compile_Time_Warning |
Pragma_Convention_Identifier | Pragma_Convention_Identifier |
Pragma_CPP_Class | Pragma_CPP_Class |
...@@ -1179,6 +1176,7 @@ begin ...@@ -1179,6 +1176,7 @@ begin
Pragma_Unimplemented_Unit | Pragma_Unimplemented_Unit |
Pragma_Universal_Data | Pragma_Universal_Data |
Pragma_Unreferenced | Pragma_Unreferenced |
Pragma_Unreferenced_Objects |
Pragma_Unreserve_All_Interrupts | Pragma_Unreserve_All_Interrupts |
Pragma_Unsuppress | Pragma_Unsuppress |
Pragma_Use_VADS_Size | Pragma_Use_VADS_Size |
......
...@@ -392,6 +392,7 @@ package body Sem_Warn is ...@@ -392,6 +392,7 @@ package body Sem_Warn is
-- or if it is a parameter, to the corresponding spec. -- or if it is a parameter, to the corresponding spec.
if Has_Pragma_Unreferenced (E1) if Has_Pragma_Unreferenced (E1)
or else Has_Pragma_Unreferenced_Objects (Etype (E1))
or else (Is_Formal (E1) or else (Is_Formal (E1)
and then Present (Spec_Entity (E1)) and then Present (Spec_Entity (E1))
and then and then
...@@ -1641,6 +1642,7 @@ package body Sem_Warn is ...@@ -1641,6 +1642,7 @@ package body Sem_Warn is
then then
if Warn_On_Modified_Unread if Warn_On_Modified_Unread
and then not Is_Imported (E) and then not Is_Imported (E)
and then not Is_Return_Object (E)
-- Suppress message for aliased or renamed variables, -- Suppress message for aliased or renamed variables,
-- since there may be other entities that read the -- since there may be other entities that read the
...@@ -1658,20 +1660,12 @@ package body Sem_Warn is ...@@ -1658,20 +1660,12 @@ package body Sem_Warn is
-- Normal case of neither assigned nor read -- Normal case of neither assigned nor read
else else
-- We suppress the message for limited controlled types, -- We suppress the message for types for which a valid
-- to catch the common design pattern (known as RAII, or -- pragma Unreferenced_Objects has been given, otherwise
-- Resource Acquisition Is Initialization) which uses -- we go ahead and give the message.
-- such types solely for their initialization and
-- finalization semantics.
if Is_Controlled (Etype (E))
and then Is_Limited_Type (Etype (E))
then
null;
-- Normal case where we want to give message if not Has_Pragma_Unreferenced_Objects (Etype (E)) then
else
-- Distinguish renamed case in message -- Distinguish renamed case in message
if Present (Renamed_Object (E)) if Present (Renamed_Object (E))
...@@ -1740,6 +1734,26 @@ package body Sem_Warn is ...@@ -1740,6 +1734,26 @@ package body Sem_Warn is
end loop; end loop;
end Output_Unreferenced_Messages; end Output_Unreferenced_Messages;
----------------------------
-- Set_Dot_Warning_Switch --
----------------------------
function Set_Dot_Warning_Switch (C : Character) return Boolean is
begin
case C is
when 'x' =>
Warn_On_Non_Local_Exception := True;
when 'X' =>
Warn_On_Non_Local_Exception := False;
when others =>
return False;
end case;
return True;
end Set_Dot_Warning_Switch;
------------------------ ------------------------
-- Set_Warning_Switch -- -- Set_Warning_Switch --
------------------------ ------------------------
...@@ -1761,6 +1775,7 @@ package body Sem_Warn is ...@@ -1761,6 +1775,7 @@ package body Sem_Warn is
Warn_On_Export_Import := True; Warn_On_Export_Import := True;
Warn_On_Modified_Unread := True; Warn_On_Modified_Unread := True;
Warn_On_No_Value_Assigned := True; Warn_On_No_Value_Assigned := True;
Warn_On_Non_Local_Exception := True;
Warn_On_Obsolescent_Feature := True; Warn_On_Obsolescent_Feature := True;
Warn_On_Questionable_Missing_Parens := True; Warn_On_Questionable_Missing_Parens := True;
Warn_On_Redundant_Constructs := True; Warn_On_Redundant_Constructs := True;
...@@ -1784,8 +1799,9 @@ package body Sem_Warn is ...@@ -1784,8 +1799,9 @@ package body Sem_Warn is
Warn_On_Hiding := False; Warn_On_Hiding := False;
Warn_On_Modified_Unread := False; Warn_On_Modified_Unread := False;
Warn_On_No_Value_Assigned := False; Warn_On_No_Value_Assigned := False;
Warn_On_Non_Local_Exception := False;
Warn_On_Obsolescent_Feature := False; Warn_On_Obsolescent_Feature := False;
Warn_On_Questionable_Missing_Parens := True; Warn_On_Questionable_Missing_Parens := False;
Warn_On_Redundant_Constructs := False; Warn_On_Redundant_Constructs := False;
Warn_On_Unchecked_Conversion := False; Warn_On_Unchecked_Conversion := False;
Warn_On_Unrecognized_Pragma := False; Warn_On_Unrecognized_Pragma := False;
...@@ -2409,11 +2425,12 @@ package body Sem_Warn is ...@@ -2409,11 +2425,12 @@ package body Sem_Warn is
-- Start of processing for Warn_On_Useless_Assignment -- Start of processing for Warn_On_Useless_Assignment
begin begin
-- Check if this is a case we want to warn on, a variable with -- Check if this is a case we want to warn on, a variable with the
-- the last assignment field set, with warnings enabled, and -- last assignment field set, with warnings enabled, and which is
-- which is not imported or exported. -- not imported or exported.
if Ekind (Ent) = E_Variable if Ekind (Ent) = E_Variable
and then not Is_Return_Object (Ent)
and then Present (Last_Assignment (Ent)) and then Present (Last_Assignment (Ent))
and then not Warnings_Off (Ent) and then not Warnings_Off (Ent)
and then not Has_Pragma_Unreferenced (Ent) and then not Has_Pragma_Unreferenced (Ent)
......
...@@ -37,9 +37,16 @@ package Sem_Warn is ...@@ -37,9 +37,16 @@ package Sem_Warn is
-------------------- --------------------
function Set_Warning_Switch (C : Character) return Boolean; function Set_Warning_Switch (C : Character) return Boolean;
-- This function sets the warning switch or switches corresponding to -- This function sets the warning switch or switches corresponding to the
-- the given character. It is used for processing a -gnatw switch on the -- given character. It is used to process a -gnatw switch on the command
-- command line, or a string literal in pragma Warnings. -- line, or a character in a string literal in pragma Warnings. Returns
-- True for valid warning character C, False for invalid character.
function Set_Dot_Warning_Switch (C : Character) return Boolean;
-- This function sets the warning switch or switches corresponding to the
-- given character preceded by a dot. Used to process a -gnatw. switch on
-- the command line or .C in a string literal in pragma Warnings. Returns
-- True for valid warning character C, False for invalid character.
------------------------------------------ ------------------------------------------
-- Routines to Handle Unused References -- -- Routines to Handle Unused References --
......
...@@ -139,7 +139,7 @@ package body Snames is ...@@ -139,7 +139,7 @@ package body Snames is
"partition#" & "partition#" &
"partition_interface#" & "partition_interface#" &
"ras#" & "ras#" &
"call#" & "_call#" &
"rci_name#" & "rci_name#" &
"receiver#" & "receiver#" &
"result#" & "result#" &
...@@ -178,6 +178,7 @@ package body Snames is ...@@ -178,6 +178,7 @@ package body Snames is
"ada_2005#" & "ada_2005#" &
"assertion_policy#" & "assertion_policy#" &
"c_pass_by_copy#" & "c_pass_by_copy#" &
"compile_time_error#" &
"compile_time_warning#" & "compile_time_warning#" &
"component_alignment#" & "component_alignment#" &
"convention_identifier#" & "convention_identifier#" &
...@@ -317,6 +318,7 @@ package body Snames is ...@@ -317,6 +318,7 @@ package body Snames is
"unchecked_union#" & "unchecked_union#" &
"unimplemented_unit#" & "unimplemented_unit#" &
"unreferenced#" & "unreferenced#" &
"unreferenced_objects#" &
"unreserve_all_interrupts#" & "unreserve_all_interrupts#" &
"volatile#" & "volatile#" &
"volatile_components#" & "volatile_components#" &
...@@ -333,6 +335,7 @@ package body Snames is ...@@ -333,6 +335,7 @@ package body Snames is
"asm#" & "asm#" &
"assembly#" & "assembly#" &
"default#" & "default#" &
"c_plus_plus#" &
"dll#" & "dll#" &
"win32#" & "win32#" &
"as_is#" & "as_is#" &
...@@ -664,13 +667,16 @@ package body Snames is ...@@ -664,13 +667,16 @@ package body Snames is
"ada_roots#" & "ada_roots#" &
"archive_builder#" & "archive_builder#" &
"archive_indexer#" & "archive_indexer#" &
"archive_suffix#" &
"binder#" & "binder#" &
"binder_driver#" & "binder_driver#" &
"body_suffix#" & "body_suffix#" &
"builder#" & "builder#" &
"builder_switches#" &
"compiler#" & "compiler#" &
"compiler_driver#" & "compiler_driver#" &
"compiler_kind#" & "compiler_kind#" &
"compiler_minimum_options#" &
"compiler_pic_option#" & "compiler_pic_option#" &
"compute_dependency#" & "compute_dependency#" &
"config_body_file_name#" & "config_body_file_name#" &
...@@ -695,6 +701,7 @@ package body Snames is ...@@ -695,6 +701,7 @@ package body Snames is
"finder#" & "finder#" &
"global_compiler_switches#" & "global_compiler_switches#" &
"global_configuration_pragmas#" & "global_configuration_pragmas#" &
"global_config_file#" &
"gnatls#" & "gnatls#" &
"gnatstub#" & "gnatstub#" &
"implementation#" & "implementation#" &
...@@ -707,32 +714,47 @@ package body Snames is ...@@ -707,32 +714,47 @@ package body Snames is
"language_processing#" & "language_processing#" &
"languages#" & "languages#" &
"library_ali_dir#" & "library_ali_dir#" &
"library_dir#" &
"library_auto_init#" & "library_auto_init#" &
"library_auto_init_supported#" &
"library_builder#" &
"library_dir#" &
"library_gcc#" & "library_gcc#" &
"library_interface#" & "library_interface#" &
"library_kind#" & "library_kind#" &
"library_name#" & "library_name#" &
"library_major_minor_id_supported#" &
"library_options#" & "library_options#" &
"library_reference_symbol_file#" & "library_reference_symbol_file#" &
"library_src_dir#" & "library_src_dir#" &
"library_support#" &
"library_symbol_file#" & "library_symbol_file#" &
"library_symbol_policy#" & "library_symbol_policy#" &
"library_version#" & "library_version#" &
"library_version_options#" &
"linker#" & "linker#" &
"linker_executable_option#" & "linker_executable_option#" &
"linker_lib_dir_option#" & "linker_lib_dir_option#" &
"linker_lib_name_option#" & "linker_lib_name_option#" &
"local_config_file#" &
"local_configuration_pragmas#" & "local_configuration_pragmas#" &
"locally_removed_files#" & "locally_removed_files#" &
"mapping_file_switches#" & "mapping_file_switches#" &
"mapping_spec_suffix#" &
"mapping_body_suffix#" &
"metrics#" & "metrics#" &
"minimum_binder_options#" &
"naming#" & "naming#" &
"objects_path#" &
"objects_path_file#" &
"object_dir#" & "object_dir#" &
"pretty_printer#" & "pretty_printer#" &
"project#" & "project#" &
"roots#" & "roots#" &
"run_path_option#" &
"runtime_project#" & "runtime_project#" &
"shared_library_minimum_options#" &
"shared_library_prefix#" &
"shared_library_suffix#" &
"separate_suffix#" & "separate_suffix#" &
"source_dirs#" & "source_dirs#" &
"source_files#" & "source_files#" &
...@@ -742,7 +764,10 @@ package body Snames is ...@@ -742,7 +764,10 @@ package body Snames is
"specification#" & "specification#" &
"specification_exceptions#" & "specification_exceptions#" &
"specification_suffix#" & "specification_suffix#" &
"stack#" &
"switches#" & "switches#" &
"symbolic_link_supported#" &
"toolchain_version#" &
"unaligned_valid#" & "unaligned_valid#" &
"interface#" & "interface#" &
"overriding#" & "overriding#" &
...@@ -976,14 +1001,16 @@ package body Snames is ...@@ -976,14 +1001,16 @@ package body Snames is
Convention_Identifiers.Init; Convention_Identifiers.Init;
Convention_Identifiers.Append ((Name_Asm, Convention_Assembler)); Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler)); Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
Convention_Identifiers.Append ((Name_Default, Convention_C));
Convention_Identifiers.Append ((Name_External, Convention_C));
Convention_Identifiers.Append ((Name_Default, Convention_C)); Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
Convention_Identifiers.Append ((Name_External, Convention_C));
Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall)); Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall)); Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
end Initialize; end Initialize;
----------------------- -----------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment