diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2022-07-03 18:41:56 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-13 10:01:15 +0000 |
commit | 05e91ac1f89dc0b4757ac7e8ffaacd65bcdc4794 (patch) | |
tree | 1534578479d1206ee12400292edf6461383b417c /gcc/ada/sem_res.adb | |
parent | b872d3fe67b54fef84ccafc7d39f1017a68332c2 (diff) | |
download | gcc-05e91ac1f89dc0b4757ac7e8ffaacd65bcdc4794.zip gcc-05e91ac1f89dc0b4757ac7e8ffaacd65bcdc4794.tar.gz gcc-05e91ac1f89dc0b4757ac7e8ffaacd65bcdc4794.tar.bz2 |
[Ada] Plug legality loophole for equality operator of untagged record types
In Ada 2012, the RM 4.5.2(9.8) clause prevents an equality operator for an
untagged record type from being declared after the type is frozen. While
the clause is implemented in GNAT, the implementation has a loophole which
lets subprogram bodies that are not the completion of a declaration pass
the check without being flagged.
gcc/ada/
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Set Acts_As_Spec
earlier if the body is not the completion of a declaration.
(Check_Untagged_Equality): Deal with subprogram bodies that are
not the completion of a declaration and make sure that they are
not flagged when they cause the freezing of the type themselves.
Give a warning on the freezing point of the type in more cases.
* sem_res.adb (Resolve_Equality_Op): Revert latest change.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1412d94..44fc955 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8967,14 +8967,7 @@ package body Sem_Res is then Eq := Get_User_Defined_Equality (T); - -- We need to make sure that the instance is not within the - -- same declarative region as the type, or else that it lies - -- after the declaration of the user-defined "=" operator. - - if Present (Eq) - and then (not In_Same_Extended_Unit (Eq, N) - or else Earlier_In_Extended_Unit (Eq, N)) - then + if Present (Eq) then if Is_Abstract_Subprogram (Eq) then Nondispatching_Call_To_Abstract_Operation (N, Eq); else |