aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-02-23 19:13:36 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-05-23 09:59:06 +0200
commitad16b816d56a2b49adcc9662275a14bf9e4cf6e9 (patch)
treec930d4b9b9df1b6718abd691c0dc02a516d5a168 /gcc/ada/sem_res.adb
parent9826f1e019f6abc5f4960dcfd8f7fcf83dc820dc (diff)
downloadgcc-ad16b816d56a2b49adcc9662275a14bf9e4cf6e9.zip
gcc-ad16b816d56a2b49adcc9662275a14bf9e4cf6e9.tar.gz
gcc-ad16b816d56a2b49adcc9662275a14bf9e4cf6e9.tar.bz2
ada: Fix resolution of mod operator of System.Storage_Elements
This operator is special because the left operand is of Address type while the right operand and the result are of Storage_Offset type (but we raise Constraint_Error if the right operand is not positive) and it needs to be resolved to the type of the left operand to implement the correct semantics. gcc/ada/ * exp_ch4.adb (Expand_N_Op_Mod): Adjust the detection of the special operator of System.Storage_Elements. Do not rewrite it into a rem. * sem_res.adb (Resolve_Intrinsic_Operator): Use the base type of the left operand for the special mod operator of System.Storage_Elements
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb23
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index a99bed0..f1d9a97 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -9710,10 +9710,19 @@ package body Sem_Res is
--------------------------------
procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id) is
- Btyp : constant Entity_Id := Implementation_Base_Type (Typ);
- Op : Entity_Id;
- Arg1 : Node_Id;
- Arg2 : Node_Id;
+ Is_Stoele_Mod : constant Boolean :=
+ Nkind (N) = N_Op_Mod
+ and then Is_RTE (First_Subtype (Typ), RE_Storage_Offset)
+ and then Is_RTE (Etype (Left_Opnd (N)), RE_Address);
+ -- True if this is the special mod operator of System.Storage_Elements,
+ -- which needs to be resolved to the type of the left operand in order
+ -- to implement the correct semantics.
+
+ Btyp : constant Entity_Id :=
+ (if Is_Stoele_Mod
+ then Implementation_Base_Type (Etype (Left_Opnd (N)))
+ else Implementation_Base_Type (Typ));
+ -- The base type to be used for the operator
function Convert_Operand (Opnd : Node_Id) return Node_Id;
-- If the operand is a literal, it cannot be the expression in a
@@ -9742,6 +9751,12 @@ package body Sem_Res is
return Res;
end Convert_Operand;
+ -- Local variables
+
+ Arg1 : Node_Id;
+ Arg2 : Node_Id;
+ Op : Entity_Id;
+
-- Start of processing for Resolve_Intrinsic_Operator
begin