aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_warn.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2004-04-05 16:57:42 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2004-04-05 16:57:42 +0200
commit30c2010625760849692e4fb21d7166616c138bb5 (patch)
tree2d91f19f11f8b38d7d3f5b5cf90649006ce6ddb8 /gcc/ada/sem_warn.adb
parent4f976745b7f4deeed63381e21990fd2a2c2e2103 (diff)
downloadgcc-30c2010625760849692e4fb21d7166616c138bb5.zip
gcc-30c2010625760849692e4fb21d7166616c138bb5.tar.gz
gcc-30c2010625760849692e4fb21d7166616c138bb5.tar.bz2
[multiple changes]
2004-04-05 Vincent Celier <celier@gnat.com> * adaint.h, adaint.c: Add function __gnat_named_file_length * impunit.adb: Add Ada.Directories to the list * Makefile.in: Add VMS and Windows versions of Ada.Directories.Validity package body. * Makefile.rtl: Add a-direct and a-dirval * mlib-tgt.ads: Minor comment update. * a-dirval.ads, a-dirval.adb, 5vdirval.adb, 5wdirval.adb, a-direct.ads, a-direct.adb: New files. 2004-04-05 Vincent Celier <celier@gnat.com> PR ada/13620 * make.adb (Scan_Make_Arg): Pass any -fxxx switches to gnatlink, not just to the compiler. 2004-04-05 Robert Dewar <dewar@gnat.com> * a-except.adb (Exception_Name_Simple): Make sure lower bound of returned string is 1. * ali-util.adb: Use proper specific form for Warnings (Off, entity) * eval_fat.ads: Minor reformatting * g-curexc.ads: Document that lower bound of returned string values is always one. * gnatlink.adb: Add ??? comment for previous change (need to document why this is VMS specific) * s-stoele.ads: Minor reformatting * tbuild.ads: Minor reformatting throughout (new function specs) * par-ch10.adb (P_Context_Clause): Handle comma instead of semicolon after WITH. * scng.adb: Minor reformatting 2004-04-05 Geert Bosch <bosch@gnat.com> * eval_fat.adb (Machine): Remove unnecessary suppression of warning. (Leading_Part): Still perform truncation to machine number if the specified radix_digits is greater or equal to machine_mantissa. 2004-04-05 Javier Miranda <miranda@gnat.com> * par-ch3.adb: Complete documentation of previous change Correct wrong syntax documentation of the OBJECT_DECLARATION rule (aliased must appear before constant). * par-ch4.adb: Complete documentation of previous change. * par-ch6.adb: Complete documentation of previous change. * sinfo.ads: Fix typo in commment. 2004-04-05 Ed Schonberg <schonberg@gnat.com> * sem_ch3.adb (Inherit_Components): If derived type is private and has stored discriminants, use its discriminants to constrain parent type, as is done for non-private derived record types. * sem_ch4.adb (Remove_Abstract_Operations): New subprogram to implement Ada 2005 AI-310: an abstract non-dispatching operation is not a candidate interpretation in an overloaded call. * tbuild.adb (Unchecked_Convert_To): Preserve conversion node if expression is Null and target type is not an access type (e.g. a non-private address type). 2004-04-05 Thomas Quinot <quinot@act-europe.fr> * exp_ch6.adb (Rewrite_Function_Call): When rewriting an assignment statement whose right-hand side is an inlined call, save a copy of the original assignment subtree to preserve enough consistency for Analyze_Assignment to proceed. * sem_ch5.adb (Analyze_Assignment): Remove a costly copy of the complete assignment subtree which is now unnecessary, as the expansion of inlined call has been improved to preserve a consistent assignment tree. Note_Possible_Modification must be called only after checks have been applied, or else unnecessary checks will be generated. * sem_util.adb (Note_Possible_Modification): Reorganise the handling of explicit dereferences that do not Come_From_Source: - be selective on cases where we must go back to the dereferenced pointer (an assignment to an implicit dereference must not be recorded as modifying the pointer); - do not rely on Original_Node being present (Analyze_Assignment calls Note_Possible_Modification on a copied tree). * sem_warn.adb (Check_References): When an unset reference to a pointer that is never assigned is encountered, prefer '<pointer> may be null' warning over '<pointer> is never assigned a value'. 2004-04-05 Ramon Fernandez <fernandez@gnat.com> * tracebak.c: Change STOP_FRAME in ppc vxworks to be compliant with the ABI. 2004-04-05 Olivier Hainque <hainque@act-europe.fr> * 5gmastop.adb (Pop_Frame): Comment out the pragma Linker_Option for libexc. We currently don't reference anything in this library and linking it in triggers linker warnings we don't want to see. * init.c: Update comments. From-SVN: r80431
Diffstat (limited to 'gcc/ada/sem_warn.adb')
-rw-r--r--gcc/ada/sem_warn.adb136
1 files changed, 71 insertions, 65 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index c6aa359..187fc9b 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -351,7 +351,7 @@ package body Sem_Warn is
E1 := First_Entity (E);
while Present (E1) loop
- -- We only look at source entities with warning flag off
+ -- We only look at source entities with warning flag on
if Comes_From_Source (E1) and then not Warnings_Off (E1) then
@@ -367,6 +367,14 @@ package body Sem_Warn is
-- do not consider the implicit initialization of an access
-- type to be the assignment of a value for this purpose.
+ if Ekind (E1) = E_Out_Parameter
+ and then Present (Spec_Entity (E1))
+ then
+ UR := Unset_Reference (Spec_Entity (E1));
+ else
+ UR := Unset_Reference (E1);
+ end if;
+
-- If the entity is an out parameter of the current subprogram
-- body, check the warning status of the parameter in the spec.
@@ -376,6 +384,23 @@ package body Sem_Warn is
then
null;
+ elsif Warn_On_No_Value_Assigned
+ and then Present (UR)
+ and then Is_Access_Type (Etype (E1))
+ then
+
+ -- For access types, the only time we made a UR
+ -- entry was for a dereference, and so we post
+ -- the appropriate warning here (note that the
+ -- dereference may not be explicit in the source,
+ -- for example in the case of a dispatching call
+ -- with an anonymous access controlling formal, or
+ -- of an assignment of a pointer involving a
+ -- discriminant check on the designated object).
+
+ Error_Msg_NE ("& may be null?", UR, E1);
+ goto Continue;
+
elsif Never_Set_In_Source (E1)
and then not Generic_Package_Spec_Entity (E1)
then
@@ -435,86 +460,67 @@ package body Sem_Warn is
-- types from this check, since access types do always have
-- a null value, and that seems legitimate in this case.
- if Ekind (E1) = E_Out_Parameter
- and then Present (Spec_Entity (E1))
- then
- UR := Unset_Reference (Spec_Entity (E1));
- else
- UR := Unset_Reference (E1);
- end if;
-
if Warn_On_No_Value_Assigned and then Present (UR) then
- -- For access types, the only time we made a UR entry
- -- was for a dereference, and so we post the appropriate
- -- warning here. The issue is not that the value is not
- -- initialized here, but that it is null.
-
- if Is_Access_Type (Etype (E1)) then
- Error_Msg_NE ("& may be null?", UR, E1);
- goto Continue;
-
-- For other than access type, go back to original node
-- to deal with case where original unset reference
-- has been rewritten during expansion.
- else
- UR := Original_Node (UR);
+ UR := Original_Node (UR);
- -- In some cases, the original node may be a type
- -- conversion or qualification, and in this case
- -- we want the object entity inside.
+ -- In some cases, the original node may be a type
+ -- conversion or qualification, and in this case
+ -- we want the object entity inside.
- while Nkind (UR) = N_Type_Conversion
- or else Nkind (UR) = N_Qualified_Expression
- loop
- UR := Expression (UR);
- end loop;
+ while Nkind (UR) = N_Type_Conversion
+ or else Nkind (UR) = N_Qualified_Expression
+ loop
+ UR := Expression (UR);
+ end loop;
- -- Here we issue the warning, all checks completed
- -- If the unset reference is prefix of a selected
- -- component that comes from source, mention the
- -- component as well. If the selected component comes
- -- from expansion, all we know is that the entity is
- -- not fully initialized at the point of the reference.
- -- Locate an unintialized component to get a better
- -- error message.
+ -- Here we issue the warning, all checks completed
+ -- If the unset reference is prefix of a selected
+ -- component that comes from source, mention the
+ -- component as well. If the selected component comes
+ -- from expansion, all we know is that the entity is
+ -- not fully initialized at the point of the reference.
+ -- Locate an unintialized component to get a better
+ -- error message.
- if Nkind (Parent (UR)) = N_Selected_Component then
- Error_Msg_Node_2 := Selector_Name (Parent (UR));
+ if Nkind (Parent (UR)) = N_Selected_Component then
+ Error_Msg_Node_2 := Selector_Name (Parent (UR));
- if not Comes_From_Source (Parent (UR)) then
- declare
- Comp : Entity_Id;
+ if not Comes_From_Source (Parent (UR)) then
+ declare
+ Comp : Entity_Id;
- begin
- Comp := First_Entity (Etype (E1));
- while Present (Comp) loop
- if Ekind (Comp) = E_Component
- and then Nkind (Parent (Comp)) =
- N_Component_Declaration
- and then No (Expression (Parent (Comp)))
- then
- Error_Msg_Node_2 := Comp;
- exit;
- end if;
-
- Next_Entity (Comp);
- end loop;
- end;
- end if;
+ begin
+ Comp := First_Entity (Etype (E1));
+ while Present (Comp) loop
+ if Ekind (Comp) = E_Component
+ and then Nkind (Parent (Comp)) =
+ N_Component_Declaration
+ and then No (Expression (Parent (Comp)))
+ then
+ Error_Msg_Node_2 := Comp;
+ exit;
+ end if;
- Error_Msg_N
- ("`&.&` may be referenced before it has a value?",
- UR);
- else
- Error_Msg_N
- ("& may be referenced before it has a value?",
- UR);
+ Next_Entity (Comp);
+ end loop;
+ end;
end if;
- goto Continue;
+ Error_Msg_N
+ ("`&.&` may be referenced before it has a value?",
+ UR);
+ else
+ Error_Msg_N
+ ("& may be referenced before it has a value?",
+ UR);
end if;
+
+ goto Continue;
end if;
end if;