Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / fortran / trans-openmp.c
index f8b3e22..988dea9 100644 (file)
@@ -1,6 +1,5 @@
 /* OpenMP directive translation -- generate GCC trees from gfc_code.
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 2005-2013 Free Software Foundation, Inc.
    Contributed by Jakub Jelinek <jakub@redhat.com>
 
 This file is part of GCC.
@@ -651,7 +650,7 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
   gcc_assert (t == SUCCESS);
 
   /* Create the init statement list.  */
-  pushlevel (0);
+  pushlevel ();
   if (GFC_DESCRIPTOR_TYPE_P (type)
       && GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE)
     {
@@ -691,13 +690,13 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
   else
     stmt = gfc_trans_assignment (e1, e2, false, false);
   if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   OMP_CLAUSE_REDUCTION_INIT (c) = stmt;
 
   /* Create the merge statement list.  */
-  pushlevel (0);
+  pushlevel ();
   if (GFC_DESCRIPTOR_TYPE_P (type)
       && GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE)
     {
@@ -714,9 +713,9 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
   else
     stmt = gfc_trans_assignment (e3, e4, false, true);
   if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   OMP_CLAUSE_REDUCTION_MERGE (c) = stmt;
 
   /* And stick the placeholder VAR_DECL into the clause as well.  */
@@ -1001,20 +1000,20 @@ gfc_trans_omp_code (gfc_code *code, bool force_empty)
 {
   tree stmt;
 
-  pushlevel (0);
+  pushlevel ();
   stmt = gfc_trans_code (code);
   if (TREE_CODE (stmt) != BIND_EXPR)
     {
       if (!IS_EMPTY_STMT (stmt) || force_empty)
        {
-         tree block = poplevel (1, 0, 0);
+         tree block = poplevel (1, 0);
          stmt = build3_v (BIND_EXPR, NULL, stmt, block);
        }
       else
-       poplevel (0, 0, 0);
+       poplevel (0, 0);
     }
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   return stmt;
 }
 
@@ -1293,8 +1292,6 @@ typedef struct dovar_init_d {
   tree init;
 } dovar_init;
 
-DEF_VEC_O(dovar_init);
-DEF_VEC_ALLOC_O(dovar_init,heap);
 
 static tree
 gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
@@ -1307,7 +1304,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
   stmtblock_t body;
   gfc_omp_clauses *clauses = code->ext.omp_clauses;
   int i, collapse = clauses->collapse;
-  VEC(dovar_init,heap) *inits = NULL;
+  vec<dovar_init> inits = vNULL;
   dovar_init *di;
   unsigned ix;
 
@@ -1434,9 +1431,8 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
          /* Initialize DOVAR.  */
          tmp = fold_build2_loc (input_location, MULT_EXPR, type, count, step);
          tmp = fold_build2_loc (input_location, PLUS_EXPR, type, from, tmp);
-         di = VEC_safe_push (dovar_init, heap, inits, NULL);
-         di->var = dovar;
-         di->init = tmp;
+         dovar_init e = {dovar, tmp};
+         inits.safe_push (e);
        }
 
       if (!dovar_found)
@@ -1501,15 +1497,15 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
 
   if (pblock != &block)
     {
-      pushlevel (0);
+      pushlevel ();
       gfc_start_block (&block);
     }
 
   gfc_start_block (&body);
 
-  FOR_EACH_VEC_ELT (dovar_init, inits, ix, di)
+  FOR_EACH_VEC_ELT (inits, ix, di)
     gfc_add_modify (&body, di->var, di->init);
-  VEC_free (dovar_init, heap, inits);
+  inits.release ();
 
   /* Cycle statement is implemented with a goto.  Exit statement must not be
      present for this loop.  */
@@ -1612,12 +1608,12 @@ gfc_trans_omp_parallel_do (gfc_code *code)
   if (!do_clauses.ordered && do_clauses.sched_kind != OMP_SCHED_STATIC)
     pblock = &block;
   else
-    pushlevel (0);
+    pushlevel ();
   stmt = gfc_trans_omp_do (code, pblock, &do_clauses, omp_clauses);
   if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
                     omp_clauses);
   OMP_PARALLEL_COMBINED (stmt) = 1;
@@ -1638,12 +1634,12 @@ gfc_trans_omp_parallel_sections (gfc_code *code)
   gfc_start_block (&block);
   omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
                                       code->loc);
-  pushlevel (0);
+  pushlevel ();
   stmt = gfc_trans_omp_sections (code, &section_clauses);
   if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
                     omp_clauses);
   OMP_PARALLEL_COMBINED (stmt) = 1;
@@ -1664,12 +1660,12 @@ gfc_trans_omp_parallel_workshare (gfc_code *code)
   gfc_start_block (&block);
   omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
                                       code->loc);
-  pushlevel (0);
+  pushlevel ();
   stmt = gfc_trans_omp_workshare (code, &workshare_clauses);
   if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
   stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
                     omp_clauses);
   OMP_PARALLEL_COMBINED (stmt) = 1;
@@ -1763,7 +1759,7 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
 
   code = code->block->next;
 
-  pushlevel (0);
+  pushlevel ();
 
   gfc_start_block (&block);
   pblock = &block;
@@ -1892,14 +1888,14 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
     {
       if (!IS_EMPTY_STMT (stmt))
        {
-         tree bindblock = poplevel (1, 0, 0);
+         tree bindblock = poplevel (1, 0);
          stmt = build3_v (BIND_EXPR, NULL, stmt, bindblock);
        }
       else
-       poplevel (0, 0, 0);
+       poplevel (0, 0);
     }
   else
-    poplevel (0, 0, 0);
+    poplevel (0, 0);
 
   if (IS_EMPTY_STMT (stmt) && !clauses->nowait)
     stmt = gfc_trans_omp_barrier ();