aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-10-15 13:00:10 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-11-07 10:15:04 +0100
commit003fe1356b3963c678a0f1be40cd764264fa60ab (patch)
treecfe59300a5a1b0072ee6836958a0cebcb7191689 /gcc/ada/sem_res.adb
parent63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc (diff)
downloadgcc-003fe1356b3963c678a0f1be40cd764264fa60ab.zip
gcc-003fe1356b3963c678a0f1be40cd764264fa60ab.tar.gz
gcc-003fe1356b3963c678a0f1be40cd764264fa60ab.tar.bz2
ada: Fix incorrect resolution of overloaded function call in instance
The problem occurs when the function call is the operand of an equality operator, the type used to do the comparison is declared outside of the generic construct but visible inside it, and this generic construct also declares two functions with the same profile except for the result type, one result type being the aforementioned type, the other being derived from this type but not visible inside the generic construct. When the second operand is either a literal or also overloaded, the call may be resolved to the second function instead of the first in instances. gcc/ada/ * gen_il-fields.ads (Opt_Field_Enum): Add Compare_Type. * gen_il-gen-gen_nodes.adb (N_Op_Eq): Likewise. (N_Op_Ge): Likewise. (N_Op_Gt): Likewise. (N_Op_Le): Likewise. (N_Op_Lt): Likewise. (N_Op_Ne): Likewise. * sinfo.ads (Compare_Type): Document new field. * sem_ch4.adb (Analyze_Comparison_Equality_Op): If the entity is already present, set the Compare_Type on overloaded operands if it is present on the node. * sem_ch12.adb (Check_Private_View): Look into the Compare_Type instead of the Etype for comparison operators. (Copy_Generic_Node): Remove obsolete code for comparison operators. (Save_Global_References.Save_References): Do not walk into the descendants of N_Implicit_Label_Declaration nodes. (Save_Global_References.Set_Global_Type): Look into the Compare_Type instead of the Etype for comparison operators. * sem_res.adb (Resolve_Comparison_Op): Set Compare_Type. (Resolve_Equality_Op): Likewise.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index fa1365c..42f7c10 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -7611,6 +7611,7 @@ package body Sem_Res is
Resolve (L, T);
Resolve (R, T);
+ Set_Compare_Type (N, T);
Check_Unset_Reference (L);
Check_Unset_Reference (R);
Generate_Operator_Reference (N, T);
@@ -9119,6 +9120,7 @@ package body Sem_Res is
Resolve (L, T);
Resolve (R, T);
+ Set_Compare_Type (N, T);
-- AI12-0413: user-defined primitive equality of an untagged record
-- type hides the predefined equality operator, including within a