OSDN Git Service

PR target/38695
[pf3gnuchains/gcc-fork.git] / gcc / omp-low.c
index d6c5500..b7885e6 100644 (file)
@@ -164,7 +164,7 @@ static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *);
 /* Find an OpenMP clause of type KIND within CLAUSES.  */
 
 tree
-find_omp_clause (tree clauses, enum tree_code kind)
+find_omp_clause (tree clauses, enum omp_clause_code kind)
 {
   for (; clauses ; clauses = OMP_CLAUSE_CHAIN (clauses))
     if (OMP_CLAUSE_CODE (clauses) == kind)
@@ -760,10 +760,10 @@ use_pointer_for_field (tree decl, omp_context *shared_ctx)
          omp_context *up;
 
          for (up = shared_ctx->outer; up; up = up->outer)
-           if (maybe_lookup_decl (decl, up))
+           if (is_taskreg_ctx (up) && maybe_lookup_decl (decl, up))
              break;
 
-         if (up && is_taskreg_ctx (up))
+         if (up)
            {
              tree c;
 
@@ -3681,8 +3681,20 @@ expand_omp_for_generic (struct omp_region *region,
       t4 = build_fold_addr_expr (iend0);
       t3 = build_fold_addr_expr (istart0);
       t2 = fold_convert (fd->iter_type, fd->loop.step);
-      t1 = fold_convert (fd->iter_type, fd->loop.n2);
-      t0 = fold_convert (fd->iter_type, fd->loop.n1);
+      if (POINTER_TYPE_P (type)
+         && TYPE_PRECISION (type) != TYPE_PRECISION (fd->iter_type))
+       {
+         /* Avoid casting pointers to integer of a different size.  */
+         tree itype
+           = lang_hooks.types.type_for_size (TYPE_PRECISION (type), 0);
+         t1 = fold_convert (fd->iter_type, fold_convert (itype, fd->loop.n2));
+         t0 = fold_convert (fd->iter_type, fold_convert (itype, fd->loop.n1));
+       }
+      else
+       {
+         t1 = fold_convert (fd->iter_type, fd->loop.n2);
+         t0 = fold_convert (fd->iter_type, fd->loop.n1);
+       }
       if (bias)
        {
          t1 = fold_build2 (PLUS_EXPR, fd->iter_type, t1, bias);