aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2025-02-07 12:29:46 -0800
committerEric Botcazou <ebotcazou@adacore.com>2025-06-06 16:44:45 +0200
commit1189522245be51d435fcc6d205e690f086f12e46 (patch)
treea10e0e26a49abb4b1f828d3a514df80246eec373 /gcc
parent855fe3625493e3888df5da12aba945c243ec6650 (diff)
downloadgcc-1189522245be51d435fcc6d205e690f086f12e46.zip
gcc-1189522245be51d435fcc6d205e690f086f12e46.tar.gz
gcc-1189522245be51d435fcc6d205e690f086f12e46.tar.bz2
ada: Incorrect unresolved operator name in an instantiation
In some cases, a generic containing a use of a unary operator successfully compiles but the compiler incorrectly rejects the corresponding use in an instantiation. gcc/ada/ChangeLog: * sem_ch4.adb (Find_Unary_Types): Because we reanalyze names in an instance, we sometimes have to take steps to filter out extraneous name resolution candidates that happen to be visible at the point of the instance declaration. Remove some code that appears to have been written with this in mind. This is done for two reasons. First, the code sometimes doesn't work (possibly because the In_Instance test is not specific enough - it probably should be testing to see whether we are in an instance of the particular generic in which the result of calling Corresponding_Generic_Type was declared) and causes correct code to be rejected. Second, the code seems to no longer be necessary (possibly because of subsequent fixes in this area which are not specific to unary operators).
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch4.adb25
1 files changed, 2 insertions, 23 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 4069839..50b3eee 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -7642,35 +7642,14 @@ package body Sem_Ch4 is
begin
if not Is_Overloaded (R) then
if Is_Numeric_Type (Etype (R)) then
-
- -- In an instance a generic actual may be a numeric type even if
- -- the formal in the generic unit was not. In that case, the
- -- predefined operator was not a possible interpretation in the
- -- generic, and cannot be one in the instance, unless the operator
- -- is an actual of an instance.
-
- if In_Instance
- and then
- not Is_Numeric_Type (Corresponding_Generic_Type (Etype (R)))
- then
- null;
- else
- Add_One_Interp (N, Op_Id, Base_Type (Etype (R)));
- end if;
+ Add_One_Interp (N, Op_Id, Base_Type (Etype (R)));
end if;
else
Get_First_Interp (R, Index, It);
while Present (It.Typ) loop
if Is_Numeric_Type (It.Typ) then
- if In_Instance
- and then
- not Is_Numeric_Type
- (Corresponding_Generic_Type (Etype (It.Typ)))
- then
- null;
-
- elsif Is_Effectively_Visible_Operator (N, Base_Type (It.Typ))
+ if Is_Effectively_Visible_Operator (N, Base_Type (It.Typ))
then
Add_One_Interp (N, Op_Id, Base_Type (It.Typ));
end if;