]> gcc.gnu.org Git - gcc.git/commit
ada: Rewrite Append_Entity_Name; skip irrelevant names
authorBob Duff <duff@adacore.com>
Thu, 25 Jan 2024 13:38:08 +0000 (08:38 -0500)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 13 May 2024 08:03:30 +0000 (10:03 +0200)
commit0533acf60438aec7858b18b0b52706ca6f1b3564
tree5989c80180fadafdf4710dbcce986d10bc4da32c
parentc52bfe61b2f103d1be6065242f145ec49d13cce7
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.
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
This page took 0.057048 seconds and 5 git commands to generate.