aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-01-14 00:05:54 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-10 08:19:23 +0000
commit7f8053225de072fed9c4822e589c853a6f5e47c4 (patch)
tree3cca2df6a508114bb16be38e971920fb4d707482 /gcc/ada/sem_res.adb
parent6798cad793d9581936f2de76c85a22a5449d7358 (diff)
downloadgcc-7f8053225de072fed9c4822e589c853a6f5e47c4.zip
gcc-7f8053225de072fed9c4822e589c853a6f5e47c4.tar.gz
gcc-7f8053225de072fed9c4822e589c853a6f5e47c4.tar.bz2
[Ada] Fix hiding of user-defined operator that is not a homograph
This adds a missing test for the presence of a homograph when applying the RM 8.4(10) clause about the visibility of operators, and removes resolution code made obsolete by the change. There is also a fixlet for a previously undetected ambiguity in the runtime. gcc/ada/ * sem_res.adb (Resolve_Eqyality_Op): Remove obsolete code. (Resolve_Op_Not): Likewise. * sem_type.adb (Disambiguate): Add missing test for RM 8.4(10). * libgnat/s-dwalin.adb (Enable_Cache): Fix ambiguity. (Symbolic_Address): Likewise. gcc/testsuite/ * gnat.dg/equal7.adb: Add expected error messages (code is now illegal).
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb86
1 files changed, 2 insertions, 84 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 734e457..26da4ff 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8962,55 +8962,6 @@ package body Sem_Res is
Error_Msg_N ("?q?equality should be parenthesized here!", N);
end if;
- -- If the equality is overloaded and the operands have resolved
- -- properly, set the proper equality operator on the node. The
- -- current setting is the first one found during analysis, which
- -- is not necessarily the one to which the node has resolved.
-
- if Is_Overloaded (N) then
- declare
- I : Interp_Index;
- It : Interp;
-
- begin
- Get_First_Interp (N, I, It);
-
- -- If the equality is user-defined, the type of the operands
- -- matches that of the formals. For a predefined operator,
- -- it is the scope that matters, given that the predefined
- -- equality has Any_Type formals. In either case the result
- -- type (most often Boolean) must match the context. The scope
- -- is either that of the type, if there is a generated equality
- -- (when there is an equality for the component type), or else
- -- Standard otherwise.
-
- while Present (It.Typ) loop
- if Etype (It.Nam) = Typ
- and then
- (Etype (First_Entity (It.Nam)) = Etype (L)
- or else Scope (It.Nam) = Standard_Standard
- or else Scope (It.Nam) = Scope (T))
- then
- Set_Entity (N, It.Nam);
-
- Set_Is_Overloaded (N, False);
- exit;
- end if;
-
- Get_Next_Interp (I, It);
- end loop;
-
- -- If expansion is active and this is an inherited operation,
- -- replace it with its ancestor. This must not be done during
- -- preanalysis because the type may not be frozen yet, as when
- -- the context is a precondition or postcondition.
-
- if Present (Alias (Entity (N))) and then Expander_Active then
- Set_Entity (N, Alias (Entity (N)));
- end if;
- end;
- end if;
-
Check_Unset_Reference (L);
Check_Unset_Reference (R);
Generate_Operator_Reference (N, T);
@@ -10594,42 +10545,9 @@ package body Sem_Res is
end if;
-- Complete resolution and evaluation of NOT
- -- If argument is an equality and expected type is boolean, that
- -- expected type has no effect on resolution, and there are
- -- special rules for resolution of Eq, Neq in the presence of
- -- overloaded operands, so we directly call its resolution routines.
-
- declare
- Opnd : constant Node_Id := Right_Opnd (N);
- Op_Id : Entity_Id;
-
- begin
- if B_Typ = Standard_Boolean
- and then Nkind (Opnd) in N_Op_Eq | N_Op_Ne
- and then Is_Overloaded (Opnd)
- then
- Resolve_Equality_Op (Opnd, B_Typ);
- Op_Id := Entity (Opnd);
-
- if Ekind (Op_Id) = E_Function
- and then not Is_Intrinsic_Subprogram (Op_Id)
- then
- Rewrite_Operator_As_Call (Opnd, Op_Id);
- end if;
-
- if not Inside_A_Generic or else Is_Entity_Name (Opnd) then
- Freeze_Expression (Opnd);
- end if;
-
- Expand (Opnd);
-
- else
- Resolve (Opnd, B_Typ);
- end if;
-
- Check_Unset_Reference (Opnd);
- end;
+ Resolve (Right_Opnd (N), B_Typ);
+ Check_Unset_Reference (Right_Opnd (N));
Set_Etype (N, B_Typ);
Generate_Operator_Reference (N, B_Typ);
Eval_Op_Not (N);