Commit 9cf50493 by Ed Schonberg Committed by Arnaud Charlet

exp_strm.adb (Build_Record_Or_Elementary_Input_Function): If this is an Input…

exp_strm.adb (Build_Record_Or_Elementary_Input_Function): If this is an Input function for an access type...

2008-04-08  Ed Schonberg  <schonberg@adacore.com>

	* exp_strm.adb (Build_Record_Or_Elementary_Input_Function): If this is
	an Input function for an access type, do not perform default
	initialization on the local variable that receives the value, to
	prevent spurious warnings when the type is null-excluding.

From-SVN: r134032
parent 7f0b5314
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -373,7 +373,7 @@ package body Exp_Strm is ...@@ -373,7 +373,7 @@ package body Exp_Strm is
-- array may be user-defined, and be frozen after the type for which -- array may be user-defined, and be frozen after the type for which
-- we are generating the stream subprogram. In that case, freeze the -- we are generating the stream subprogram. In that case, freeze the
-- stream attribute of the component type, whose declaration could not -- stream attribute of the component type, whose declaration could not
-- generate any additional freezing actions in any case. See 5509-003. -- generate any additional freezing actions in any case.
if Nam = Name_Read then if Nam = Name_Read then
RW := TSS (Base_Type (Ctyp), TSS_Stream_Read); RW := TSS (Base_Type (Ctyp), TSS_Stream_Read);
...@@ -1092,13 +1092,14 @@ package body Exp_Strm is ...@@ -1092,13 +1092,14 @@ package body Exp_Strm is
Decl : out Node_Id; Decl : out Node_Id;
Fnam : out Entity_Id) Fnam : out Entity_Id)
is is
Cn : Name_Id; Cn : Name_Id;
J : Pos; J : Pos;
Decls : List_Id; Decls : List_Id;
Constr : List_Id; Constr : List_Id;
Stms : List_Id; Obj_Decl : Node_Id;
Discr : Entity_Id; Stms : List_Id;
Odef : Node_Id; Discr : Entity_Id;
Odef : Node_Id;
begin begin
Decls := New_List; Decls := New_List;
...@@ -1152,14 +1153,23 @@ package body Exp_Strm is ...@@ -1152,14 +1153,23 @@ package body Exp_Strm is
-- Perhaps we should just generate an extended return in all cases??? -- Perhaps we should just generate an extended return in all cases???
Obj_Decl :=
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
Object_Definition => Odef);
-- If the type is an access type, do not perform default initialization.
-- The object is about to get its value from Read, and if the type is
-- null excluding we do not want spurious warnings on an initial null.
if Is_Access_Type (Typ) then
Set_No_Initialization (Obj_Decl);
end if;
if Ada_Version >= Ada_05 then if Ada_Version >= Ada_05 then
Stms := New_List ( Stms := New_List (
Make_Extended_Return_Statement (Loc, Make_Extended_Return_Statement (Loc,
Return_Object_Declarations => Return_Object_Declarations => New_List (Obj_Decl),
New_List (Make_Object_Declaration (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_V),
Object_Definition => Odef)),
Handled_Statement_Sequence => Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Make_Handled_Sequence_Of_Statements (Loc,
New_List (Make_Attribute_Reference (Loc, New_List (Make_Attribute_Reference (Loc,
...@@ -1170,10 +1180,7 @@ package body Exp_Strm is ...@@ -1170,10 +1180,7 @@ package body Exp_Strm is
Make_Identifier (Loc, Name_V))))))); Make_Identifier (Loc, Name_V)))))));
else else
Append_To (Decls, Append_To (Decls, Obj_Decl);
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
Object_Definition => Odef));
Stms := New_List ( Stms := New_List (
Make_Attribute_Reference (Loc, Make_Attribute_Reference (Loc,
......
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