diff options
author | Bob Duff <duff@adacore.com> | 2024-01-25 08:38:08 -0500 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-13 10:03:30 +0200 |
commit | 0533acf60438aec7858b18b0b52706ca6f1b3564 (patch) | |
tree | 5989c80180fadafdf4710dbcce986d10bc4da32c /gcc/ada/sem_util.ads | |
parent | c52bfe61b2f103d1be6065242f145ec49d13cce7 (diff) | |
download | gcc-0533acf60438aec7858b18b0b52706ca6f1b3564.zip gcc-0533acf60438aec7858b18b0b52706ca6f1b3564.tar.gz gcc-0533acf60438aec7858b18b0b52706ca6f1b3564.tar.bz2 |
ada: Rewrite Append_Entity_Name; skip irrelevant names
This patch rewrites Append_Entity_Name, both for maintainability and to
improve user messages. The main issue was that the recursion stopped
when the enclosing scope is the wrapper created in case of
postconditions with 'Old. This caused different results depending
on the enabling/disabling of assertions. Instead of stopping,
we now skip things that the user shouldn't see; there is useful
information in more-outer scope names.
Simplify the code. We had a nested procedure, which called itself
recursively, and also was mutually recursive with the outer procedure.
Avoid testing Is_Internal_Name of the Chars, which seems too fragile.
'R' is used for subprogram instances, but for example "SR" is used for
TSS_Stream_Read, so removing 'R' works only by accident.
Instead, base the test for subprogram instances on normal Einfo
queries.
The new version of Append_Entity_Name produces different (and better)
results in many cases, but this fact is not apparent in most test cases,
because they don't raise unhandled exceptions or do other things that
involve printing the entity name.
The comment:
-- Otherwise nothing to output (happens in unnamed block statements)
is removed; there are many cases other than block statements that
reached that part of the code.
gcc/ada/
* sem_util.ads (Append_Entity_Name): Fix comment to reflect new
semantics. The comment said, "The qualification stops at an
enclosing scope has no source name (block or loop)." There seems
to be no reason for stopping; instead, we should SKIP things with
no source name. And the "loop" part was wrong.
* sem_util.adb (Append_Entity_Name): Do not stop the recursion;
skip to next-outer scope instead. Misc cleanup/simplification.
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r-- | gcc/ada/sem_util.ads | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 83e824b..a5eb1ec 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -110,10 +110,9 @@ package Sem_Util is -- because those are the only dynamic cases. procedure Append_Entity_Name (Buf : in out Bounded_String; E : Entity_Id); - -- Recursive procedure to construct string for qualified name of enclosing - -- program unit. The qualification stops at an enclosing scope has no - -- source name (block or loop). If entity is a subprogram instance, skip - -- enclosing wrapper package. The name is appended to Buf. + -- Construct a user-readable expanded name for E, for printing in messages, + -- such as run-time errors for unhandled exceptions. Names created for + -- internal use are not included. The name is appended to Buf. procedure Append_Inherited_Subprogram (S : Entity_Id); -- If the parent of the operation is declared in the visible part of |