]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Incorrect emptying of CUDA global subprograms
authorJustin Squirek <squirek@adacore.com>
Fri, 10 Jun 2022 12:16:17 +0000 (12:16 +0000)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 6 Jul 2022 13:29:47 +0000 (13:29 +0000)
This patch corrects an error in the compiler whereby no
Corresponding_Spec was set for emptied CUDA global subprograms - leading
to a malformed tree.

gcc/ada/

* gnat_cuda.adb (Empty_CUDA_Global_Subprogram): Set
Specification and Corresponding_Spec to match the original
Kernel_Body.

gcc/ada/gnat_cuda.adb

index 44394b731630a17e013e016fb44c92262725b2cf..3391263afed6e454db2e95998d6e77a819887f65 100644 (file)
@@ -165,17 +165,20 @@ package body GNAT_CUDA is
 
       Kernel_Elm := First_Elmt (Kernels);
       while Present (Kernel_Elm) loop
-         Kernel := Node (Kernel_Elm);
+         Kernel      := Node (Kernel_Elm);
          Kernel_Body := Subprogram_Body (Kernel);
-         Loc := Sloc (Kernel_Body);
+         Loc         := Sloc (Kernel_Body);
 
          Null_Body := Make_Subprogram_Body (Loc,
-           Specification              => Subprogram_Specification (Kernel),
+           Specification              => Specification (Kernel_Body),
            Declarations               => New_List,
            Handled_Statement_Sequence =>
              Make_Handled_Sequence_Of_Statements (Loc,
                Statements => New_List (Make_Null_Statement (Loc))));
 
+         Set_Corresponding_Spec (Null_Body,
+           Corresponding_Spec (Kernel_Body));
+
          Rewrite (Kernel_Body, Null_Body);
 
          Next_Elmt (Kernel_Elm);