aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-01-29 11:45:36 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-07 05:29:02 -0400
commitbf62c9012ce7edbc55a62a4ef34a988209ff81a2 (patch)
tree8232f854748f341d8c319b3f924765bc78584318 /gcc
parentbfdc95943e46532617c70eed00f5dff5a2238dcd (diff)
downloadgcc-bf62c9012ce7edbc55a62a4ef34a988209ff81a2.zip
gcc-bf62c9012ce7edbc55a62a4ef34a988209ff81a2.tar.gz
gcc-bf62c9012ce7edbc55a62a4ef34a988209ff81a2.tar.bz2
[Ada] Cleanup code for flagging object references in interfering contexts
gcc/ada/ * sem_res.adb (Flag_Object): Replace chained IF with a CASE; remove repeated calls to Entity; do not traverse into N_Identifier and N_Expanded_Name, because only need to examine their Entity field anyway.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_res.adb34
1 files changed, 20 insertions, 14 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index d2819e4..fc89a31 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -3748,24 +3748,30 @@ package body Sem_Res is
Id : Entity_Id;
begin
- -- Do not consider nested function calls because they have already
- -- been processed during their own resolution.
+ case Nkind (N) is
+ -- Do not consider nested function calls because they have
+ -- already been processed during their own resolution.
- if Nkind (N) = N_Function_Call then
- return Skip;
+ when N_Function_Call =>
+ return Skip;
- elsif Is_Entity_Name (N) and then Present (Entity (N)) then
- Id := Entity (N);
+ when N_Identifier | N_Expanded_Name =>
+ Id := Entity (N);
+
+ if Present (Id)
+ and then Is_Object (Id)
+ and then Is_Effectively_Volatile_For_Reading (Id)
+ then
+ Error_Msg_N
+ ("volatile object cannot appear in this context"
+ & " (SPARK RM 7.1.3(10))", N);
+ end if;
- if Is_Object (Id)
- and then Is_Effectively_Volatile_For_Reading (Id)
- then
- Error_Msg_N
- ("volatile object cannot appear in this context (SPARK "
- & "RM 7.1.3(10))", N);
return Skip;
- end if;
- end if;
+
+ when others =>
+ null;
+ end case;
return OK;
end Flag_Object;