From fbe627afbd02f0e151a772f1bbd00ec8dc13c6a8 Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Wed, 6 Jun 2007 12:29:05 +0200 Subject: g-comlin.ads, [...]: Add new warning for renaming of function return objects 2007-04-20 Robert Dewar Ed Schonberg * g-comlin.ads, g-comlin.adb: Add new warning for renaming of function return objects * opt.adb (Tree_Write, Tree_Read): Use proper expressions for size (Tree_Read): Use size of object instead of type'object_size, since the latter is incorrect for packed array types. (Tree_Write): Same fix * opt.ads: Add new warning for renaming of function return objects (Generating_Code): New boolean variable used to indicate that the frontend as finished its work and has called the backend to process the tree and generate the object file. (GCC_Version): Is now private (Static_Dispatch_Tables): New constant declaration. (Overflow_Checks_Unsuppressed): New flag. (Process_Suppress_Unsuppress): Set Overflow_Checks_Unsuppressed. (List_Closure): New flag for gnatbind (-R) Zero_Formatting: New flag for gnatbind (-Z) (Special_Exception_Package_Used): New flag. (Warn_On_Unrepped_Components): New flag. * sem_ch8.adb (Check_Library_Unit_Renaming): Check that the renamed unit is a compilation unit, rather than relying on its scope, so that Standard can be renamed. (Analyze_Object_Renaming): Add new warning for renaming of function return objects. Also reject attempt to rename function return object in Ada 83 mode. (Attribute_Renaming): In case of tagged types, add the body of the generated function to the freezing actions of the type. (Find_Type): A protected type is visible right after the reserved word "is" is encountered in its type declaration. Set the entity and type rather than emitting an error message. (New_Scope): Properly propagate Discard_Names to inner scopes (Check_Nested_Access): New procedure. (Has_Nested_Access, Set_Has_Nested_Access): New procedures. (Find_Direct_Name, Note_Possible_Modification): Use Check_Nested_Access. * sem_warn.ads, sem_warn.adb: Improvements to infinite loop warning Add new warning for renaming of function return objects (Check_References): Suppress warnings for objects whose type or base type has Warnings suppressed. (Set_Dot_Warning_Switch): Add processing for -gnatw.c/C (Set_Warning_Switch): Include new -gnatwc in -gnatwa From-SVN: r125414 --- gcc/ada/opt.adb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'gcc/ada/opt.adb') diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb index 8c11718..7834812 100644 --- a/gcc/ada/opt.adb +++ b/gcc/ada/opt.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -37,6 +37,9 @@ with Tree_IO; use Tree_IO; package body Opt is + SU : constant := Storage_Unit; + -- Shorthand for System.Storage_Unit + ---------------------------------- -- Register_Opt_Config_Switches -- ---------------------------------- @@ -169,10 +172,10 @@ package body Opt is Tree_Read_Char (Identifier_Character_Set); Tree_Read_Int (Maximum_File_Name_Length); Tree_Read_Data (Suppress_Options'Address, - Suppress_Array'Object_Size / Storage_Unit); + (Suppress_Options'Size + SU - 1) / SU); Tree_Read_Bool (Verbose_Mode); Tree_Read_Data (Warning_Mode'Address, - Warning_Mode_Type'Object_Size / Storage_Unit); + (Warning_Mode'Size + SU - 1) / SU); Tree_Read_Int (Ada_Version_Config_Val); Tree_Read_Int (Ada_Version_Explicit_Config_Val); Tree_Read_Int (Assertions_Enabled_Config_Val); @@ -198,23 +201,23 @@ package body Opt is begin Tree_Read_Data (Tmp'Address, Tree_Version_String_Len); - GNAT.Strings.Free (Tree_Version_String); + System.Strings.Free (Tree_Version_String); Free (Tree_Version_String); Tree_Version_String := new String'(Tmp); end; Tree_Read_Data (Distribution_Stub_Mode'Address, - Distribution_Stub_Mode_Type'Object_Size / Storage_Unit); + (Distribution_Stub_Mode'Size + SU - 1) / Storage_Unit); Tree_Read_Bool (Inline_Active); Tree_Read_Bool (Inline_Processing_Required); Tree_Read_Bool (List_Units); Tree_Read_Bool (Configurable_Run_Time_Mode); Tree_Read_Data (Operating_Mode'Address, - Operating_Mode_Type'Object_Size / Storage_Unit); + (Operating_Mode'Size + SU - 1) / Storage_Unit); Tree_Read_Bool (Suppress_Checks); Tree_Read_Bool (Try_Semantics); Tree_Read_Data (Wide_Character_Encoding_Method'Address, - WC_Encoding_Method'Object_Size / Storage_Unit); + (Wide_Character_Encoding_Method'Size + SU - 1) / SU); Tree_Read_Bool (Upper_Half_Encoding); Tree_Read_Bool (Force_ALI_Tree_File); end Tree_Read; @@ -233,10 +236,10 @@ package body Opt is Tree_Write_Char (Identifier_Character_Set); Tree_Write_Int (Maximum_File_Name_Length); Tree_Write_Data (Suppress_Options'Address, - Suppress_Array'Object_Size / Storage_Unit); + (Suppress_Options'Size + SU - 1) / SU); Tree_Write_Bool (Verbose_Mode); Tree_Write_Data (Warning_Mode'Address, - Warning_Mode_Type'Object_Size / Storage_Unit); + (Warning_Mode'Size + SU - 1) / Storage_Unit); Tree_Write_Int (Ada_Version_Type'Pos (Ada_Version_Config)); Tree_Write_Int (Ada_Version_Type'Pos (Ada_Version_Explicit_Config)); Tree_Write_Int (Boolean'Pos (Assertions_Enabled_Config)); @@ -246,20 +249,19 @@ package body Opt is Tree_Write_Bool (Enable_Overflow_Checks); Tree_Write_Bool (Full_List); Tree_Write_Int (Int (Version_String'Length)); - Tree_Write_Data (Version_String'Address, - Version_String'Length); + Tree_Write_Data (Version_String'Address, Version_String'Length); Tree_Write_Data (Distribution_Stub_Mode'Address, - Distribution_Stub_Mode_Type'Object_Size / Storage_Unit); + (Distribution_Stub_Mode'Size + SU - 1) / SU); Tree_Write_Bool (Inline_Active); Tree_Write_Bool (Inline_Processing_Required); Tree_Write_Bool (List_Units); Tree_Write_Bool (Configurable_Run_Time_Mode); Tree_Write_Data (Operating_Mode'Address, - Operating_Mode_Type'Object_Size / Storage_Unit); + (Operating_Mode'Size + SU - 1) / SU); Tree_Write_Bool (Suppress_Checks); Tree_Write_Bool (Try_Semantics); Tree_Write_Data (Wide_Character_Encoding_Method'Address, - WC_Encoding_Method'Object_Size / Storage_Unit); + (Wide_Character_Encoding_Method'Size + SU - 1) / SU); Tree_Write_Bool (Upper_Half_Encoding); Tree_Write_Bool (Force_ALI_Tree_File); end Tree_Write; -- cgit v1.1