aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-07-09 08:26:37 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-19 05:53:40 -0400
commitdc55492d63569da6b0885d9b3a7ee2cff61b9302 (patch)
tree4c0365640ab953b4f3f870c2dae48716f0394135 /gcc
parent5f396397f6ed41e58f5708a645dbbb218421d4e3 (diff)
downloadgcc-dc55492d63569da6b0885d9b3a7ee2cff61b9302.zip
gcc-dc55492d63569da6b0885d9b3a7ee2cff61b9302.tar.gz
gcc-dc55492d63569da6b0885d9b3a7ee2cff61b9302.tar.bz2
[Ada] AI12-0352: Early derivation and equality of untagged types
gcc/ada/ * sem_ch6.adb (Check_Untagged_Equality): Check for AI12-0352.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch6.adb21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 8447411..f314f1b 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -9118,10 +9118,27 @@ package body Sem_Ch6 is
("equality operator appears too late (Ada 2012)?y?", Eq_Op);
end if;
- -- No error detected
+ -- Finally check for AI12-0352: declaration of a user-defined primitive
+ -- equality operation for a record type T is illegal if it occurs after
+ -- a type has been derived from T.
else
- return;
+ Obj_Decl := Next (Parent (Typ));
+
+ while Present (Obj_Decl) and then Obj_Decl /= Decl loop
+ if Nkind (Obj_Decl) = N_Full_Type_Declaration
+ and then Etype (Defining_Identifier (Obj_Decl)) = Typ
+ then
+ Error_Msg_N
+ ("equality operator cannot appear after derivation", Eq_Op);
+ Error_Msg_NE
+ ("an equality operator for& cannot be declared after "
+ & "this point??",
+ Obj_Decl, Typ);
+ end if;
+
+ Next (Obj_Decl);
+ end loop;
end if;
end Check_Untagged_Equality;