diff options
author | Bob Duff <duff@adacore.com> | 2024-01-05 10:40:00 -0500 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-07 09:55:52 +0200 |
commit | d4b41cc4b02e365fc749dc90975af4d2360a8fb3 (patch) | |
tree | e49a35a3b7c4b79dc85ac6004ea1137bf45bbf50 /gcc | |
parent | 6fa5f50897c4beba0b55f0c0b76529758a5d24bd (diff) | |
download | gcc-d4b41cc4b02e365fc749dc90975af4d2360a8fb3.zip gcc-d4b41cc4b02e365fc749dc90975af4d2360a8fb3.tar.gz gcc-d4b41cc4b02e365fc749dc90975af4d2360a8fb3.tar.bz2 |
ada: Fix bug in overloaded selected_components in aspect_specifications
This patch fixes a bug where if a selected_component X.Y appears in an
aspect_specification, and there are two or more overloaded Y's in X,
then it can choose the wrong one, leading to subsequent type errors.
It was always picking the last declaration of Y, and leaving Entity
set to that. We now reset Entity (as for the already-existing code
for N_Identifier just below).
Note that Resolve_Aspect_Expressions is called only for
aspect_specifications, and not even all aspect_specifications,
so the bug didn't occur for other names. For example,
Resolve_Aspect_Expressions is not called for aspect_specifications
in the visible part of a library package if there is no private part.
gcc/ada/
* sem_ch13.adb (Resolve_Name): This is called only for names in
aspect_specifications. If the name is an overloaded
selected_component, reset the Entity. Note that this was already
done for N_Identifier in the code just below.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch13.adb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index ed0e61b..c16a771 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -15925,12 +15925,20 @@ package body Sem_Ch13 is and then Chars (Prefix (N)) /= Chars (E) then Find_Selected_Component (N); + + -- Reset the Entity if N is overloaded since the entity might + -- not be the correct one; allow later resolution to set it + -- properly. + + if Is_Overloaded (N) then + Set_Entity (N, Empty); + end if; end if; return Skip; - -- Resolve identifiers that are not selectors in parameter - -- associations (these are never resolved by visibility). + -- Resolve identifiers, but not selectors in parameter associations; + -- the selectors are never resolved by visibility. elsif Nkind (N) = N_Identifier and then Chars (N) /= Chars (E) @@ -15939,8 +15947,7 @@ package body Sem_Ch13 is then Find_Direct_Name (N); - -- Reset the Entity if N is overloaded since the entity may not - -- be the correct one. + -- Reset the Entity as above for selected_components if Is_Overloaded (N) then Set_Entity (N, Empty); |