Commit b3f48fd4 by Arnaud Charlet

[multiple changes]

2010-09-10  Robert Dewar  <dewar@adacore.com>

	* gnat_ugn.texi: Add documentation for -gnatw.s/S
	* sem_ch13.adb (Analyze_Attribute_Definition_Clause, case
	Component_Size): Implement warning on overriden size clause.
	(Analyze_Record_Representation_Clause): Implement warning on overriden
	size clause.
	* sem_warn.ads, sem_warn.adb (Warn_On_Overridden_Size): New flag
	(-gnatw.s/S).
	* ug_words: Add entries for -gnatw.s/S.
	* vms_data.ads, usage.adb: Add line for -gnatw.s/-gnatw.S.
	* gcc-interface/Make-lang.in: Update dependencies.

2010-09-10  Vincent Celier  <celier@adacore.com>

	* prj-dect.adb (Parse_Package_Declaration): Allow a package to extend
	a package with the same name from an imported or extended project.
	* prj-proc.adb (Process_Declarative_Items): Process package extensions

2010-09-10  Bob Duff  <duff@adacore.com>

	* exp_ch6.adb (Expand_Call): Do not perform a null_exclusion check on
	'out' parameters.

From-SVN: r164194
parent bedbdfcf
2010-09-10 Robert Dewar <dewar@adacore.com> 2010-09-10 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Add documentation for -gnatw.s/S
* sem_ch13.adb (Analyze_Attribute_Definition_Clause, case
Component_Size): Implement warning on overriden size clause.
(Analyze_Record_Representation_Clause): Implement warning on overriden
size clause.
* sem_warn.ads, sem_warn.adb (Warn_On_Overridden_Size): New flag
(-gnatw.s/S).
* ug_words: Add entries for -gnatw.s/S.
* vms_data.ads, usage.adb: Add line for -gnatw.s/-gnatw.S.
* gcc-interface/Make-lang.in: Update dependencies.
2010-09-10 Vincent Celier <celier@adacore.com>
* prj-dect.adb (Parse_Package_Declaration): Allow a package to extend
a package with the same name from an imported or extended project.
* prj-proc.adb (Process_Declarative_Items): Process package extensions
2010-09-10 Bob Duff <duff@adacore.com>
* exp_ch6.adb (Expand_Call): Do not perform a null_exclusion check on
'out' parameters.
2010-09-10 Robert Dewar <dewar@adacore.com>
* sem.adb: Minor reformatting. * sem.adb: Minor reformatting.
2010-09-10 Bob Duff <duff@adacore.com> 2010-09-10 Bob Duff <duff@adacore.com>
......
...@@ -2330,17 +2330,22 @@ package body Exp_Ch6 is ...@@ -2330,17 +2330,22 @@ package body Exp_Ch6 is
end if; end if;
-- Perform the check of 4.6(49) that prevents a null value from being -- Perform the check of 4.6(49) that prevents a null value from being
-- passed as an actual to an access parameter. Note that the check is -- passed as an actual to an access parameter. Note that the check
-- elided in the common cases of passing an access attribute or -- is elided in the common cases of passing an access attribute or
-- access parameter as an actual. Also, we currently don't enforce -- access parameter as an actual. Also, we currently don't enforce
-- this check for expander-generated actuals and when -gnatdj is set. -- this check for expander-generated actuals and when -gnatdj is set.
if Ada_Version >= Ada_05 then if Ada_Version >= Ada_05 then
-- Ada 2005 (AI-231): Check null-excluding access types -- Ada 2005 (AI-231): Check null-excluding access types. Note that
-- the intent of 6.4.1(13) is that null-exclusion checks should
-- not be done for 'out' parameters, even though it refers only
-- to constraint checks, and a null_exlusion is not a constraint.
-- Note that AI05-0196-1 corrects this mistake in the RM.
if Is_Access_Type (Etype (Formal)) if Is_Access_Type (Etype (Formal))
and then Can_Never_Be_Null (Etype (Formal)) and then Can_Never_Be_Null (Etype (Formal))
and then Ekind (Formal) /= E_Out_Parameter
and then Nkind (Prev) /= N_Raise_Constraint_Error and then Nkind (Prev) /= N_Raise_Constraint_Error
and then (Known_Null (Prev) and then (Known_Null (Prev)
or else not Can_Never_Be_Null (Etype (Prev))) or else not Can_Never_Be_Null (Etype (Prev)))
...@@ -2424,10 +2429,10 @@ package body Exp_Ch6 is ...@@ -2424,10 +2429,10 @@ package body Exp_Ch6 is
-- since this is a left side reference. We only do this for calls -- since this is a left side reference. We only do this for calls
-- from the source program since we assume that compiler generated -- from the source program since we assume that compiler generated
-- calls explicitly generate any required checks. We also need it -- calls explicitly generate any required checks. We also need it
-- only if we are doing standard validity checks, since clearly it -- only if we are doing standard validity checks, since clearly it is
-- is not needed if validity checks are off, and in subscript -- not needed if validity checks are off, and in subscript validity
-- validity checking mode, all indexed components are checked with -- checking mode, all indexed components are checked with a call
-- a call directly from Expand_N_Indexed_Component. -- directly from Expand_N_Indexed_Component.
if Comes_From_Source (N) if Comes_From_Source (N)
and then Ekind (Formal) /= E_In_Parameter and then Ekind (Formal) /= E_In_Parameter
...@@ -2593,11 +2598,11 @@ package body Exp_Ch6 is ...@@ -2593,11 +2598,11 @@ package body Exp_Ch6 is
-- Deals with Dispatch_Call if we still have a call, before expanding -- Deals with Dispatch_Call if we still have a call, before expanding
-- extra actuals since this will be done on the re-analysis of the -- extra actuals since this will be done on the re-analysis of the
-- dispatching call. Note that we do not try to shorten the actual -- dispatching call. Note that we do not try to shorten the actual list
-- list for a dispatching call, it would not make sense to do so. -- for a dispatching call, it would not make sense to do so. Expansion
-- Expansion of dispatching calls is suppressed when VM_Target, because -- of dispatching calls is suppressed when VM_Target, because the VM
-- the VM back-ends directly handle the generation of dispatching -- back-ends directly handle the generation of dispatching calls and
-- calls and would have to undo any expansion to an indirect call. -- would have to undo any expansion to an indirect call.
if Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement) if Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement)
and then Present (Controlling_Argument (N)) and then Present (Controlling_Argument (N))
...@@ -2605,8 +2610,8 @@ package body Exp_Ch6 is ...@@ -2605,8 +2610,8 @@ package body Exp_Ch6 is
if Tagged_Type_Expansion then if Tagged_Type_Expansion then
Expand_Dispatching_Call (N); Expand_Dispatching_Call (N);
-- The following return is worrisome. Is it really OK to -- The following return is worrisome. Is it really OK to skip all
-- skip all remaining processing in this procedure ??? -- remaining processing in this procedure ???
return; return;
...@@ -2624,8 +2629,8 @@ package body Exp_Ch6 is ...@@ -2624,8 +2629,8 @@ package body Exp_Ch6 is
-- Similarly, expand calls to RCI subprograms on which pragma -- Similarly, expand calls to RCI subprograms on which pragma
-- All_Calls_Remote applies. The rewriting will be reanalyzed -- All_Calls_Remote applies. The rewriting will be reanalyzed
-- later. Do this only when the call comes from source since we do -- later. Do this only when the call comes from source since we
-- not want such a rewriting to occur in expanded code. -- do not want such a rewriting to occur in expanded code.
if Is_All_Remote_Call (N) then if Is_All_Remote_Call (N) then
Expand_All_Calls_Remote_Subprogram_Call (N); Expand_All_Calls_Remote_Subprogram_Call (N);
...@@ -2650,15 +2655,15 @@ package body Exp_Ch6 is ...@@ -2650,15 +2655,15 @@ package body Exp_Ch6 is
end loop; end loop;
end if; end if;
-- At this point we have all the actuals, so this is the point at -- At this point we have all the actuals, so this is the point at which
-- which the various expansion activities for actuals is carried out. -- the various expansion activities for actuals is carried out.
Expand_Actuals (N, Subp); Expand_Actuals (N, Subp);
-- If the subprogram is a renaming, or if it is inherited, replace it -- If the subprogram is a renaming, or if it is inherited, replace it in
-- in the call with the name of the actual subprogram being called. -- the call with the name of the actual subprogram being called. If this
-- If this is a dispatching call, the run-time decides what to call. -- is a dispatching call, the run-time decides what to call. The Alias
-- The Alias attribute does not apply to entries. -- attribute does not apply to entries.
if Nkind (N) /= N_Entry_Call_Statement if Nkind (N) /= N_Entry_Call_Statement
and then No (Controlling_Argument (N)) and then No (Controlling_Argument (N))
...@@ -2827,10 +2832,10 @@ package body Exp_Ch6 is ...@@ -2827,10 +2832,10 @@ package body Exp_Ch6 is
if Is_Access_Protected_Subprogram_Type if Is_Access_Protected_Subprogram_Type
(Base_Type (Etype (Prefix (Name (N))))) (Base_Type (Etype (Prefix (Name (N)))))
then then
-- If this is a call through an access to protected operation, -- If this is a call through an access to protected operation, the
-- the prefix has the form (object'address, operation'access). -- prefix has the form (object'address, operation'access). Rewrite
-- Rewrite as a for other protected calls: the object is the -- as a for other protected calls: the object is the 1st parameter
-- first parameter of the list of actuals. -- of the list of actuals.
declare declare
Call : Node_Id; Call : Node_Id;
...@@ -2905,11 +2910,11 @@ package body Exp_Ch6 is ...@@ -2905,11 +2910,11 @@ package body Exp_Ch6 is
-- In the case where the intrinsic is to be processed by the back end, -- In the case where the intrinsic is to be processed by the back end,
-- the call to Expand_Intrinsic_Call will do nothing, which is fine, -- the call to Expand_Intrinsic_Call will do nothing, which is fine,
-- since the idea in this case is to pass the call unchanged. -- since the idea in this case is to pass the call unchanged. If the
-- If the intrinsic is an inherited unchecked conversion, and the -- intrinsic is an inherited unchecked conversion, and the derived type
-- derived type is the target type of the conversion, we must retain -- is the target type of the conversion, we must retain it as the return
-- it as the return type of the expression. Otherwise the expansion -- type of the expression. Otherwise the expansion below, which uses the
-- below, which uses the parent operation, will yield the wrong type. -- parent operation, will yield the wrong type.
if Is_Intrinsic_Subprogram (Subp) then if Is_Intrinsic_Subprogram (Subp) then
Expand_Intrinsic_Call (N, Subp); Expand_Intrinsic_Call (N, Subp);
......
...@@ -5582,6 +5582,25 @@ To suppress these back end warnings as well, use the switch @option{-w} ...@@ -5582,6 +5582,25 @@ To suppress these back end warnings as well, use the switch @option{-w}
in addition to @option{-gnatws}. Also this switch has no effect on the in addition to @option{-gnatws}. Also this switch has no effect on the
handling of style check messages. handling of style check messages.
@item -gnatw.s
@emph{Activate warnings on overridden size clauses.}
@cindex @option{-gnatw.s} (@command{gcc})
@cindex Record Representation (component sizes)
This switch activates warnings on component clauses in record
representation clauses where the length given overrides that
specified by an explicit size clause for the component type. A
warning is similarly given in the array case if a specified
component size overrides an explicit size clause for the array
component type.
Note that @option{-gnatwa} does not affect the setting of this warning option.
@item -gnatw.S
@emph{Suppress warnings on overriddebn size clauses.}
@cindex @option{-gnatw.S} (@command{gcc})
This switch suppresses warnings on component clauses in record
representation clauses that override size clauses, and similar
warnings when an array component size overrides a size clause.
@item -gnatwt @item -gnatwt
@emph{Activate warnings for tracking of deleted conditional code.} @emph{Activate warnings for tracking of deleted conditional code.}
@cindex @option{-gnatwt} (@command{gcc}) @cindex @option{-gnatwt} (@command{gcc})
......
...@@ -1027,8 +1027,9 @@ package body Prj.Dect is ...@@ -1027,8 +1027,9 @@ package body Prj.Dect is
First_Attribute : Attribute_Node_Id := Empty_Attribute; First_Attribute : Attribute_Node_Id := Empty_Attribute;
Current_Package : Package_Node_Id := Empty_Package; Current_Package : Package_Node_Id := Empty_Package;
First_Declarative_Item : Project_Node_Id := Empty_Node; First_Declarative_Item : Project_Node_Id := Empty_Node;
Package_Location : constant Source_Ptr := Token_Ptr; Package_Location : constant Source_Ptr := Token_Ptr;
Renaming : Boolean := False;
Extending : Boolean := False;
begin begin
Package_Declaration := Package_Declaration :=
...@@ -1149,13 +1150,20 @@ package body Prj.Dect is ...@@ -1149,13 +1150,20 @@ package body Prj.Dect is
end if; end if;
if Token = Tok_Renames then if Token = Tok_Renames then
Renaming := True;
elsif Token = Tok_Extends then
Extending := True;
end if;
if Renaming or else Extending then
if Is_Config_File then if Is_Config_File then
Error_Msg Error_Msg
(Flags, (Flags,
"no package renames in configuration projects", Token_Ptr); "no package rename or extension in configuration projects",
Token_Ptr);
end if; end if;
-- Scan past "renames" -- Scan past "renames" or "extends"
Scan (In_Tree); Scan (In_Tree);
...@@ -1249,7 +1257,9 @@ package body Prj.Dect is ...@@ -1249,7 +1257,9 @@ package body Prj.Dect is
end if; end if;
end if; end if;
end if; end if;
end if;
if Renaming then
Expect (Tok_Semicolon, "`;`"); Expect (Tok_Semicolon, "`;`");
Set_End_Of_Line (Package_Declaration); Set_End_Of_Line (Package_Declaration);
Set_Previous_Line_Node (Package_Declaration); Set_Previous_Line_Node (Package_Declaration);
...@@ -1305,7 +1315,7 @@ package body Prj.Dect is ...@@ -1305,7 +1315,7 @@ package body Prj.Dect is
Remove_Next_End_Node; Remove_Next_End_Node;
else else
Error_Msg (Flags, "expected IS or RENAMES", Token_Ptr); Error_Msg (Flags, "expected IS", Token_Ptr);
end if; end if;
end Parse_Package_Declaration; end Parse_Package_Declaration;
......
...@@ -1428,7 +1428,7 @@ package body Prj.Proc is ...@@ -1428,7 +1428,7 @@ package body Prj.Proc is
if Present (Project_Of_Renamed_Package) then if Present (Project_Of_Renamed_Package) then
-- Renamed package -- Renamed or extending package
declare declare
Project_Name : constant Name_Id := Project_Name : constant Name_Id :=
...@@ -1466,8 +1466,6 @@ package body Prj.Proc is ...@@ -1466,8 +1466,6 @@ package body Prj.Proc is
In_Tree => In_Tree); In_Tree => In_Tree);
end; end;
-- Standard package declaration, not renaming
else else
-- Set the default values of the attributes -- Set the default values of the attributes
...@@ -1482,19 +1480,22 @@ package body Prj.Proc is ...@@ -1482,19 +1480,22 @@ package body Prj.Proc is
(Current_Item, From_Project_Node_Tree)), (Current_Item, From_Project_Node_Tree)),
Project_Level => False); Project_Level => False);
-- And process declarative items of the new package
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
Flags => Flags,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Pkg => New_Pkg,
Item =>
First_Declarative_Item_Of
(Current_Item, From_Project_Node_Tree));
end if; end if;
-- Process declarative items (nothing to do when the
-- package is renaming, as the first declarative item is
-- null).
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
Flags => Flags,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Pkg => New_Pkg,
Item =>
First_Declarative_Item_Of
(Current_Item, From_Project_Node_Tree));
end; end;
end if; end if;
......
...@@ -1283,6 +1283,7 @@ package body Sem_Ch13 is ...@@ -1283,6 +1283,7 @@ package body Sem_Ch13 is
when Attribute_Component_Size => Component_Size_Case : declare when Attribute_Component_Size => Component_Size_Case : declare
Csize : constant Uint := Static_Integer (Expr); Csize : constant Uint := Static_Integer (Expr);
Ctyp : Entity_Id;
Btype : Entity_Id; Btype : Entity_Id;
Biased : Boolean; Biased : Boolean;
New_Ctyp : Entity_Id; New_Ctyp : Entity_Id;
...@@ -1295,13 +1296,14 @@ package body Sem_Ch13 is ...@@ -1295,13 +1296,14 @@ package body Sem_Ch13 is
end if; end if;
Btype := Base_Type (U_Ent); Btype := Base_Type (U_Ent);
Ctyp := Component_Type (Btype);
if Has_Component_Size_Clause (Btype) then if Has_Component_Size_Clause (Btype) then
Error_Msg_N Error_Msg_N
("component size clause for& previously given", Nam); ("component size clause for& previously given", Nam);
elsif Csize /= No_Uint then elsif Csize /= No_Uint then
Check_Size (Expr, Component_Type (Btype), Csize, Biased); Check_Size (Expr, Ctyp, Csize, Biased);
if Has_Aliased_Components (Btype) if Has_Aliased_Components (Btype)
and then Csize < 32 and then Csize < 32
...@@ -1367,6 +1369,17 @@ package body Sem_Ch13 is ...@@ -1367,6 +1369,17 @@ package body Sem_Ch13 is
end if; end if;
end if; end if;
-- Deal with warning on overridden size
if Warn_On_Overridden_Size
and then Has_Size_Clause (Ctyp)
and then RM_Size (Ctyp) /= Csize
then
Error_Msg_NE
("?component size overrides size clause for&",
N, Ctyp);
end if;
Set_Has_Component_Size_Clause (Btype, True); Set_Has_Component_Size_Clause (Btype, True);
Set_Has_Non_Standard_Rep (Btype, True); Set_Has_Non_Standard_Rep (Btype, True);
end if; end if;
...@@ -2749,6 +2762,15 @@ package body Sem_Ch13 is ...@@ -2749,6 +2762,15 @@ package body Sem_Ch13 is
Set_Normalized_First_Bit (Comp, Fbit mod SSU); Set_Normalized_First_Bit (Comp, Fbit mod SSU);
Set_Normalized_Position (Comp, Fbit / SSU); Set_Normalized_Position (Comp, Fbit / SSU);
if Warn_On_Overridden_Size
and then Has_Size_Clause (Etype (Comp))
and then RM_Size (Etype (Comp)) /= Esize (Comp)
then
Error_Msg_NE
("?component size overrides size clause for&",
Component_Name (CC), Etype (Comp));
end if;
-- This information is also set in the corresponding -- This information is also set in the corresponding
-- component of the base type, found by accessing the -- component of the base type, found by accessing the
-- Original_Record_Component link if it is present. -- Original_Record_Component link if it is present.
......
...@@ -3085,6 +3085,7 @@ package body Sem_Warn is ...@@ -3085,6 +3085,7 @@ package body Sem_Warn is
Warn_On_Object_Renames_Function := True; Warn_On_Object_Renames_Function := True;
Warn_On_Obsolescent_Feature := True; Warn_On_Obsolescent_Feature := True;
Warn_On_Overlap := True; Warn_On_Overlap := True;
Warn_On_Overridden_Size := True;
Warn_On_Parameter_Order := True; Warn_On_Parameter_Order := True;
Warn_On_Questionable_Missing_Parens := True; Warn_On_Questionable_Missing_Parens := True;
Warn_On_Record_Holes := True; Warn_On_Record_Holes := True;
...@@ -3135,6 +3136,12 @@ package body Sem_Warn is ...@@ -3135,6 +3136,12 @@ package body Sem_Warn is
when 'R' => when 'R' =>
Warn_On_Object_Renames_Function := False; Warn_On_Object_Renames_Function := False;
when 's' =>
Warn_On_Overridden_Size := True;
when 'S' =>
Warn_On_Overridden_Size := False;
when 'u' => when 'u' =>
Warn_On_Unordered_Enumeration_Type := True; Warn_On_Unordered_Enumeration_Type := True;
...@@ -3268,6 +3275,7 @@ package body Sem_Warn is ...@@ -3268,6 +3275,7 @@ package body Sem_Warn is
Warn_On_Object_Renames_Function := False; Warn_On_Object_Renames_Function := False;
Warn_On_Obsolescent_Feature := False; Warn_On_Obsolescent_Feature := False;
Warn_On_Overlap := False; Warn_On_Overlap := False;
Warn_On_Overridden_Size := False;
Warn_On_Parameter_Order := False; Warn_On_Parameter_Order := False;
Warn_On_Record_Holes := False; Warn_On_Record_Holes := False;
Warn_On_Questionable_Missing_Parens := False; Warn_On_Questionable_Missing_Parens := False;
......
...@@ -47,6 +47,12 @@ package Sem_Warn is ...@@ -47,6 +47,12 @@ package Sem_Warn is
-- Warn when explicit record component clauses leave uncovered holes (gaps) -- Warn when explicit record component clauses leave uncovered holes (gaps)
-- in a record layout. Off by default, set by -gnatw.h (but not -gnatwa). -- in a record layout. Off by default, set by -gnatw.h (but not -gnatwa).
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 typen which was
-- set with an explicit size clause. Off by default, set by -gnatw.sn (but
-- not -gnatwa).
------------------------ ------------------------
-- Warnings Off Table -- -- Warnings Off Table --
------------------------ ------------------------
......
...@@ -161,6 +161,8 @@ gcc -c ^ GNAT COMPILE ...@@ -161,6 +161,8 @@ gcc -c ^ GNAT COMPILE
-gnatwP ^ /WARNINGS=NOINEFFECTIVE_INLINE -gnatwP ^ /WARNINGS=NOINEFFECTIVE_INLINE
-gnatw.p ^ /WARNINGS=PARAMETER_ORDER -gnatw.p ^ /WARNINGS=PARAMETER_ORDER
-gnatw.P ^ /WARNINGS=NO_PARAMETER_ORDER -gnatw.P ^ /WARNINGS=NO_PARAMETER_ORDER
-gnatw.h ^ /WARNINGS=OVERRIDING_SIZE
-gnatw.H ^ /WARNINGS=NOOVERRIDING_SIZE
-gnatwq ^ /WARNINGS=MISSING_PARENS -gnatwq ^ /WARNINGS=MISSING_PARENS
-gnatwQ ^ /WARNINGS=NOMISSING_PARENS -gnatwQ ^ /WARNINGS=NOMISSING_PARENS
-gnatwr ^ /WARNINGS=REDUNDANT -gnatwr ^ /WARNINGS=REDUNDANT
......
...@@ -468,6 +468,8 @@ begin ...@@ -468,6 +468,8 @@ begin
Write_Line (" .r+ turn on warnings for object renaming function"); Write_Line (" .r+ turn on warnings for object renaming function");
Write_Line (" .R* turn off warnings for object renaming function"); Write_Line (" .R* turn off warnings for object renaming function");
Write_Line (" s suppress all info/warnings"); Write_Line (" s suppress all info/warnings");
Write_Line (" .s turn on warnings for overridden size clause");
Write_Line (" .S* turn off warnings for overridden size clause");
Write_Line (" t turn on warnings for tracking deleted code"); Write_Line (" t turn on warnings for tracking deleted code");
Write_Line (" T* turn off warnings for tracking deleted code"); Write_Line (" T* turn off warnings for tracking deleted code");
Write_Line (" u+ turn on warnings for unused entity"); Write_Line (" u+ turn on warnings for unused entity");
......
...@@ -3011,6 +3011,10 @@ package VMS_Data is ...@@ -3011,6 +3011,10 @@ package VMS_Data is
"-gnatw.R " & "-gnatw.R " &
"SUPPRESS " & "SUPPRESS " &
"-gnatws " & "-gnatws " &
"OVERRIDING_SIZE " &
"-gnatw.s " &
"NOOVERRIDING_SIZE " &
"-gnatw.S " &
"DELETED_CODE " & "DELETED_CODE " &
"-gnatwt " & "-gnatwt " &
"NODELETED_CODE " & "NODELETED_CODE " &
......
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