[Ada] Fix thinko in Acc_Loop_to_gnu
diff mbox series

Message ID 20190819083858.GA33326@adacore.com
State New
Headers show
Series
  • [Ada] Fix thinko in Acc_Loop_to_gnu
Related show

Commit Message

Pierre-Marie de Rodat Aug. 19, 2019, 8:38 a.m. UTC
This fixes a glitch introduced during the initial OpenACC work import
process, causing crashes on any Acc_Parallel + Acc_Loop combination.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-08-19  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

	* gcc-interface/trans.c (Acc_Loop_to_gnu): Return the openacc
	BIND_EXPR node we have constructed on purpose.  Remove unused
	variable.

gcc/testsuite/

	* gnat.dg/openacc1.adb: New testcase.

Patch
diff mbox series

--- gcc/ada/gcc-interface/trans.c
+++ gcc/ada/gcc-interface/trans.c
@@ -3398,9 +3398,6 @@  independent_iterations_p (tree stmt_list)
 static tree
 Acc_Loop_to_gnu (Node_Id gnat_loop)
 {
-  const struct loop_info_d * const gnu_loop_info = gnu_loop_stack->last ();
-  tree gnu_loop_stmt = gnu_loop_info->stmt;
-
   tree acc_loop = make_node (OACC_LOOP);
   tree acc_bind_expr = NULL_TREE;
   Node_Id cur_loop = gnat_loop;
@@ -3517,7 +3514,7 @@  Acc_Loop_to_gnu (Node_Id gnat_loop)
 
   BIND_EXPR_BODY (acc_bind_expr) = acc_loop;
 
-  return gnu_loop_stmt;
+  return acc_bind_expr;
 }
 
 /* Helper for Loop_Statement_to_gnu, to translate the body of a loop not

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/openacc1.adb
@@ -0,0 +1,12 @@ 
+--  { dg-do compile }
+
+procedure OpenAcc1 is
+   type Integer_Array is array (1 .. 32) of Integer;
+   Data : Integer_Array;
+begin
+   for i in Data'Range loop
+      pragma Acc_Parallel;
+      pragma Acc_Loop(Worker);
+      Data (i) := i;
+   end loop;
+end;