aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch6.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r--gcc/ada/sem_ch6.adb25
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index dbb4bb8..1df3737 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -9527,14 +9527,14 @@ package body Sem_Ch6 is
Default := Expression (Param_Spec);
if Is_Scalar_Type (Etype (Default)) then
- if Nkind
- (Parameter_Type (Param_Spec)) /= N_Access_Definition
+ if Nkind (Parameter_Type (Param_Spec)) /=
+ N_Access_Definition
then
Formal_Type := Entity (Parameter_Type (Param_Spec));
-
else
- Formal_Type := Access_Definition
- (Related_Nod, Parameter_Type (Param_Spec));
+ Formal_Type :=
+ Access_Definition
+ (Related_Nod, Parameter_Type (Param_Spec));
end if;
Apply_Scalar_Range_Check (Default, Formal_Type);
@@ -9556,6 +9556,21 @@ package body Sem_Ch6 is
if Is_Aliased (Formal) then
Set_Mechanism (Formal, By_Reference);
+
+ -- Warn if user asked this to be passed by copy
+
+ if Convention (Formal_Type) = Convention_Ada_Pass_By_Copy then
+ Error_Msg_N
+ ("?cannot pass aliased parameter & by copy", Formal);
+ end if;
+
+ -- Force mechanism if type has Convention Ada_Pass_By_Ref/Copy
+
+ elsif Convention (Formal_Type) = Convention_Ada_Pass_By_Copy then
+ Set_Mechanism (Formal, By_Copy);
+
+ elsif Convention (Formal_Type) = Convention_Ada_Pass_By_Reference then
+ Set_Mechanism (Formal, By_Reference);
end if;
Next (Param_Spec);