PR c++/60417
[official-gcc.git] / gcc / ada / exp_dbug.adb
blobc025f05f3784a6922cf5c911ff44eee0a256b2b0
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ D B U G --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1996-2014, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with Alloc; use Alloc;
27 with Atree; use Atree;
28 with Debug; use Debug;
29 with Einfo; use Einfo;
30 with Nlists; use Nlists;
31 with Nmake; use Nmake;
32 with Opt; use Opt;
33 with Output; use Output;
34 with Sem_Aux; use Sem_Aux;
35 with Sem_Eval; use Sem_Eval;
36 with Sem_Util; use Sem_Util;
37 with Sinfo; use Sinfo;
38 with Stand; use Stand;
39 with Stringt; use Stringt;
40 with Table;
41 with Targparm; use Targparm;
42 with Tbuild; use Tbuild;
43 with Urealp; use Urealp;
45 package body Exp_Dbug is
47 -- The following table is used to queue up the entities passed as
48 -- arguments to Qualify_Entity_Names for later processing when
49 -- Qualify_All_Entity_Names is called.
51 package Name_Qualify_Units is new Table.Table (
52 Table_Component_Type => Node_Id,
53 Table_Index_Type => Nat,
54 Table_Low_Bound => 1,
55 Table_Initial => Alloc.Name_Qualify_Units_Initial,
56 Table_Increment => Alloc.Name_Qualify_Units_Increment,
57 Table_Name => "Name_Qualify_Units");
59 --------------------------------
60 -- Use of Qualification Flags --
61 --------------------------------
63 -- There are two flags used to keep track of qualification of entities
65 -- Has_Fully_Qualified_Name
66 -- Has_Qualified_Name
68 -- The difference between these is as follows. Has_Qualified_Name is
69 -- set to indicate that the name has been qualified as required by the
70 -- spec of this package. As described there, this may involve the full
71 -- qualification for the name, but for some entities, notably procedure
72 -- local variables, this full qualification is not required.
74 -- The flag Has_Fully_Qualified_Name is set if indeed the name has been
75 -- fully qualified in the Ada sense. If Has_Fully_Qualified_Name is set,
76 -- then Has_Qualified_Name is also set, but the other way round is not
77 -- the case.
79 -- Consider the following example:
81 -- with ...
82 -- procedure X is
83 -- B : Ddd.Ttt;
84 -- procedure Y is ..
86 -- Here B is a procedure local variable, so it does not need fully
87 -- qualification. The flag Has_Qualified_Name will be set on the
88 -- first attempt to qualify B, to indicate that the job is done
89 -- and need not be redone.
91 -- But Y is qualified as x__y, since procedures are always fully
92 -- qualified, so the first time that an attempt is made to qualify
93 -- the name y, it will be replaced by x__y, and both flags are set.
95 -- Why the two flags? Well there are cases where we derive type names
96 -- from object names. As noted in the spec, type names are always
97 -- fully qualified. Suppose for example that the backend has to build
98 -- a padded type for variable B. then it will construct the PAD name
99 -- from B, but it requires full qualification, so the fully qualified
100 -- type name will be x__b___PAD. The two flags allow the circuit for
101 -- building this name to realize efficiently that b needs further
102 -- qualification.
104 --------------------
105 -- Homonym_Suffix --
106 --------------------
108 -- The string defined here (and its associated length) is used to gather
109 -- the homonym string that will be appended to Name_Buffer when the name
110 -- is complete. Strip_Suffixes appends to this string as does
111 -- Append_Homonym_Number, and Output_Homonym_Numbers_Suffix appends the
112 -- string to the end of Name_Buffer.
114 Homonym_Numbers : String (1 .. 256);
115 Homonym_Len : Natural := 0;
117 ----------------------
118 -- Local Procedures --
119 ----------------------
121 procedure Add_Uint_To_Buffer (U : Uint);
122 -- Add image of universal integer to Name_Buffer, updating Name_Len
124 procedure Add_Real_To_Buffer (U : Ureal);
125 -- Add nnn_ddd to Name_Buffer, where nnn and ddd are integer values of
126 -- the normalized numerator and denominator of the given real value.
128 procedure Append_Homonym_Number (E : Entity_Id);
129 -- If the entity E has homonyms in the same scope, then make an entry
130 -- in the Homonym_Numbers array, bumping Homonym_Count accordingly.
132 function Bounds_Match_Size (E : Entity_Id) return Boolean;
133 -- Determine whether the bounds of E match the size of the type. This is
134 -- used to determine whether encoding is required for a discrete type.
136 procedure Output_Homonym_Numbers_Suffix;
137 -- If homonym numbers are stored, then output them into Name_Buffer
139 procedure Prepend_String_To_Buffer (S : String);
140 -- Prepend given string to the contents of the string buffer, updating
141 -- the value in Name_Len (i.e. string is added at start of buffer).
143 procedure Prepend_Uint_To_Buffer (U : Uint);
144 -- Prepend image of universal integer to Name_Buffer, updating Name_Len
146 procedure Qualify_Entity_Name (Ent : Entity_Id);
147 -- If not already done, replaces the Chars field of the given entity
148 -- with the appropriate fully qualified name.
150 procedure Reset_Buffers;
151 -- Reset the contents of Name_Buffer and Homonym_Numbers by setting their
152 -- respective lengths to zero.
154 procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean);
155 -- Given an qualified entity name in Name_Buffer, remove any plain X or
156 -- X{nb} qualification suffix. The contents of Name_Buffer is not changed
157 -- but Name_Len may be adjusted on return to remove the suffix. If a
158 -- BNPE suffix is found and stripped, then BNPE_Suffix_Found is set to
159 -- True. If no suffix is found, then BNPE_Suffix_Found is not modified.
160 -- This routine also searches for a homonym suffix, and if one is found
161 -- it is also stripped, and the entries are added to the global homonym
162 -- list (Homonym_Numbers) so that they can later be put back.
164 ------------------------
165 -- Add_Real_To_Buffer --
166 ------------------------
168 procedure Add_Real_To_Buffer (U : Ureal) is
169 begin
170 Add_Uint_To_Buffer (Norm_Num (U));
171 Add_Str_To_Name_Buffer ("_");
172 Add_Uint_To_Buffer (Norm_Den (U));
173 end Add_Real_To_Buffer;
175 ------------------------
176 -- Add_Uint_To_Buffer --
177 ------------------------
179 procedure Add_Uint_To_Buffer (U : Uint) is
180 begin
181 if U < 0 then
182 Add_Uint_To_Buffer (-U);
183 Add_Char_To_Name_Buffer ('m');
184 else
185 UI_Image (U, Decimal);
186 Add_Str_To_Name_Buffer (UI_Image_Buffer (1 .. UI_Image_Length));
187 end if;
188 end Add_Uint_To_Buffer;
190 ---------------------------
191 -- Append_Homonym_Number --
192 ---------------------------
194 procedure Append_Homonym_Number (E : Entity_Id) is
196 procedure Add_Nat_To_H (Nr : Nat);
197 -- Little procedure to append Nr to Homonym_Numbers
199 ------------------
200 -- Add_Nat_To_H --
201 ------------------
203 procedure Add_Nat_To_H (Nr : Nat) is
204 begin
205 if Nr >= 10 then
206 Add_Nat_To_H (Nr / 10);
207 end if;
209 Homonym_Len := Homonym_Len + 1;
210 Homonym_Numbers (Homonym_Len) :=
211 Character'Val (Nr mod 10 + Character'Pos ('0'));
212 end Add_Nat_To_H;
214 -- Start of processing for Append_Homonym_Number
216 begin
217 if Has_Homonym (E) then
218 declare
219 H : Entity_Id := Homonym (E);
220 Nr : Nat := 1;
222 begin
223 while Present (H) loop
224 if Scope (H) = Scope (E) then
225 Nr := Nr + 1;
226 end if;
228 H := Homonym (H);
229 end loop;
231 if Homonym_Len > 0 then
232 Homonym_Len := Homonym_Len + 1;
233 Homonym_Numbers (Homonym_Len) := '_';
234 end if;
236 Add_Nat_To_H (Nr);
237 end;
238 end if;
239 end Append_Homonym_Number;
241 -----------------------
242 -- Bounds_Match_Size --
243 -----------------------
245 function Bounds_Match_Size (E : Entity_Id) return Boolean is
246 Siz : Uint;
248 begin
249 if not Is_OK_Static_Subtype (E) then
250 return False;
252 elsif Is_Integer_Type (E)
253 and then Subtypes_Statically_Match (E, Base_Type (E))
254 then
255 return True;
257 -- Here we check if the static bounds match the natural size, which is
258 -- the size passed through with the debugging information. This is the
259 -- Esize rounded up to 8, 16, 32 or 64 as appropriate.
261 else
262 declare
263 Umark : constant Uintp.Save_Mark := Uintp.Mark;
264 Result : Boolean;
266 begin
267 if Esize (E) <= 8 then
268 Siz := Uint_8;
269 elsif Esize (E) <= 16 then
270 Siz := Uint_16;
271 elsif Esize (E) <= 32 then
272 Siz := Uint_32;
273 else
274 Siz := Uint_64;
275 end if;
277 if Is_Modular_Integer_Type (E) or else Is_Enumeration_Type (E) then
278 Result :=
279 Expr_Rep_Value (Type_Low_Bound (E)) = 0
280 and then
281 2 ** Siz - Expr_Rep_Value (Type_High_Bound (E)) = 1;
283 else
284 Result :=
285 Expr_Rep_Value (Type_Low_Bound (E)) + 2 ** (Siz - 1) = 0
286 and then
287 2 ** (Siz - 1) - Expr_Rep_Value (Type_High_Bound (E)) = 1;
288 end if;
290 Release (Umark);
291 return Result;
292 end;
293 end if;
294 end Bounds_Match_Size;
296 --------------------------------
297 -- Debug_Renaming_Declaration --
298 --------------------------------
300 function Debug_Renaming_Declaration (N : Node_Id) return Node_Id is
301 Loc : constant Source_Ptr := Sloc (N);
302 Ent : constant Node_Id := Defining_Entity (N);
303 Nam : constant Node_Id := Name (N);
304 Ren : Node_Id;
305 Typ : Entity_Id;
306 Obj : Entity_Id;
307 Res : Node_Id;
309 Enable : Boolean := Nkind (N) = N_Package_Renaming_Declaration;
310 -- By default, we do not generate an encoding for renaming. This is
311 -- however done (in which case this is set to True) in a few cases:
312 -- - when a package is renamed,
313 -- - when the renaming involves a packed array,
314 -- - when the renaming involves a packed record.
316 procedure Enable_If_Packed_Array (N : Node_Id);
317 -- Enable encoding generation if N is a packed array
319 function Output_Subscript (N : Node_Id; S : String) return Boolean;
320 -- Outputs a single subscript value as ?nnn (subscript is compile time
321 -- known value with value nnn) or as ?e (subscript is local constant
322 -- with name e), where S supplies the proper string to use for ?.
323 -- Returns False if the subscript is not of an appropriate type to
324 -- output in one of these two forms. The result is prepended to the
325 -- name stored in Name_Buffer.
327 ----------------------------
328 -- Enable_If_Packed_Array --
329 ----------------------------
331 procedure Enable_If_Packed_Array (N : Node_Id) is
332 T : constant Entity_Id := Etype (N);
333 begin
334 Enable :=
335 Enable or else (Ekind (T) in Array_Kind
336 and then Present (Packed_Array_Impl_Type (T)));
337 end Enable_If_Packed_Array;
339 ----------------------
340 -- Output_Subscript --
341 ----------------------
343 function Output_Subscript (N : Node_Id; S : String) return Boolean is
344 begin
345 if Compile_Time_Known_Value (N) then
346 Prepend_Uint_To_Buffer (Expr_Value (N));
348 elsif Nkind (N) = N_Identifier
349 and then Scope (Entity (N)) = Scope (Ent)
350 and then Ekind (Entity (N)) = E_Constant
351 then
352 Prepend_String_To_Buffer (Get_Name_String (Chars (Entity (N))));
354 else
355 return False;
356 end if;
358 Prepend_String_To_Buffer (S);
359 return True;
360 end Output_Subscript;
362 -- Start of processing for Debug_Renaming_Declaration
364 begin
365 if not Comes_From_Source (N)
366 and then not Needs_Debug_Info (Ent)
367 then
368 return Empty;
369 end if;
371 -- Do not output those local variables in VM case, as this does not
372 -- help debugging (they are just unused), and might lead to duplicated
373 -- local variable names.
375 if VM_Target /= No_VM then
376 return Empty;
377 end if;
379 -- Get renamed entity and compute suffix
381 Name_Len := 0;
382 Ren := Nam;
383 loop
384 case Nkind (Ren) is
386 when N_Identifier =>
387 exit;
389 when N_Expanded_Name =>
391 -- The entity field for an N_Expanded_Name is on the expanded
392 -- name node itself, so we are done here too.
394 exit;
396 when N_Selected_Component =>
397 Enable := Enable or else Is_Packed (Etype (Prefix (Ren)));
398 Prepend_String_To_Buffer
399 (Get_Name_String (Chars (Selector_Name (Ren))));
400 Prepend_String_To_Buffer ("XR");
401 Ren := Prefix (Ren);
403 when N_Indexed_Component =>
404 declare
405 X : Node_Id;
407 begin
408 Enable_If_Packed_Array (Prefix (Ren));
410 X := Last (Expressions (Ren));
411 while Present (X) loop
412 if not Output_Subscript (X, "XS") then
413 Set_Materialize_Entity (Ent);
414 return Empty;
415 end if;
417 Prev (X);
418 end loop;
419 end;
421 Ren := Prefix (Ren);
423 when N_Slice =>
424 Enable_If_Packed_Array (Prefix (Ren));
425 Typ := Etype (First_Index (Etype (Nam)));
427 if not Output_Subscript (Type_High_Bound (Typ), "XS") then
428 Set_Materialize_Entity (Ent);
429 return Empty;
430 end if;
432 if not Output_Subscript (Type_Low_Bound (Typ), "XL") then
433 Set_Materialize_Entity (Ent);
434 return Empty;
435 end if;
437 Ren := Prefix (Ren);
439 when N_Explicit_Dereference =>
440 Prepend_String_To_Buffer ("XA");
441 Ren := Prefix (Ren);
443 -- For now, anything else simply results in no translation
445 when others =>
446 Set_Materialize_Entity (Ent);
447 return Empty;
448 end case;
449 end loop;
451 -- If we found no reason here to emit an encoding, stop now
453 if not Enable then
454 Set_Materialize_Entity (Ent);
455 return Empty;
456 end if;
458 Prepend_String_To_Buffer ("___XE");
460 -- Include the designation of the form of renaming
462 case Nkind (N) is
463 when N_Object_Renaming_Declaration =>
464 Prepend_String_To_Buffer ("___XR");
466 when N_Exception_Renaming_Declaration =>
467 Prepend_String_To_Buffer ("___XRE");
469 when N_Package_Renaming_Declaration =>
470 Prepend_String_To_Buffer ("___XRP");
472 when others =>
473 return Empty;
474 end case;
476 -- Add the name of the renaming entity to the front
478 Prepend_String_To_Buffer (Get_Name_String (Chars (Ent)));
480 -- If it is a child unit create a fully qualified name, to disambiguate
481 -- multiple child units with the same name and different parents.
483 if Nkind (N) = N_Package_Renaming_Declaration
484 and then Is_Child_Unit (Ent)
485 then
486 Prepend_String_To_Buffer ("__");
487 Prepend_String_To_Buffer
488 (Get_Name_String (Chars (Scope (Ent))));
489 end if;
491 -- Create the special object whose name is the debug encoding for the
492 -- renaming declaration.
494 -- For now, the object name contains the suffix encoding for the renamed
495 -- object, but not the name of the leading entity. The object is linked
496 -- the renamed entity using the Debug_Renaming_Link field. Then the
497 -- Qualify_Entity_Name procedure uses this link to create the proper
498 -- fully qualified name.
500 -- The reason we do things this way is that we really need to copy the
501 -- qualification of the renamed entity, and it is really much easier to
502 -- do this after the renamed entity has itself been fully qualified.
504 Obj := Make_Defining_Identifier (Loc, Chars => Name_Enter);
505 Res :=
506 Make_Object_Declaration (Loc,
507 Defining_Identifier => Obj,
508 Object_Definition => New_Occurrence_Of
509 (Standard_Debug_Renaming_Type, Loc));
511 Set_Debug_Renaming_Link (Obj, Entity (Ren));
513 Set_Debug_Info_Needed (Obj);
515 -- The renamed entity may be a temporary, e.g. the result of an
516 -- implicit dereference in an iterator. Indicate that the temporary
517 -- itself requires debug information. If the renamed entity comes
518 -- from source this is a no-op.
520 Set_Debug_Info_Needed (Entity (Ren));
522 -- Mark the object as internal so that it won't be initialized when
523 -- pragma Initialize_Scalars or Normalize_Scalars is in use.
525 Set_Is_Internal (Obj);
527 return Res;
529 -- If we get an exception, just figure it is a case that we cannot
530 -- successfully handle using our current approach, since this is
531 -- only for debugging, no need to take the compilation with us.
533 exception
534 when others =>
535 return Make_Null_Statement (Loc);
536 end Debug_Renaming_Declaration;
538 ----------------------
539 -- Get_Encoded_Name --
540 ----------------------
542 -- Note: see spec for details on encodings
544 procedure Get_Encoded_Name (E : Entity_Id) is
545 Has_Suffix : Boolean;
547 begin
548 -- If not generating code, there is no need to create encoded names, and
549 -- problems when the back-end is called to annotate types without full
550 -- code generation. See comments in Get_External_Name for additional
551 -- details.
553 -- However we do create encoded names if the back end is active, even
554 -- if Operating_Mode got reset. Otherwise any serious error reported
555 -- by the backend calling Error_Msg changes the Compilation_Mode to
556 -- Check_Semantics, which disables the functionality of this routine,
557 -- causing the generation of spurious additional errors.
559 -- Couldn't we just test Original_Operating_Mode here? ???
561 if Operating_Mode /= Generate_Code
562 and then not Generating_Code
563 then
564 return;
565 end if;
567 Get_Name_String (Chars (E));
569 -- Nothing to do if we do not have a type
571 if not Is_Type (E)
573 -- Or if this is an enumeration base type
575 or else (Is_Enumeration_Type (E) and then Is_Base_Type (E))
577 -- Or if this is a dummy type for a renaming
579 or else (Name_Len >= 3 and then
580 Name_Buffer (Name_Len - 2 .. Name_Len) = "_XR")
582 or else (Name_Len >= 4 and then
583 (Name_Buffer (Name_Len - 3 .. Name_Len) = "_XRE"
584 or else
585 Name_Buffer (Name_Len - 3 .. Name_Len) = "_XRP"))
587 -- For all these cases, just return the name unchanged
589 then
590 Name_Buffer (Name_Len + 1) := ASCII.NUL;
591 return;
592 end if;
594 Has_Suffix := True;
596 -- Fixed-point case
598 if Is_Fixed_Point_Type (E) then
599 Get_External_Name (E, True, "XF_");
600 Add_Real_To_Buffer (Delta_Value (E));
602 if Small_Value (E) /= Delta_Value (E) then
603 Add_Str_To_Name_Buffer ("_");
604 Add_Real_To_Buffer (Small_Value (E));
605 end if;
607 -- Discrete case where bounds do not match size
609 elsif Is_Discrete_Type (E)
610 and then not Bounds_Match_Size (E)
611 then
612 declare
613 Lo : constant Node_Id := Type_Low_Bound (E);
614 Hi : constant Node_Id := Type_High_Bound (E);
616 Lo_Con : constant Boolean := Compile_Time_Known_Value (Lo);
617 Hi_Con : constant Boolean := Compile_Time_Known_Value (Hi);
619 Lo_Discr : constant Boolean :=
620 Nkind (Lo) = N_Identifier
621 and then
622 Ekind (Entity (Lo)) = E_Discriminant;
624 Hi_Discr : constant Boolean :=
625 Nkind (Hi) = N_Identifier
626 and then
627 Ekind (Entity (Hi)) = E_Discriminant;
629 Lo_Encode : constant Boolean := Lo_Con or Lo_Discr;
630 Hi_Encode : constant Boolean := Hi_Con or Hi_Discr;
632 Biased : constant Boolean := Has_Biased_Representation (E);
634 begin
635 if Biased then
636 Get_External_Name (E, True, "XB");
637 else
638 Get_External_Name (E, True, "XD");
639 end if;
641 if Lo_Encode or Hi_Encode then
642 if Biased then
643 Add_Str_To_Name_Buffer ("_");
644 else
645 if Lo_Encode then
646 if Hi_Encode then
647 Add_Str_To_Name_Buffer ("LU_");
648 else
649 Add_Str_To_Name_Buffer ("L_");
650 end if;
651 else
652 Add_Str_To_Name_Buffer ("U_");
653 end if;
654 end if;
656 if Lo_Con then
657 Add_Uint_To_Buffer (Expr_Rep_Value (Lo));
658 elsif Lo_Discr then
659 Get_Name_String_And_Append (Chars (Entity (Lo)));
660 end if;
662 if Lo_Encode and Hi_Encode then
663 Add_Str_To_Name_Buffer ("__");
664 end if;
666 if Hi_Con then
667 Add_Uint_To_Buffer (Expr_Rep_Value (Hi));
668 elsif Hi_Discr then
669 Get_Name_String_And_Append (Chars (Entity (Hi)));
670 end if;
671 end if;
672 end;
674 -- For all other cases, the encoded name is the normal type name
676 else
677 Has_Suffix := False;
678 Get_External_Name (E);
679 end if;
681 if Debug_Flag_B and then Has_Suffix then
682 Write_Str ("**** type ");
683 Write_Name (Chars (E));
684 Write_Str (" is encoded as ");
685 Write_Str (Name_Buffer (1 .. Name_Len));
686 Write_Eol;
687 end if;
689 Name_Buffer (Name_Len + 1) := ASCII.NUL;
690 end Get_Encoded_Name;
692 -----------------------
693 -- Get_External_Name --
694 -----------------------
696 procedure Get_External_Name
697 (Entity : Entity_Id;
698 Has_Suffix : Boolean := False;
699 Suffix : String := "")
701 E : Entity_Id := Entity;
702 Kind : Entity_Kind;
704 procedure Get_Qualified_Name_And_Append (Entity : Entity_Id);
705 -- Appends fully qualified name of given entity to Name_Buffer
707 -----------------------------------
708 -- Get_Qualified_Name_And_Append --
709 -----------------------------------
711 procedure Get_Qualified_Name_And_Append (Entity : Entity_Id) is
712 begin
713 -- If the entity is a compilation unit, its scope is Standard,
714 -- there is no outer scope, and the no further qualification
715 -- is required.
717 -- If the front end has already computed a fully qualified name,
718 -- then it is also the case that no further qualification is
719 -- required.
721 if Present (Scope (Scope (Entity)))
722 and then not Has_Fully_Qualified_Name (Entity)
723 then
724 Get_Qualified_Name_And_Append (Scope (Entity));
725 Add_Str_To_Name_Buffer ("__");
726 Get_Name_String_And_Append (Chars (Entity));
727 Append_Homonym_Number (Entity);
729 else
730 Get_Name_String_And_Append (Chars (Entity));
731 end if;
732 end Get_Qualified_Name_And_Append;
734 -- Start of processing for Get_External_Name
736 begin
737 -- If we are not in code generation mode, this procedure may still be
738 -- called from Back_End (more specifically - from gigi for doing type
739 -- representation annotation or some representation-specific checks).
740 -- But in this mode there is no need to mess with external names.
742 -- Furthermore, the call causes difficulties in this case because the
743 -- string representing the homonym number is not correctly reset as a
744 -- part of the call to Output_Homonym_Numbers_Suffix (which is not
745 -- called in gigi).
747 if Operating_Mode /= Generate_Code then
748 return;
749 end if;
751 Reset_Buffers;
753 -- If this is a child unit, we want the child
755 if Nkind (E) = N_Defining_Program_Unit_Name then
756 E := Defining_Identifier (Entity);
757 end if;
759 Kind := Ekind (E);
761 -- Case of interface name being used
763 if (Kind = E_Procedure or else
764 Kind = E_Function or else
765 Kind = E_Constant or else
766 Kind = E_Variable or else
767 Kind = E_Exception)
768 and then Present (Interface_Name (E))
769 and then No (Address_Clause (E))
770 and then not Has_Suffix
771 then
772 Add_String_To_Name_Buffer (Strval (Interface_Name (E)));
774 -- All other cases besides the interface name case
776 else
777 -- If this is a library level subprogram (i.e. a subprogram that is a
778 -- compilation unit other than a subunit), then we prepend _ada_ to
779 -- ensure distinctions required as described in the spec.
781 -- Check explicitly for child units, because those are not flagged
782 -- as Compilation_Units by lib. Should they be ???
784 if Is_Subprogram (E)
785 and then (Is_Compilation_Unit (E) or Is_Child_Unit (E))
786 and then not Has_Suffix
787 then
788 Add_Str_To_Name_Buffer ("_ada_");
789 end if;
791 -- If the entity is a subprogram instance that is not a compilation
792 -- unit, generate the name of the original Ada entity, which is the
793 -- one gdb needs.
795 if Is_Generic_Instance (E)
796 and then Is_Subprogram (E)
797 and then not Is_Compilation_Unit (Scope (E))
798 and then (Ekind (Scope (E)) = E_Package
799 or else
800 Ekind (Scope (E)) = E_Package_Body)
801 and then Present (Related_Instance (Scope (E)))
802 then
803 E := Related_Instance (Scope (E));
804 end if;
806 Get_Qualified_Name_And_Append (E);
807 end if;
809 if Has_Suffix then
810 Add_Str_To_Name_Buffer ("___");
811 Add_Str_To_Name_Buffer (Suffix);
812 end if;
814 Name_Buffer (Name_Len + 1) := ASCII.NUL;
815 end Get_External_Name;
817 --------------------------
818 -- Get_Variant_Encoding --
819 --------------------------
821 procedure Get_Variant_Encoding (V : Node_Id) is
822 Choice : Node_Id;
824 procedure Choice_Val (Typ : Character; Choice : Node_Id);
825 -- Output encoded value for a single choice value. Typ is the key
826 -- character ('S', 'F', or 'T') that precedes the choice value.
828 ----------------
829 -- Choice_Val --
830 ----------------
832 procedure Choice_Val (Typ : Character; Choice : Node_Id) is
833 begin
834 if Nkind (Choice) = N_Integer_Literal then
835 Add_Char_To_Name_Buffer (Typ);
836 Add_Uint_To_Buffer (Intval (Choice));
838 -- Character literal with no entity present (this is the case
839 -- Standard.Character or Standard.Wide_Character as root type)
841 elsif Nkind (Choice) = N_Character_Literal
842 and then No (Entity (Choice))
843 then
844 Add_Char_To_Name_Buffer (Typ);
845 Add_Uint_To_Buffer (Char_Literal_Value (Choice));
847 else
848 declare
849 Ent : constant Entity_Id := Entity (Choice);
851 begin
852 if Ekind (Ent) = E_Enumeration_Literal then
853 Add_Char_To_Name_Buffer (Typ);
854 Add_Uint_To_Buffer (Enumeration_Rep (Ent));
856 else
857 pragma Assert (Ekind (Ent) = E_Constant);
858 Choice_Val (Typ, Constant_Value (Ent));
859 end if;
860 end;
861 end if;
862 end Choice_Val;
864 -- Start of processing for Get_Variant_Encoding
866 begin
867 Name_Len := 0;
869 Choice := First (Discrete_Choices (V));
870 while Present (Choice) loop
871 if Nkind (Choice) = N_Others_Choice then
872 Add_Char_To_Name_Buffer ('O');
874 elsif Nkind (Choice) = N_Range then
875 Choice_Val ('R', Low_Bound (Choice));
876 Choice_Val ('T', High_Bound (Choice));
878 elsif Is_Entity_Name (Choice)
879 and then Is_Type (Entity (Choice))
880 then
881 Choice_Val ('R', Type_Low_Bound (Entity (Choice)));
882 Choice_Val ('T', Type_High_Bound (Entity (Choice)));
884 elsif Nkind (Choice) = N_Subtype_Indication then
885 declare
886 Rang : constant Node_Id :=
887 Range_Expression (Constraint (Choice));
888 begin
889 Choice_Val ('R', Low_Bound (Rang));
890 Choice_Val ('T', High_Bound (Rang));
891 end;
893 else
894 Choice_Val ('S', Choice);
895 end if;
897 Next (Choice);
898 end loop;
900 Name_Buffer (Name_Len + 1) := ASCII.NUL;
902 if Debug_Flag_B then
903 declare
904 VP : constant Node_Id := Parent (V); -- Variant_Part
905 CL : constant Node_Id := Parent (VP); -- Component_List
906 RD : constant Node_Id := Parent (CL); -- Record_Definition
907 FT : constant Node_Id := Parent (RD); -- Full_Type_Declaration
909 begin
910 Write_Str ("**** variant for type ");
911 Write_Name (Chars (Defining_Identifier (FT)));
912 Write_Str (" is encoded as ");
913 Write_Str (Name_Buffer (1 .. Name_Len));
914 Write_Eol;
915 end;
916 end if;
917 end Get_Variant_Encoding;
919 -----------------------------------------
920 -- Build_Subprogram_Instance_Renamings --
921 -----------------------------------------
923 procedure Build_Subprogram_Instance_Renamings
924 (N : Node_Id;
925 Wrapper : Entity_Id)
927 Loc : Source_Ptr;
928 Decl : Node_Id;
929 E : Entity_Id;
931 begin
932 E := First_Entity (Wrapper);
933 while Present (E) loop
934 if Nkind (Parent (E)) = N_Object_Declaration
935 and then Is_Elementary_Type (Etype (E))
936 then
937 Loc := Sloc (Expression (Parent (E)));
938 Decl := Make_Object_Renaming_Declaration (Loc,
939 Defining_Identifier =>
940 Make_Defining_Identifier (Loc, Chars (E)),
941 Subtype_Mark => New_Occurrence_Of (Etype (E), Loc),
942 Name => New_Occurrence_Of (E, Loc));
944 Append (Decl, Declarations (N));
945 Set_Needs_Debug_Info (Defining_Identifier (Decl));
946 end if;
948 Next_Entity (E);
949 end loop;
950 end Build_Subprogram_Instance_Renamings;
952 ------------------------------------
953 -- Get_Secondary_DT_External_Name --
954 ------------------------------------
956 procedure Get_Secondary_DT_External_Name
957 (Typ : Entity_Id;
958 Ancestor_Typ : Entity_Id;
959 Suffix_Index : Int)
961 begin
962 Get_External_Name (Typ);
964 if Ancestor_Typ /= Typ then
965 declare
966 Len : constant Natural := Name_Len;
967 Save_Str : constant String (1 .. Name_Len)
968 := Name_Buffer (1 .. Name_Len);
969 begin
970 Get_External_Name (Ancestor_Typ);
972 -- Append the extended name of the ancestor to the
973 -- extended name of Typ
975 Name_Buffer (Len + 2 .. Len + Name_Len + 1) :=
976 Name_Buffer (1 .. Name_Len);
977 Name_Buffer (1 .. Len) := Save_Str;
978 Name_Buffer (Len + 1) := '_';
979 Name_Len := Len + Name_Len + 1;
980 end;
981 end if;
983 Add_Nat_To_Name_Buffer (Suffix_Index);
984 end Get_Secondary_DT_External_Name;
986 ---------------------------------
987 -- Make_Packed_Array_Impl_Type_Name --
988 ---------------------------------
990 function Make_Packed_Array_Impl_Type_Name
991 (Typ : Entity_Id;
992 Csize : Uint)
993 return Name_Id
995 begin
996 Get_Name_String (Chars (Typ));
997 Add_Str_To_Name_Buffer ("___XP");
998 Add_Uint_To_Buffer (Csize);
999 return Name_Find;
1000 end Make_Packed_Array_Impl_Type_Name;
1002 -----------------------------------
1003 -- Output_Homonym_Numbers_Suffix --
1004 -----------------------------------
1006 procedure Output_Homonym_Numbers_Suffix is
1007 J : Natural;
1009 begin
1010 if Homonym_Len > 0 then
1012 -- Check for all 1's, in which case we do not output
1014 J := 1;
1015 loop
1016 exit when Homonym_Numbers (J) /= '1';
1018 -- If we reached end of string we do not output
1020 if J = Homonym_Len then
1021 Homonym_Len := 0;
1022 return;
1023 end if;
1025 exit when Homonym_Numbers (J + 1) /= '_';
1026 J := J + 2;
1027 end loop;
1029 -- If we exit the loop then suffix must be output
1031 Add_Str_To_Name_Buffer ("__");
1032 Add_Str_To_Name_Buffer (Homonym_Numbers (1 .. Homonym_Len));
1033 Homonym_Len := 0;
1034 end if;
1035 end Output_Homonym_Numbers_Suffix;
1037 ------------------------------
1038 -- Prepend_String_To_Buffer --
1039 ------------------------------
1041 procedure Prepend_String_To_Buffer (S : String) is
1042 N : constant Integer := S'Length;
1043 begin
1044 Name_Buffer (1 + N .. Name_Len + N) := Name_Buffer (1 .. Name_Len);
1045 Name_Buffer (1 .. N) := S;
1046 Name_Len := Name_Len + N;
1047 end Prepend_String_To_Buffer;
1049 ----------------------------
1050 -- Prepend_Uint_To_Buffer --
1051 ----------------------------
1053 procedure Prepend_Uint_To_Buffer (U : Uint) is
1054 begin
1055 if U < 0 then
1056 Prepend_String_To_Buffer ("m");
1057 Prepend_Uint_To_Buffer (-U);
1058 else
1059 UI_Image (U, Decimal);
1060 Prepend_String_To_Buffer (UI_Image_Buffer (1 .. UI_Image_Length));
1061 end if;
1062 end Prepend_Uint_To_Buffer;
1064 ------------------------------
1065 -- Qualify_All_Entity_Names --
1066 ------------------------------
1068 procedure Qualify_All_Entity_Names is
1069 E : Entity_Id;
1070 Ent : Entity_Id;
1072 begin
1073 for J in Name_Qualify_Units.First .. Name_Qualify_Units.Last loop
1074 E := Defining_Entity (Name_Qualify_Units.Table (J));
1075 Reset_Buffers;
1076 Qualify_Entity_Name (E);
1078 -- Normally entities in the qualification list are scopes, but in the
1079 -- case of a library-level package renaming there is an associated
1080 -- variable that encodes the debugger name and that variable is
1081 -- entered in the list since it occurs in the Aux_Decls list of the
1082 -- compilation and doesn't have a normal scope.
1084 if Ekind (E) /= E_Variable then
1085 Ent := First_Entity (E);
1086 while Present (Ent) loop
1087 Reset_Buffers;
1088 Qualify_Entity_Name (Ent);
1089 Next_Entity (Ent);
1091 -- There are odd cases where Last_Entity (E) = E. This happens
1092 -- in the case of renaming of packages. This test avoids
1093 -- getting stuck in such cases.
1095 exit when Ent = E;
1096 end loop;
1097 end if;
1098 end loop;
1099 end Qualify_All_Entity_Names;
1101 -------------------------
1102 -- Qualify_Entity_Name --
1103 -------------------------
1105 procedure Qualify_Entity_Name (Ent : Entity_Id) is
1107 Full_Qualify_Name : String (1 .. Name_Buffer'Length);
1108 Full_Qualify_Len : Natural := 0;
1109 -- Used to accumulate fully qualified name of subprogram
1111 procedure Fully_Qualify_Name (E : Entity_Id);
1112 -- Used to qualify a subprogram or type name, where full
1113 -- qualification up to Standard is always used. Name is set
1114 -- in Full_Qualify_Name with the length in Full_Qualify_Len.
1115 -- Note that this routine does not prepend the _ada_ string
1116 -- required for library subprograms (this is done in the back end).
1118 function Is_BNPE (S : Entity_Id) return Boolean;
1119 -- Determines if S is a BNPE, i.e. Body-Nested Package Entity, which
1120 -- is defined to be a package which is immediately nested within a
1121 -- package body.
1123 function Qualify_Needed (S : Entity_Id) return Boolean;
1124 -- Given a scope, determines if the scope is to be included in the
1125 -- fully qualified name, True if so, False if not. Blocks and loops
1126 -- are excluded from a qualified name.
1128 procedure Set_BNPE_Suffix (E : Entity_Id);
1129 -- Recursive routine to append the BNPE qualification suffix. Works
1130 -- from right to left with E being the current entity in the list.
1131 -- The result does NOT have the trailing n's and trailing b stripped.
1132 -- The caller must do this required stripping.
1134 procedure Set_Entity_Name (E : Entity_Id);
1135 -- Internal recursive routine that does most of the work. This routine
1136 -- leaves the result sitting in Name_Buffer and Name_Len.
1138 BNPE_Suffix_Needed : Boolean := False;
1139 -- Set true if a body-nested package entity suffix is required
1141 Save_Chars : constant Name_Id := Chars (Ent);
1142 -- Save original name
1144 ------------------------
1145 -- Fully_Qualify_Name --
1146 ------------------------
1148 procedure Fully_Qualify_Name (E : Entity_Id) is
1149 Discard : Boolean := False;
1151 begin
1152 -- Ignore empty entry (can happen in error cases)
1154 if No (E) then
1155 return;
1157 -- If this we are qualifying entities local to a generic instance,
1158 -- use the name of the original instantiation, not that of the
1159 -- anonymous subprogram in the wrapper package, so that gdb doesn't
1160 -- have to know about these.
1162 elsif Is_Generic_Instance (E)
1163 and then Is_Subprogram (E)
1164 and then not Comes_From_Source (E)
1165 and then not Is_Compilation_Unit (Scope (E))
1166 then
1167 Fully_Qualify_Name (Related_Instance (Scope (E)));
1168 return;
1169 end if;
1171 -- If we reached fully qualified name, then just copy it
1173 if Has_Fully_Qualified_Name (E) then
1174 Get_Name_String (Chars (E));
1175 Strip_Suffixes (Discard);
1176 Full_Qualify_Name (1 .. Name_Len) := Name_Buffer (1 .. Name_Len);
1177 Full_Qualify_Len := Name_Len;
1178 Set_Has_Fully_Qualified_Name (Ent);
1180 -- Case of non-fully qualified name
1182 else
1183 if Scope (E) = Standard_Standard then
1184 Set_Has_Fully_Qualified_Name (Ent);
1185 else
1186 Fully_Qualify_Name (Scope (E));
1187 Full_Qualify_Name (Full_Qualify_Len + 1) := '_';
1188 Full_Qualify_Name (Full_Qualify_Len + 2) := '_';
1189 Full_Qualify_Len := Full_Qualify_Len + 2;
1190 end if;
1192 if Has_Qualified_Name (E) then
1193 Get_Unqualified_Name_String (Chars (E));
1194 else
1195 Get_Name_String (Chars (E));
1196 end if;
1198 -- Here we do one step of the qualification
1200 Full_Qualify_Name
1201 (Full_Qualify_Len + 1 .. Full_Qualify_Len + Name_Len) :=
1202 Name_Buffer (1 .. Name_Len);
1203 Full_Qualify_Len := Full_Qualify_Len + Name_Len;
1204 Append_Homonym_Number (E);
1205 end if;
1207 if Is_BNPE (E) then
1208 BNPE_Suffix_Needed := True;
1209 end if;
1210 end Fully_Qualify_Name;
1212 -------------
1213 -- Is_BNPE --
1214 -------------
1216 function Is_BNPE (S : Entity_Id) return Boolean is
1217 begin
1218 return Ekind (S) = E_Package and then Is_Package_Body_Entity (S);
1219 end Is_BNPE;
1221 --------------------
1222 -- Qualify_Needed --
1223 --------------------
1225 function Qualify_Needed (S : Entity_Id) return Boolean is
1226 begin
1227 -- If we got all the way to Standard, then we have certainly
1228 -- fully qualified the name, so set the flag appropriately,
1229 -- and then return False, since we are most certainly done.
1231 if S = Standard_Standard then
1232 Set_Has_Fully_Qualified_Name (Ent, True);
1233 return False;
1235 -- Otherwise figure out if further qualification is required
1237 else
1238 return Is_Subprogram (Ent)
1239 or else Ekind (Ent) = E_Subprogram_Body
1240 or else (Ekind (S) /= E_Block
1241 and then Ekind (S) /= E_Loop
1242 and then not Is_Dynamic_Scope (S));
1243 end if;
1244 end Qualify_Needed;
1246 ---------------------
1247 -- Set_BNPE_Suffix --
1248 ---------------------
1250 procedure Set_BNPE_Suffix (E : Entity_Id) is
1251 S : constant Entity_Id := Scope (E);
1253 begin
1254 if Qualify_Needed (S) then
1255 Set_BNPE_Suffix (S);
1257 if Is_BNPE (E) then
1258 Add_Char_To_Name_Buffer ('b');
1259 else
1260 Add_Char_To_Name_Buffer ('n');
1261 end if;
1263 else
1264 Add_Char_To_Name_Buffer ('X');
1265 end if;
1266 end Set_BNPE_Suffix;
1268 ---------------------
1269 -- Set_Entity_Name --
1270 ---------------------
1272 procedure Set_Entity_Name (E : Entity_Id) is
1273 S : constant Entity_Id := Scope (E);
1275 begin
1276 -- If we reach an already qualified name, just take the encoding
1277 -- except that we strip the package body suffixes, since these
1278 -- will be separately put on later.
1280 if Has_Qualified_Name (E) then
1281 Get_Name_String_And_Append (Chars (E));
1282 Strip_Suffixes (BNPE_Suffix_Needed);
1284 -- If the top level name we are adding is itself fully
1285 -- qualified, then that means that the name that we are
1286 -- preparing for the Fully_Qualify_Name call will also
1287 -- generate a fully qualified name.
1289 if Has_Fully_Qualified_Name (E) then
1290 Set_Has_Fully_Qualified_Name (Ent);
1291 end if;
1293 -- Case where upper level name is not encoded yet
1295 else
1296 -- Recurse if further qualification required
1298 if Qualify_Needed (S) then
1299 Set_Entity_Name (S);
1300 Add_Str_To_Name_Buffer ("__");
1301 end if;
1303 -- Otherwise get name and note if it is a BNPE
1305 Get_Name_String_And_Append (Chars (E));
1307 if Is_BNPE (E) then
1308 BNPE_Suffix_Needed := True;
1309 end if;
1311 Append_Homonym_Number (E);
1312 end if;
1313 end Set_Entity_Name;
1315 -- Start of processing for Qualify_Entity_Name
1317 begin
1318 if Has_Qualified_Name (Ent) then
1319 return;
1321 -- In formal verification mode, simply append a suffix for homonyms.
1322 -- We used to qualify entity names as full expansion does, but this was
1323 -- removed as this prevents the verification back-end from using a short
1324 -- name for debugging and user interaction. The verification back-end
1325 -- already takes care of qualifying names when needed. Still mark the
1326 -- name as being qualified, as Qualify_Entity_Name may be called more
1327 -- than once on the same entity.
1329 elsif GNATprove_Mode then
1330 if Has_Homonym (Ent) then
1331 Get_Name_String (Chars (Ent));
1332 Append_Homonym_Number (Ent);
1333 Output_Homonym_Numbers_Suffix;
1334 Set_Chars (Ent, Name_Enter);
1335 end if;
1337 Set_Has_Qualified_Name (Ent);
1338 return;
1340 -- If the entity is a variable encoding the debug name for an object
1341 -- renaming, then the qualified name of the entity associated with the
1342 -- renamed object can now be incorporated in the debug name.
1344 elsif Ekind (Ent) = E_Variable
1345 and then Present (Debug_Renaming_Link (Ent))
1346 then
1347 Name_Len := 0;
1348 Qualify_Entity_Name (Debug_Renaming_Link (Ent));
1349 Get_Name_String (Chars (Ent));
1351 -- Retrieve the now-qualified name of the renamed entity and insert
1352 -- it in the middle of the name, just preceding the suffix encoding
1353 -- describing the renamed object.
1355 declare
1356 Renamed_Id : constant String :=
1357 Get_Name_String (Chars (Debug_Renaming_Link (Ent)));
1358 Insert_Len : constant Integer := Renamed_Id'Length + 1;
1359 Index : Natural := Name_Len - 3;
1361 begin
1362 -- Loop backwards through the name to find the start of the "___"
1363 -- sequence associated with the suffix.
1365 while Index >= Name_Buffer'First
1366 and then (Name_Buffer (Index + 1) /= '_'
1367 or else Name_Buffer (Index + 2) /= '_'
1368 or else Name_Buffer (Index + 3) /= '_')
1369 loop
1370 Index := Index - 1;
1371 end loop;
1373 pragma Assert (Name_Buffer (Index + 1 .. Index + 3) = "___");
1375 -- Insert an underscore separator and the entity name just in
1376 -- front of the suffix.
1378 Name_Buffer (Index + 1 + Insert_Len .. Name_Len + Insert_Len) :=
1379 Name_Buffer (Index + 1 .. Name_Len);
1380 Name_Buffer (Index + 1) := '_';
1381 Name_Buffer (Index + 2 .. Index + Insert_Len) := Renamed_Id;
1382 Name_Len := Name_Len + Insert_Len;
1383 end;
1385 -- Reset the name of the variable to the new name that includes the
1386 -- name of the renamed entity.
1388 Set_Chars (Ent, Name_Enter);
1390 -- If the entity needs qualification by its scope then develop it
1391 -- here, add the variable's name, and again reset the entity name.
1393 if Qualify_Needed (Scope (Ent)) then
1394 Name_Len := 0;
1395 Set_Entity_Name (Scope (Ent));
1396 Add_Str_To_Name_Buffer ("__");
1398 Get_Name_String_And_Append (Chars (Ent));
1400 Set_Chars (Ent, Name_Enter);
1401 end if;
1403 Set_Has_Qualified_Name (Ent);
1404 return;
1406 elsif Is_Subprogram (Ent)
1407 or else Ekind (Ent) = E_Subprogram_Body
1408 or else Is_Type (Ent)
1409 then
1410 Fully_Qualify_Name (Ent);
1411 Name_Len := Full_Qualify_Len;
1412 Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
1414 elsif Qualify_Needed (Scope (Ent)) then
1415 Name_Len := 0;
1416 Set_Entity_Name (Ent);
1418 else
1419 Set_Has_Qualified_Name (Ent);
1420 return;
1421 end if;
1423 -- Fall through with a fully qualified name in Name_Buffer/Name_Len
1425 Output_Homonym_Numbers_Suffix;
1427 -- Add body-nested package suffix if required
1429 if BNPE_Suffix_Needed
1430 and then Ekind (Ent) /= E_Enumeration_Literal
1431 then
1432 Set_BNPE_Suffix (Ent);
1434 -- Strip trailing n's and last trailing b as required. note that
1435 -- we know there is at least one b, or no suffix would be generated.
1437 while Name_Buffer (Name_Len) = 'n' loop
1438 Name_Len := Name_Len - 1;
1439 end loop;
1441 Name_Len := Name_Len - 1;
1442 end if;
1444 Set_Chars (Ent, Name_Enter);
1445 Set_Has_Qualified_Name (Ent);
1447 if Debug_Flag_BB then
1448 Write_Str ("*** ");
1449 Write_Name (Save_Chars);
1450 Write_Str (" qualified as ");
1451 Write_Name (Chars (Ent));
1452 Write_Eol;
1453 end if;
1454 end Qualify_Entity_Name;
1456 --------------------------
1457 -- Qualify_Entity_Names --
1458 --------------------------
1460 procedure Qualify_Entity_Names (N : Node_Id) is
1461 begin
1462 Name_Qualify_Units.Append (N);
1463 end Qualify_Entity_Names;
1465 -------------------
1466 -- Reset_Buffers --
1467 -------------------
1469 procedure Reset_Buffers is
1470 begin
1471 Name_Len := 0;
1472 Homonym_Len := 0;
1473 end Reset_Buffers;
1475 --------------------
1476 -- Strip_Suffixes --
1477 --------------------
1479 procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean) is
1480 SL : Natural;
1482 pragma Warnings (Off, BNPE_Suffix_Found);
1483 -- Since this procedure only ever sets the flag
1485 begin
1486 -- Search for and strip BNPE suffix
1488 for J in reverse 2 .. Name_Len loop
1489 if Name_Buffer (J) = 'X' then
1490 Name_Len := J - 1;
1491 BNPE_Suffix_Found := True;
1492 exit;
1493 end if;
1495 exit when Name_Buffer (J) /= 'b' and then Name_Buffer (J) /= 'n';
1496 end loop;
1498 -- Search for and strip homonym numbers suffix
1500 for J in reverse 2 .. Name_Len - 2 loop
1501 if Name_Buffer (J) = '_'
1502 and then Name_Buffer (J + 1) = '_'
1503 then
1504 if Name_Buffer (J + 2) in '0' .. '9' then
1505 if Homonym_Len > 0 then
1506 Homonym_Len := Homonym_Len + 1;
1507 Homonym_Numbers (Homonym_Len) := '-';
1508 end if;
1510 SL := Name_Len - (J + 1);
1512 Homonym_Numbers (Homonym_Len + 1 .. Homonym_Len + SL) :=
1513 Name_Buffer (J + 2 .. Name_Len);
1514 Name_Len := J - 1;
1515 Homonym_Len := Homonym_Len + SL;
1516 end if;
1518 exit;
1519 end if;
1520 end loop;
1521 end Strip_Suffixes;
1523 end Exp_Dbug;