aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-02-28 14:26:02 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-09 04:09:05 -0400
commit4e510a0a2baa41a22a7acef872cd309ea78ef737 (patch)
treea0ba3a8fec8810c2f6bfc19409db228f37214dd5 /gcc
parentc4609e75ef41546d7b7373cc3d6d0ba9fa15dfcd (diff)
downloadgcc-4e510a0a2baa41a22a7acef872cd309ea78ef737.zip
gcc-4e510a0a2baa41a22a7acef872cd309ea78ef737.tar.gz
gcc-4e510a0a2baa41a22a7acef872cd309ea78ef737.tar.bz2
[Ada] Ada2020 AI12-0282: Shared variable control aspects in generics
2020-06-09 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch12.adb (Check_Shared_Variable_Control_Aspects): Require exact match between formal and actual for aspects Atomic and Volatile only for formal derived types.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch12.adb23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 106226f..caf423a 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -12394,19 +12394,38 @@ package body Sem_Ch12 is
-- Ada 2020: Verify that shared variable control aspects (RM C.6)
-- that may be specified for the formal are obeyed by the actual.
+ -- If the fornal is a derived type the aspect specifications must match.
+ -- NOTE: AI12-0282 implies that matching of aspects is required between
+ -- formal and actual in all cases, but this is too restrictive.
+ -- In particular it violates a language design rule: a limited private
+ -- indefinite formal can be matched by any actual. The current code
+ -- reflects an older and more permissve version of RM C.6 (12/5).
procedure Check_Shared_Variable_Control_Aspects is
begin
if Ada_Version >= Ada_2020 then
- if Is_Atomic (A_Gen_T) /= Is_Atomic (Act_T) then
+ if Is_Atomic (A_Gen_T) and then not Is_Atomic (Act_T) then
+ Error_Msg_NE
+ ("actual for& must have Atomic aspect", Actual, A_Gen_T);
+
+ elsif Is_Derived_Type (A_Gen_T)
+ and then Is_Atomic (A_Gen_T) /= Is_Atomic (Act_T)
+ then
Error_Msg_NE
("actual for& has different Atomic aspect", Actual, A_Gen_T);
end if;
- if Is_Volatile (A_Gen_T) /= Is_Volatile (Act_T) then
+ if Is_Volatile (A_Gen_T) and then not Is_Volatile (Act_T) then
Error_Msg_NE
("actual for& has different Volatile aspect",
Actual, A_Gen_T);
+
+ elsif Is_Derived_Type (A_Gen_T)
+ and then Is_Volatile (A_Gen_T) /= Is_Volatile (Act_T)
+ then
+ Error_Msg_NE
+ ("actual for& has different Volatile aspect",
+ Actual, A_Gen_T);
end if;
-- We assume that an array type whose atomic component type