This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp] Fix fortran reduction expansion


Hi!

As shown by the attached testcase, attr.flavor is important even on the
fake symbols which already have backend_decl set and shouldn't be
FL_PROCEDURE if backend_decl isn't current_function_decl.

Ok for trunk/4.2?

2006-10-29  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/29629
	* trans-openmp.c (gfc_trans_omp_array_reduction): Set attr.flavor
	of init_val_sym and outer_sym to FL_VARIABLE.

	* testsuite/libgomp.fortran/pr29629.f90: New test.

--- gcc/fortran/trans-openmp.c.jj	2006-10-22 10:39:36.000000000 +0200
+++ gcc/fortran/trans-openmp.c	2006-10-29 08:48:37.000000000 +0100
@@ -300,6 +300,7 @@ gfc_trans_omp_array_reduction (tree c, g
   init_val_sym.ts = sym->ts;
   init_val_sym.attr.referenced = 1;
   init_val_sym.declared_at = where;
+  init_val_sym.attr.flavor = FL_VARIABLE;
   backend_decl = omp_reduction_init (c, gfc_sym_type (&init_val_sym));
   init_val_sym.backend_decl = backend_decl;
 
@@ -308,6 +309,7 @@ gfc_trans_omp_array_reduction (tree c, g
   outer_sym.as = gfc_copy_array_spec (sym->as);
   outer_sym.attr.dummy = 0;
   outer_sym.attr.result = 0;
+  outer_sym.attr.flavor = FL_VARIABLE;
   outer_sym.backend_decl = create_tmp_var_raw (TREE_TYPE (decl), NULL);
 
   /* Create fake symtrees for it.  */
--- libgomp/testsuite/libgomp.fortran/pr29629.f90.jj	2006-10-29 08:59:04.000000000 +0100
+++ libgomp/testsuite/libgomp.fortran/pr29629.f90	2006-10-29 08:58:18.000000000 +0100
@@ -0,0 +1,20 @@
+! PR fortran/29629
+! { dg-do run }
+
+program pr29629
+  integer :: n
+  n = 10000
+  if (any (func(n).ne.10000)) call abort
+  contains
+    function func(n)
+      integer, intent(in) :: n
+      integer, dimension(n) :: func
+      integer :: k
+      func = 0
+!$omp parallel do private(k), reduction(+:func), num_threads(4)
+      do k = 1, n
+        func = func + 1
+      end do
+!$omp end parallel do
+    end function
+end program

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]