diff options
author | Ghjuvan Lacambre <lacambre@adacore.com> | 2020-09-01 10:57:39 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-23 04:24:52 -0400 |
commit | 6cc203bf2a78be88d60fd250617e0c652451b8aa (patch) | |
tree | 445b2cdae96e5fafc7e55fd8874349cbb6574f63 | |
parent | 4e40d14622b5ce8771498cdb9cf8cbfe6b71d883 (diff) | |
download | gcc-6cc203bf2a78be88d60fd250617e0c652451b8aa.zip gcc-6cc203bf2a78be88d60fd250617e0c652451b8aa.tar.gz gcc-6cc203bf2a78be88d60fd250617e0c652451b8aa.tar.bz2 |
[Ada] CUDA: fix CUDA_Execute not working with aggregates
gcc/ada/
* exp_prag.adb (Etype_Or_Dim3): New function.
(Expand_Pragma_Cuda_Execute): Use Etype_Or_Dim3 for temporary
decls.
-rw-r--r-- | gcc/ada/exp_prag.adb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb index 4edbd64..14ccac9 100644 --- a/gcc/ada/exp_prag.adb +++ b/gcc/ada/exp_prag.adb @@ -752,6 +752,11 @@ package body Exp_Prag is -- type of which is Integer, the value of which is Init_Val if present -- and 0 otherwise. + function Etype_Or_Dim3 (N : Node_Id) return Node_Id; + -- If N is an aggregate whose type is unknown, return a new occurrence + -- of the public Dim3 type. Otherwise, return a new occurrence of N's + -- type. + function Get_Nth_Arg_Type (Subprogram : Entity_Id; N : Positive) return Entity_Id; @@ -988,6 +993,20 @@ package body Exp_Prag is Default_Val => Make_Null (Loc)); end Build_Stream_Declaration; + ------------------------ + -- Etype_Or_Dim3 -- + ------------------------ + + function Etype_Or_Dim3 (N : Node_Id) return Node_Id is + begin + if Nkind (N) = N_Aggregate and then Is_Composite_Type (Etype (N)) + then + return New_Occurrence_Of (RTE (RE_Dim3), Sloc (N)); + end if; + + return New_Occurrence_Of (Etype (N), Loc); + end Etype_Or_Dim3; + ---------------------- -- Get_Nth_Arg_Type -- ---------------------- @@ -1054,13 +1073,11 @@ package body Exp_Prag is -- referenced multiple times but could have side effects. Temp_Grid_Decl : constant Node_Id := Make_Object_Declaration (Loc, Defining_Identifier => Temp_Grid, - Object_Definition => - New_Occurrence_Of (Etype (Grid_Dimensions), Loc), + Object_Definition => Etype_Or_Dim3 (Grid_Dimensions), Expression => Grid_Dimensions); Temp_Block_Decl : constant Node_Id := Make_Object_Declaration (Loc, Defining_Identifier => Temp_Block, - Object_Definition => - New_Occurrence_Of (Etype (Block_Dimensions), Loc), + Object_Definition => Etype_Or_Dim3 (Block_Dimensions), Expression => Block_Dimensions); -- List holding the entities of the copies of Procedure_Call's |