aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
diff options
context:
space:
mode:
authorGeert Bosch <bosch@gcc.gnu.org>2002-03-08 21:11:04 +0100
committerGeert Bosch <bosch@gcc.gnu.org>2002-03-08 21:11:04 +0100
commit07fc65c47c45af6439208797e1ab26f7daedb666 (patch)
treeb584a79288c93215b05fb451943291ccd039388b /gcc/ada/sem_util.adb
parent24965e7a8ac518b99a3bd7ef5b2d8d88f96bf514 (diff)
downloadgcc-07fc65c47c45af6439208797e1ab26f7daedb666.zip
gcc-07fc65c47c45af6439208797e1ab26f7daedb666.tar.gz
gcc-07fc65c47c45af6439208797e1ab26f7daedb666.tar.bz2
41intnam.ads, [...]: Merge in ACT changes.
* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads, 4dintnam.ads, 4gintnam.ads, 4hintnam.ads, 4lintnam.ads, 4mintnam.ads, 4pintnam.ads, 4rintnam.ads, 4sintnam.ads, 4uintnam.ads, 4vcalend.adb, 4zintnam.ads, 52system.ads, 5amastop.adb, 5asystem.ads, 5ataprop.adb, 5atpopsp.adb, 5avxwork.ads, 5bosinte.adb, 5bsystem.ads, 5esystem.ads, 5fsystem.ads, 5ftaprop.adb, 5ginterr.adb, 5gmastop.adb, 5gsystem.ads, 5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads, 5hparame.ads, 5hsystem.ads, 5htaprop.adb, 5htraceb.adb, 5itaprop.adb, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb, 5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nosinte.ads, 5ntaprop.adb, 5ointerr.adb, 5omastop.adb, 5oosinte.adb, 5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5pvxwork.ads, 5qtaprop.adb, 5sintman.adb, 5ssystem.ads, 5staprop.adb, 5stpopse.adb, 5svxwork.ads, 5tosinte.ads, 5uintman.adb, 5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb, 5vmastop.adb, 5vparame.ads, 5vsystem.ads, 5vtaprop.adb, 5vtpopde.adb, 5wmemory.adb, 5wsystem.ads, 5wtaprop.adb, 5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb, 5zosinte.ads, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb, 7sintman.adb, 7staprop.adb, 7stpopsp.adb, 9drpc.adb, Make-lang.in, Makefile.in, a-caldel.adb, a-comlin.ads, a-dynpri.adb, a-except.adb, a-except.ads, a-finali.adb, a-ncelfu.ads, a-reatim.adb, a-retide.adb, a-stream.ads, a-ststio.adb, a-ststio.ads, a-stwifi.adb, a-tags.adb, a-tasatt.adb, a-textio.adb, a-tideau.adb, a-tiflau.adb, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-witeio.adb, a-wtdeau.adb, a-wtenau.adb, a-wtflau.adb, a-wtgeau.adb, a-wtgeau.ads, a-wtinau.adb, a-wtmoau.adb, ada-tree.def, ada-tree.h, adaint.c, adaint.h, ali-util.adb, ali.adb, ali.ads, atree.adb, atree.ads, atree.h, back_end.adb, bcheck.adb, bindgen.adb, bindusg.adb, checks.adb, comperr.adb, config-lang.in, csets.adb, csets.ads, cstand.adb, cstreams.c, debug.adb, debug.ads, decl.c, einfo.adb, einfo.ads, einfo.h, elists.h, errout.adb, errout.ads, eval_fat.adb, exp_aggr.adb, exp_attr.adb, exp_ch11.adb, exp_ch12.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch3.ads, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads, exp_ch9.adb, exp_ch9.ads, exp_dbug.adb, exp_dbug.ads, exp_disp.ads, exp_dist.adb, exp_fixd.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb, exp_strm.adb, exp_util.adb, exp_util.ads, expander.adb, expect.c, fe.h, fmap.adb, fmap.ads, fname-uf.adb, freeze.adb, frontend.adb, g-awk.adb, g-cgideb.adb, g-comlin.adb, g-comlin.ads, g-debpoo.adb, g-dirope.adb, g-dirope.ads, g-dyntab.adb, g-expect.adb, g-expect.ads, g-io.ads, g-io_aux.adb, g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-os_lib.adb, g-os_lib.ads, g-regexp.adb, g-regpat.adb, g-socket.adb, g-socket.ads, g-spipat.adb, g-table.adb, g-trasym.adb, g-trasym.ads, gigi.h, gmem.c, gnat1drv.adb, gnatbind.adb, gnatbl.c, gnatchop.adb, gnatcmd.adb, gnatdll.adb, gnatfind.adb, gnatlbr.adb, gnatlink.adb, gnatls.adb, gnatmem.adb, gnatprep.adb, gnatvsn.ads, gnatxref.adb, hlo.adb, hostparm.ads, i-cobol.adb, i-cpp.adb, i-cstrea.ads, i-cstrin.adb, i-pacdec.adb, i-vxwork.ads, impunit.adb, init.c, inline.adb, io-aux.c, layout.adb, lib-load.adb, lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads, lib.adb, lib.ads, make.adb, makeusg.adb, mdll.adb, memroot.adb, misc.c, mlib-tgt.adb, mlib-utl.adb, mlib-utl.ads, mlib.adb, namet.adb, namet.ads, namet.h, nlists.h, nmake.adb, nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads, output.adb, output.ads, par-ch2.adb, par-ch3.adb, par-ch5.adb, par-prag.adb, par-tchk.adb, par-util.adb, par.adb, prj-attr.adb, prj-dect.adb, prj-env.adb, prj-env.ads, prj-nmsc.adb, prj-part.adb, prj-proc.adb, prj-strt.adb, prj-tree.adb, prj-tree.ads, prj.adb, prj.ads, raise.c, raise.h, repinfo.adb, restrict.adb, restrict.ads, rident.ads, rtsfind.adb, rtsfind.ads, s-arit64.adb, s-asthan.adb, s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-crc32.adb, s-crc32.ads, s-direio.adb, s-fatgen.adb, s-fileio.adb, s-finimp.adb, s-gloloc.adb, s-gloloc.ads, s-interr.adb, s-mastop.adb, s-mastop.ads, s-memory.adb, s-parame.ads, s-parint.adb, s-pooglo.adb, s-pooloc.adb, s-rpc.adb, s-secsta.adb, s-sequio.adb, s-shasto.adb, s-soflin.adb, s-soflin.ads, s-stache.adb, s-taasde.adb, s-taasde.ads, s-tadeca.adb, s-tadeca.ads, s-tadert.adb, s-tadert.ads, s-taenca.adb, s-taenca.ads, s-taprob.adb, s-taprop.ads, s-tarest.adb, s-tasdeb.adb, s-tasini.adb, s-tasini.ads, s-taskin.adb, s-taskin.ads, s-tasque.adb, s-tasque.ads, s-tasren.adb, s-tasren.ads, s-tassta.adb, s-tasuti.adb, s-tasuti.ads, s-tataat.adb, s-tataat.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb, s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads, s-unstyp.ads, s-widenu.adb, scn-nlit.adb, scn.adb, sem.adb, sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb, sem_ch10.adb, sem_ch11.adb, sem_ch11.ads, sem_ch12.adb, sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch3.adb, sem_ch3.ads, sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb, sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_dist.adb, sem_elab.adb, sem_elim.adb, sem_elim.ads, sem_eval.adb, sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb, sem_type.adb, sem_util.adb, sem_util.ads, sem_vfpt.adb, sem_warn.adb, sinfo.adb, sinfo.ads, sinfo.h, sinput-l.adb, sinput-l.ads, sinput.adb, sinput.ads, snames.adb, snames.ads, snames.h, sprint.adb, sprint.ads, stringt.adb, stringt.ads, stringt.h, style.adb, switch.adb, switch.ads, sysdep.c, system.ads, table.adb, targparm.adb, targparm.ads, targtyps.c, tbuild.adb, tbuild.ads, tracebak.c, trans.c, tree_gen.adb, tree_io.adb, treepr.adb, treepr.ads, treeprs.ads, treeprs.adt, ttypes.ads, types.adb, types.ads, types.h, uintp.ads, urealp.ads, usage.adb, utils.c, utils2.c, validsw.adb, xnmake.adb, xr_tabls.adb, xr_tabls.ads, xref_lib.adb, xref_lib.ads : Merge in ACT changes. * 1ssecsta.adb, 1ssecsta.ads, a-chlat9.ads, a-cwila9.ads, g-enblsp.adb, g-md5.adb, g-md5.ads, gnatname.adb, gnatname.ads, mkdir.c, osint-b.adb, osint-b.ads, osint-c.adb, osint-c.ads, osint-l.adb, osint-l.ads, osint-m.adb, osint-m.ads : New files * 3lsoccon.ads, 5qparame.ads, 5qvxwork.ads, 5smastop.adb, 5zparame.ads, gnatmain.adb, gnatmain.ads, gnatpsys.adb : Removed * mdllfile.adb, mdllfile.ads, mdlltool.adb, mdlltool.ads : Renamed to mdll-fil.ad[bs] and mdll-util.ad[bs] * mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads : Renamed from mdllfile.ad[bs] and mdlltool.ad[bs] From-SVN: r50451
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb383
1 files changed, 323 insertions, 60 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 53b9ce6..cfb8b08 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -1,4 +1,4 @@
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
@@ -8,7 +8,7 @@
-- --
-- $Revision$
-- --
--- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2002, 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- --
@@ -106,12 +106,13 @@ package body Sem_Util is
-----------------------------------------
procedure Apply_Compile_Time_Constraint_Error
- (N : Node_Id;
- Msg : String;
- Ent : Entity_Id := Empty;
- Typ : Entity_Id := Empty;
- Loc : Source_Ptr := No_Location;
- Rep : Boolean := True)
+ (N : Node_Id;
+ Msg : String;
+ Reason : RT_Exception_Code;
+ Ent : Entity_Id := Empty;
+ Typ : Entity_Id := Empty;
+ Loc : Source_Ptr := No_Location;
+ Rep : Boolean := True)
is
Stat : constant Boolean := Is_Static_Expression (N);
Rtyp : Entity_Id;
@@ -132,7 +133,9 @@ package body Sem_Util is
-- Now we replace the node by an N_Raise_Constraint_Error node
-- This does not need reanalyzing, so set it as analyzed now.
- Rewrite (N, Make_Raise_Constraint_Error (Sloc (N)));
+ Rewrite (N,
+ Make_Raise_Constraint_Error (Sloc (N),
+ Reason => Reason));
Set_Analyzed (N, True);
Set_Etype (N, Rtyp);
Set_Raises_Constraint_Error (N);
@@ -677,6 +680,130 @@ package body Sem_Util is
Set_Has_Fully_Qualified_Name (Elab_Ent);
end Build_Elaboration_Entity;
+ -----------------------------------
+ -- Cannot_Raise_Constraint_Error --
+ -----------------------------------
+
+ function Cannot_Raise_Constraint_Error (Expr : Node_Id) return Boolean is
+ begin
+ if Compile_Time_Known_Value (Expr) then
+ return True;
+
+ elsif Do_Range_Check (Expr) then
+ return False;
+
+ elsif Raises_Constraint_Error (Expr) then
+ return False;
+
+ else
+ case Nkind (Expr) is
+ when N_Identifier =>
+ return True;
+
+ when N_Expanded_Name =>
+ return True;
+
+ when N_Selected_Component =>
+ return not Do_Discriminant_Check (Expr);
+
+ when N_Attribute_Reference =>
+ if Do_Overflow_Check (Expr)
+ or else Do_Access_Check (Expr)
+ then
+ return False;
+
+ elsif No (Expressions (Expr)) then
+ return True;
+
+ else
+ declare
+ N : Node_Id := First (Expressions (Expr));
+
+ begin
+ while Present (N) loop
+ if Cannot_Raise_Constraint_Error (N) then
+ Next (N);
+ else
+ return False;
+ end if;
+ end loop;
+
+ return True;
+ end;
+ end if;
+
+ when N_Type_Conversion =>
+ if Do_Overflow_Check (Expr)
+ or else Do_Length_Check (Expr)
+ or else Do_Tag_Check (Expr)
+ then
+ return False;
+ else
+ return
+ Cannot_Raise_Constraint_Error (Expression (Expr));
+ end if;
+
+ when N_Unchecked_Type_Conversion =>
+ return Cannot_Raise_Constraint_Error (Expression (Expr));
+
+ when N_Unary_Op =>
+ if Do_Overflow_Check (Expr) then
+ return False;
+ else
+ return
+ Cannot_Raise_Constraint_Error (Right_Opnd (Expr));
+ end if;
+
+ when N_Op_Divide |
+ N_Op_Mod |
+ N_Op_Rem
+ =>
+ if Do_Division_Check (Expr)
+ or else Do_Overflow_Check (Expr)
+ then
+ return False;
+ else
+ return
+ Cannot_Raise_Constraint_Error (Left_Opnd (Expr))
+ and then
+ Cannot_Raise_Constraint_Error (Right_Opnd (Expr));
+ end if;
+
+ when N_Op_Add |
+ N_Op_And |
+ N_Op_Concat |
+ N_Op_Eq |
+ N_Op_Expon |
+ N_Op_Ge |
+ N_Op_Gt |
+ N_Op_Le |
+ N_Op_Lt |
+ N_Op_Multiply |
+ N_Op_Ne |
+ N_Op_Or |
+ N_Op_Rotate_Left |
+ N_Op_Rotate_Right |
+ N_Op_Shift_Left |
+ N_Op_Shift_Right |
+ N_Op_Shift_Right_Arithmetic |
+ N_Op_Subtract |
+ N_Op_Xor
+ =>
+ if Do_Overflow_Check (Expr) then
+ return False;
+ else
+ return
+ Cannot_Raise_Constraint_Error (Left_Opnd (Expr))
+ and then
+ Cannot_Raise_Constraint_Error (Right_Opnd (Expr));
+ end if;
+
+ when others =>
+ return False;
+ end case;
+ end if;
+ end Cannot_Raise_Constraint_Error;
+
--------------------------
-- Check_Fully_Declared --
--------------------------
@@ -720,7 +847,8 @@ package body Sem_Util is
if Is_Protected_Type (S) then
if Restricted_Profile then
Insert_Before (N,
- Make_Raise_Program_Error (Loc));
+ Make_Raise_Program_Error (Loc,
+ Reason => PE_Potentially_Blocking_Operation));
Error_Msg_N ("potentially blocking operation, " &
" Program Error will be raised at run time?", N);
@@ -901,6 +1029,7 @@ package body Sem_Util is
Warn : Boolean;
P : Node_Id;
Msgs : Boolean;
+ Eloc : Source_Ptr;
begin
-- A static constraint error in an instance body is not a fatal error.
@@ -911,6 +1040,11 @@ package body Sem_Util is
-- No messages are generated if we already posted an error on this node
if not Error_Posted (N) then
+ if Loc /= No_Location then
+ Eloc := Loc;
+ else
+ Eloc := Sloc (N);
+ end if;
-- Make all such messages unconditional
@@ -978,25 +1112,25 @@ package body Sem_Util is
if Msgs then
if Present (Ent) then
- Error_Msg_NE (Msgc (1 .. Msgl), N, Ent);
+ Error_Msg_NEL (Msgc (1 .. Msgl), N, Ent, Eloc);
else
- Error_Msg_NE (Msgc (1 .. Msgl), N, Etype (N));
+ Error_Msg_NEL (Msgc (1 .. Msgl), N, Etype (N), Eloc);
end if;
if Warn then
if Inside_Init_Proc then
- Error_Msg_NE
+ Error_Msg_NEL
("\& will be raised for objects of this type!?",
- N, Standard_Constraint_Error);
+ N, Standard_Constraint_Error, Eloc);
else
- Error_Msg_NE
+ Error_Msg_NEL
("\& will be raised at run time!?",
- N, Standard_Constraint_Error);
+ N, Standard_Constraint_Error, Eloc);
end if;
else
- Error_Msg_NE
+ Error_Msg_NEL
("\static expression raises&!",
- N, Standard_Constraint_Error);
+ N, Standard_Constraint_Error, Eloc);
end if;
end if;
end if;
@@ -2188,6 +2322,21 @@ package body Sem_Util is
end if;
end Get_Enum_Lit_From_Pos;
+ ------------------------
+ -- Get_Generic_Entity --
+ ------------------------
+
+ function Get_Generic_Entity (N : Node_Id) return Entity_Id is
+ Ent : constant Entity_Id := Entity (Name (N));
+
+ begin
+ if Present (Renamed_Object (Ent)) then
+ return Renamed_Object (Ent);
+ else
+ return Ent;
+ end if;
+ end Get_Generic_Entity;
+
----------------------
-- Get_Index_Bounds --
----------------------
@@ -2827,8 +2976,16 @@ package body Sem_Util is
Comp :=
Original_Record_Component (Entity (Selector_Name (Object)));
+ -- As per AI-0017, the renaming is illegal in a generic body,
+ -- even if the subtype is indefinite.
+
if not Is_Constrained (Prefix_Type)
- and then not Is_Indefinite_Subtype (Prefix_Type)
+ and then (not Is_Indefinite_Subtype (Prefix_Type)
+ or else
+ (Is_Generic_Type (Prefix_Type)
+ and then Ekind (Current_Scope) = E_Generic_Package
+ and then In_Package_Body (Current_Scope)))
+
and then (Is_Declared_Within_Variant (Comp)
or else Has_Dependent_Constraint (Comp))
and then not P_Aliased
@@ -2944,6 +3101,8 @@ package body Sem_Util is
end;
end if;
+ -- If no null indexes, then type is not fully initialized
+
return False;
elsif Is_Record_Type (Typ) then
@@ -2966,6 +3125,9 @@ package body Sem_Util is
end loop;
end;
+ -- No uninitialized components, so type is fully initialized.
+ -- Note that this catches the case of no components as well.
+
return True;
elsif Is_Concurrent_Type (Typ) then
@@ -3060,6 +3222,11 @@ package body Sem_Util is
when N_Function_Call =>
return True;
+ -- A reference to the stream attribute Input is a function call.
+
+ when N_Attribute_Reference =>
+ return Attribute_Name (N) = Name_Input;
+
when N_Selected_Component =>
return Is_Object_Reference (Selector_Name (N));
@@ -3159,6 +3326,126 @@ package body Sem_Util is
end if;
end Is_OK_Variable_For_Out_Formal;
+ -----------------------------------
+ -- Is_Partially_Initialized_Type --
+ -----------------------------------
+
+ function Is_Partially_Initialized_Type (Typ : Entity_Id) return Boolean is
+ begin
+ if Is_Scalar_Type (Typ) then
+ return False;
+
+ elsif Is_Access_Type (Typ) then
+ return True;
+
+ elsif Is_Array_Type (Typ) then
+
+ -- If component type is partially initialized, so is array type
+
+ if Is_Partially_Initialized_Type (Component_Type (Typ)) then
+ return True;
+
+ -- Otherwise we are only partially initialized if we are fully
+ -- initialized (this is the empty array case, no point in us
+ -- duplicating that code here).
+
+ else
+ return Is_Fully_Initialized_Type (Typ);
+ end if;
+
+ elsif Is_Record_Type (Typ) then
+
+ -- A discriminated type is always partially initialized
+
+ if Has_Discriminants (Typ) then
+ return True;
+
+ -- A tagged type is always partially initialized
+
+ elsif Is_Tagged_Type (Typ) then
+ return True;
+
+ -- Case of non-discriminated record
+
+ else
+ declare
+ Ent : Entity_Id;
+
+ Component_Present : Boolean := False;
+ -- Set True if at least one component is present. If no
+ -- components are present, then record type is fully
+ -- initialized (another odd case, like the null array).
+
+ begin
+ -- Loop through components
+
+ Ent := First_Entity (Typ);
+ while Present (Ent) loop
+ if Ekind (Ent) = E_Component then
+ Component_Present := True;
+
+ -- If a component has an initialization expression then
+ -- the enclosing record type is partially initialized
+
+ if Present (Parent (Ent))
+ and then Present (Expression (Parent (Ent)))
+ then
+ return True;
+
+ -- If a component is of a type which is itself partially
+ -- initialized, then the enclosing record type is also.
+
+ elsif Is_Partially_Initialized_Type (Etype (Ent)) then
+ return True;
+ end if;
+ end if;
+
+ Next_Entity (Ent);
+ end loop;
+
+ -- No initialized components found. If we found any components
+ -- they were all uninitialized so the result is false.
+
+ if Component_Present then
+ return False;
+
+ -- But if we found no components, then all the components are
+ -- initialized so we consider the type to be initialized.
+
+ else
+ return True;
+ end if;
+ end;
+ end if;
+
+ -- Concurrent types are always fully initialized
+
+ elsif Is_Concurrent_Type (Typ) then
+ return True;
+
+ -- For a private type, go to underlying type. If there is no underlying
+ -- type then just assume this partially initialized. Not clear if this
+ -- can happen in a non-error case, but no harm in testing for this.
+
+ elsif Is_Private_Type (Typ) then
+ declare
+ U : constant Entity_Id := Underlying_Type (Typ);
+
+ begin
+ if No (U) then
+ return True;
+ else
+ return Is_Partially_Initialized_Type (U);
+ end if;
+ end;
+
+ -- For any other type (are there any?) assume partially initialized
+
+ else
+ return True;
+ end if;
+ end Is_Partially_Initialized_Type;
+
-----------------------------
-- Is_RCI_Pkg_Spec_Or_Body --
-----------------------------
@@ -4225,10 +4512,13 @@ package body Sem_Util is
-- Process_End_Label --
-----------------------
- procedure Process_End_Label (N : Node_Id; Typ : Character) is
+ procedure Process_End_Label
+ (N : Node_Id;
+ Typ : Character;
+ Ent : Entity_Id)
+ is
Loc : Source_Ptr;
Nam : Node_Id;
- Ctyp : Entity_Id;
Label_Ref : Boolean;
-- Set True if reference to end label itself is required
@@ -4238,14 +4528,15 @@ package body Sem_Util is
-- the entity Ent. For the child unit case, this is the identifier
-- from the designator. For other cases, this is simply Endl.
- Ent : Entity_Id;
- -- This is the entity for the construct to which the End_Label applies
-
procedure Generate_Parent_Ref (N : Node_Id);
-- N is an identifier node that appears as a parent unit reference
-- in the case where Ent is a child unit. This procedure generates
-- an appropriate cross-reference entry.
+ -------------------------
+ -- Generate_Parent_Ref --
+ -------------------------
+
procedure Generate_Parent_Ref (N : Node_Id) is
Parent_Ent : Entity_Id;
@@ -4353,41 +4644,13 @@ package body Sem_Util is
end if;
end if;
- -- Locate the entity to which the end label applies. Most of the
- -- time this is simply the current scope containing the construct.
-
- Ent := Current_Scope;
+ -- If the end label is not for the given entity, then either we have
+ -- some previous error, or this is a generic instantiation for which
+ -- we do not need to make a cross-reference in this case anyway. In
+ -- either case we simply ignore the call.
- if Chars (Ent) = Chars (Endl) then
- null;
-
- -- But in the case of single tasks and single protected objects,
- -- the current scope is the anonymous task or protected type and
- -- what we want is the object. There is no direct link so what we
- -- do is search ahead in the entity chain for the object with the
- -- matching type and name. In practice it is almost certain to be
- -- the very next entity on the chain, so this is not inefficient.
-
- else
- Ctyp := Etype (Ent);
- loop
- Next_Entity (Ent);
-
- -- If we don't find the entry we are looking for, that's
- -- odd, perhaps results from some error condition? Anyway
- -- the appropriate thing is just to abandon the attempt.
-
- if No (Ent) then
- return;
-
- -- Exit if we find the entity we are looking for
-
- elsif Etype (Ent) = Ctyp
- and then Chars (Ent) = Chars (Endl)
- then
- exit;
- end if;
- end loop;
+ if Chars (Ent) /= Chars (Endl) then
+ return;
end if;
-- If label was really there, then generate a normal reference
@@ -4399,11 +4662,11 @@ package body Sem_Util is
if Comes_From_Source (Endl) then
-- If a label reference is required, then do the style check
- -- and generate a normal cross-reference entry for the label
+ -- and generate an l-type cross-reference entry for the label
if Label_Ref then
Style.Check_Identifier (Endl, Ent);
- Generate_Reference (Ent, Endl, 'r', Set_Ref => False);
+ Generate_Reference (Ent, Endl, 'l', Set_Ref => False);
end if;
-- Set the location to point past the label (normally this will