diff mbox

VEC re-write [patch 07/25]

Message ID 20121115215338.49C64C0916@torture.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo Nov. 15, 2012, 9:53 p.m. UTC
2012-11-15  Diego Novillo  <dnovillo@google.com>

	Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)

	* frontend-passes.c: Use new vec API in vec.h.
	* trans-array.c: Likewise.
	* trans-common.c: Likewise.
	* trans-decl.c: Likewise.
	* trans-expr.c: Likewise.
	* trans-intrinsic.c: Likewise.
	* trans-openmp.c: Likewise.
	* trans-stmt.c: Likewise.
	* trans-types.c: Likewise.
	* trans.h: Likewise.
diff mbox

Patch

diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 0cba911..287807e 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -38,7 +38,7 @@  static bool optimize_comparison (gfc_expr *, gfc_intrinsic_op);
 static bool optimize_trim (gfc_expr *);
 static bool optimize_lexical_comparison (gfc_expr *);
 static void optimize_minmaxloc (gfc_expr **);
-static bool empty_string (gfc_expr *e);
+static bool is_empty_string (gfc_expr *e);
 
 /* How deep we are inside an argument list.  */
 
@@ -742,7 +742,7 @@  optimize_assignment (gfc_code * c)
       remove_trim (rhs);
 
       /* Replace a = '   ' by a = '' to optimize away a memcpy.  */
-      if (empty_string(rhs))
+      if (is_empty_string(rhs))
 	rhs->value.character.length = 0;
     }
 
@@ -865,7 +865,7 @@  optimize_op (gfc_expr *e)
 /* Return true if a constant string contains only blanks.  */
 
 static bool
-empty_string (gfc_expr *e)
+is_empty_string (gfc_expr *e)
 {
   int i;
 
@@ -967,8 +967,8 @@  optimize_comparison (gfc_expr *e, gfc_intrinsic_op op)
       && (op == INTRINSIC_EQ || op == INTRINSIC_NE))
     {
       bool empty_op1, empty_op2;
-      empty_op1 = empty_string (op1);
-      empty_op2 = empty_string (op2);
+      empty_op1 = is_empty_string (op1);
+      empty_op2 = is_empty_string (op2);
 
       if (empty_op1 || empty_op2)
 	{
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 26f0523..e865514 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -1626,7 +1626,7 @@  gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
 	  else
 	    {
 	      /* Collect multiple scalar constants into a constructor.  */
-	      VEC(constructor_elt,gc) *v = NULL;
+	      vec<constructor_elt, va_gc> *v = NULL;
 	      tree init;
 	      tree bound;
 	      tree tmptype;
@@ -1985,7 +1985,7 @@  gfc_build_constant_array_constructor (gfc_expr * expr, tree type)
   gfc_array_spec as;
   gfc_se se;
   int i;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   /* First traverse the constructor list, converting the constants
      to tree to build an initializer.  */
@@ -5317,7 +5317,7 @@  gfc_conv_array_initializer (tree type, gfc_expr * expr)
   HOST_WIDE_INT hi;
   unsigned HOST_WIDE_INT lo;
   tree index, range;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   if (expr->expr_type == EXPR_VARIABLE
       && expr->symtree->n.sym->attr.flavor == FL_PARAMETER
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 86cf007..474774f 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -487,7 +487,7 @@  get_init_field (segment_info *head, tree union_type, tree *field_init,
   tree tmp, field;
   tree init;
   unsigned char *data, *chk;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   tree type = unsigned_char_type_node;
   int i;
@@ -644,7 +644,7 @@  create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
   if (is_init)
     {
       tree ctor, tmp;
-      VEC(constructor_elt,gc) *v = NULL;
+      vec<constructor_elt, va_gc> *v = NULL;
 
       if (field != NULL_TREE && field_init != NULL_TREE)
 	CONSTRUCTOR_APPEND_ELT (v, field, field_init);
@@ -664,7 +664,7 @@  create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
 	      }
 	  }
 
-      gcc_assert (!VEC_empty (constructor_elt, v));
+      gcc_assert (!v->is_empty ());
       ctor = build_constructor (union_type, v);
       TREE_CONSTANT (ctor) = 1;
       TREE_STATIC (ctor) = 1;
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 7750217..c661fb3 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -2284,8 +2284,8 @@  build_entry_thunks (gfc_namespace * ns, bool global)
   gfc_save_backend_locus (&old_loc);
   for (el = ns->entries; el; el = el->next)
     {
-      VEC(tree,gc) *args = NULL;
-      VEC(tree,gc) *string_args = NULL;
+      vec<tree, va_gc> *args = NULL;
+      vec<tree, va_gc> *string_args = NULL;
 
       thunk_sym = el->sym;
       
@@ -2300,16 +2300,16 @@  build_entry_thunks (gfc_namespace * ns, bool global)
 
       /* Pass extra parameter identifying this entry point.  */
       tmp = build_int_cst (gfc_array_index_type, el->id);
-      VEC_safe_push (tree, gc, args, tmp);
+      vec_safe_push (args, tmp);
 
       if (thunk_sym->attr.function)
 	{
 	  if (gfc_return_by_reference (ns->proc_name))
 	    {
 	      tree ref = DECL_ARGUMENTS (current_function_decl);
-	      VEC_safe_push (tree, gc, args, ref);
+	      vec_safe_push (args, ref);
 	      if (ns->proc_name->ts.type == BT_CHARACTER)
-		VEC_safe_push (tree, gc, args, DECL_CHAIN (ref));
+		vec_safe_push (args, DECL_CHAIN (ref));
 	    }
 	}
 
@@ -2333,27 +2333,27 @@  build_entry_thunks (gfc_namespace * ns, bool global)
 	    {
 	      /* Pass the argument.  */
 	      DECL_ARTIFICIAL (thunk_formal->sym->backend_decl) = 1;
-	      VEC_safe_push (tree, gc, args, thunk_formal->sym->backend_decl);
+	      vec_safe_push (args, thunk_formal->sym->backend_decl);
 	      if (formal->sym->ts.type == BT_CHARACTER)
 		{
 		  tmp = thunk_formal->sym->ts.u.cl->backend_decl;
-		  VEC_safe_push (tree, gc, string_args, tmp);
+		  vec_safe_push (string_args, tmp);
 		}
 	    }
 	  else
 	    {
 	      /* Pass NULL for a missing argument.  */
-	      VEC_safe_push (tree, gc, args, null_pointer_node);
+	      vec_safe_push (args, null_pointer_node);
 	      if (formal->sym->ts.type == BT_CHARACTER)
 		{
 		  tmp = build_int_cst (gfc_charlen_type_node, 0);
-		  VEC_safe_push (tree, gc, string_args, tmp);
+		  vec_safe_push (string_args, tmp);
 		}
 	    }
 	}
 
       /* Call the master function.  */
-      VEC_safe_splice (tree, gc, args, string_args);
+      vec_safe_splice (args, string_args);
       tmp = ns->proc_name->backend_decl;
       tmp = build_call_expr_loc_vec (input_location, tmp, args);
       if (ns->proc_name->attr.mixed_entry_master)
@@ -2616,7 +2616,7 @@  static tree
 build_library_function_decl_1 (tree name, const char *spec,
 			       tree rettype, int nargs, va_list p)
 {
-  VEC(tree,gc) *arglist;
+  vec<tree, va_gc> *arglist;
   tree fntype;
   tree fndecl;
   int n;
@@ -2625,11 +2625,11 @@  build_library_function_decl_1 (tree name, const char *spec,
   gcc_assert (current_function_decl == NULL_TREE);
 
   /* Create a list of the argument types.  */
-  arglist = VEC_alloc (tree, gc, abs (nargs));
+  vec_alloc (arglist, abs (nargs));
   for (n = abs (nargs); n > 0; n--)
     {
       tree argtype = va_arg (p, tree);
-      VEC_quick_push (tree, arglist, argtype);
+      arglist->quick_push (argtype);
     }
 
   /* Build the function type and decl.  */
@@ -5005,7 +5005,7 @@  create_main_function (tree fndecl)
      language standard parameters.  */
   {
     tree array_type, array, var;
-    VEC(constructor_elt,gc) *v = NULL;
+    vec<constructor_elt, va_gc> *v = NULL;
 
     /* Passing a new option to the library requires four modifications:
      + add it to the tree_cons list below
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index b0bd7f5..d6410d3 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -661,7 +661,7 @@  gfc_copy_class_to_class (tree from, tree to, tree nelems)
   tree to_data;
   tree to_ref;
   tree from_ref;
-  VEC(tree,gc) *args;
+  vec<tree, va_gc> *args;
   tree tmp;
   tree index;
   stmtblock_t loopbody;
@@ -696,13 +696,13 @@  gfc_copy_class_to_class (tree from, tree to, tree nelems)
       if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (from_data)))
 	{
 	  from_ref = gfc_get_class_array_ref (index, from);
-	  VEC_safe_push (tree, gc, args, from_ref);
+	  vec_safe_push (args, from_ref);
 	}
       else
-        VEC_safe_push (tree, gc, args, from_data);
+        vec_safe_push (args, from_data);
 
       to_ref = gfc_get_class_array_ref (index, to);
-      VEC_safe_push (tree, gc, args, to_ref);
+      vec_safe_push (args, to_ref);
 
       tmp = build_call_vec (fcn_type, fcn, args);
 
@@ -724,8 +724,8 @@  gfc_copy_class_to_class (tree from, tree to, tree nelems)
   else
     {
       gcc_assert (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (from_data)));
-      VEC_safe_push (tree, gc, args, from_data);
-      VEC_safe_push (tree, gc, args, to_data);
+      vec_safe_push (args, from_data);
+      vec_safe_push (args, to_data);
       tmp = build_call_vec (fcn_type, fcn, args);
     }
 
@@ -3822,11 +3822,11 @@  conv_isocbinding_procedure (gfc_se * se, gfc_symbol * sym,
 int
 gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 			 gfc_actual_arglist * args, gfc_expr * expr,
-			 VEC(tree,gc) *append_args)
+			 vec<tree, va_gc> *append_args)
 {
   gfc_interface_mapping mapping;
-  VEC(tree,gc) *arglist;
-  VEC(tree,gc) *retargs;
+  vec<tree, va_gc> *arglist;
+  vec<tree, va_gc> *retargs;
   tree tmp;
   tree fntype;
   gfc_se parmse;
@@ -3837,7 +3837,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   tree var;
   tree len;
   tree base_object;
-  VEC(tree,gc) *stringargs;
+  vec<tree, va_gc> *stringargs;
   tree result = NULL;
   gfc_formal_arglist *formal;
   gfc_actual_arglist *arg;
@@ -4608,7 +4608,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
       /* Character strings are passed as two parameters, a length and a
          pointer - except for Bind(c) which only passes the pointer.  */
       if (parmse.string_length != NULL_TREE && !sym->attr.is_bind_c)
-	VEC_safe_push (tree, gc, stringargs, parmse.string_length);
+	vec_safe_push (stringargs, parmse.string_length);
 
       /* For descriptorless coarrays and assumed-shape coarray dummies, we
 	 pass the token and the offset as additional arguments.  */
@@ -4618,9 +4618,8 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  && e == NULL)
 	{
 	  /* Token and offset. */
-	  VEC_safe_push (tree, gc, stringargs, null_pointer_node);
-	  VEC_safe_push (tree, gc, stringargs,
-			 build_int_cst (gfc_array_index_type, 0));
+	  vec_safe_push (stringargs, null_pointer_node);
+	  vec_safe_push (stringargs, build_int_cst (gfc_array_index_type, 0));
 	  gcc_assert (fsym->attr.optional);
 	}
       else if (fsym && fsym->attr.codimension
@@ -4646,7 +4645,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	      tmp = GFC_TYPE_ARRAY_CAF_TOKEN (caf_type);
 	    }
 	  
-	  VEC_safe_push (tree, gc, stringargs, tmp);
+	  vec_safe_push (stringargs, tmp);
 
 	  if (GFC_DESCRIPTOR_TYPE_P (caf_type)
 	      && GFC_TYPE_ARRAY_AKIND (caf_type) == GFC_ARRAY_ALLOCATABLE)
@@ -4692,10 +4691,10 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  offset = fold_build2_loc (input_location, PLUS_EXPR,
 				    gfc_array_index_type, offset, tmp);
 
-	  VEC_safe_push (tree, gc, stringargs, offset);
+	  vec_safe_push (stringargs, offset);
 	}
 
-      VEC_safe_push (tree, gc, arglist, parmse.expr);
+      vec_safe_push (arglist, parmse.expr);
     }
   gfc_finish_interface_mapping (&mapping, &se->pre, &se->post);
 
@@ -4719,7 +4718,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  if (ts.deferred)
 	    cl.backend_decl = gfc_create_var (gfc_charlen_type_node, "slen");
 	  else if (!sym->attr.dummy)
-	    cl.backend_decl = VEC_index (tree, stringargs, 0);
+	    cl.backend_decl = (*stringargs)[0];
 	  else
 	    {
 	      formal = sym->ns->proc_name->formal;
@@ -4796,7 +4795,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  else
 	    result = build_fold_indirect_ref_loc (input_location,
 						  se->expr);
-	  VEC_safe_push (tree, gc, retargs, se->expr);
+	  vec_safe_push (retargs, se->expr);
 	}
       else if (comp && comp->attr.dimension)
 	{
@@ -4832,7 +4831,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  /* Pass the temporary as the first argument.  */
 	  result = info->descriptor;
 	  tmp = gfc_build_addr_expr (NULL_TREE, result);
-	  VEC_safe_push (tree, gc, retargs, tmp);
+	  vec_safe_push (retargs, tmp);
 	}
       else if (!comp && sym->result->attr.dimension)
 	{
@@ -4868,7 +4867,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  /* Pass the temporary as the first argument.  */
 	  result = info->descriptor;
 	  tmp = gfc_build_addr_expr (NULL_TREE, result);
-	  VEC_safe_push (tree, gc, retargs, tmp);
+	  vec_safe_push (retargs, tmp);
 	}
       else if (ts.type == BT_CHARACTER)
 	{
@@ -4899,7 +4898,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  else
 	    var = gfc_conv_string_tmp (se, type, len);
 
-	  VEC_safe_push (tree, gc, retargs, var);
+	  vec_safe_push (retargs, var);
 	}
       else
 	{
@@ -4907,7 +4906,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
 	  type = gfc_get_complex_type (ts.kind);
 	  var = gfc_build_addr_expr (NULL_TREE, gfc_create_var (type, "cmplx"));
-	  VEC_safe_push (tree, gc, retargs, var);
+	  vec_safe_push (retargs, var);
 	}
 
       /* Add the string length to the argument list.  */
@@ -4917,28 +4916,28 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  if (TREE_CODE (tmp) != VAR_DECL)
 	    tmp = gfc_evaluate_now (len, &se->pre);
 	  tmp = gfc_build_addr_expr (NULL_TREE, tmp);
-	  VEC_safe_push (tree, gc, retargs, tmp);
+	  vec_safe_push (retargs, tmp);
 	}
       else if (ts.type == BT_CHARACTER)
-	VEC_safe_push (tree, gc, retargs, len);
+	vec_safe_push (retargs, len);
     }
   gfc_free_interface_mapping (&mapping);
 
   /* We need to glom RETARGS + ARGLIST + STRINGARGS + APPEND_ARGS.  */
-  arglen = (VEC_length (tree, arglist)
-	    + VEC_length (tree, stringargs) + VEC_length (tree, append_args));
-  VEC_reserve_exact (tree, gc, retargs, arglen);
+  arglen = (vec_safe_length (arglist) + vec_safe_length (stringargs)
+	    + vec_safe_length (append_args));
+  vec_safe_reserve (retargs, arglen);
 
   /* Add the return arguments.  */
-  VEC_splice (tree, retargs, arglist);
+  retargs->splice (arglist);
 
   /* Add the hidden string length parameters to the arguments.  */
-  VEC_splice (tree, retargs, stringargs);
+  retargs->splice (stringargs);
 
   /* We may want to append extra arguments here.  This is used e.g. for
      calls to libgfortran_matmul_??, which need extra information.  */
-  if (!VEC_empty (tree, append_args))
-    VEC_splice (tree, retargs, append_args);
+  if (!vec_safe_is_empty (append_args))
+    retargs->splice (append_args);
   arglist = retargs;
 
   /* Generate the actual call.  */
@@ -5423,7 +5422,8 @@  gfc_conv_function_expr (gfc_se * se, gfc_expr * expr)
   if (!sym)
     sym = expr->symtree->n.sym;
 
-  gfc_conv_procedure_call (se, sym, expr->value.function.actual, expr, NULL);
+  gfc_conv_procedure_call (se, sym, expr->value.function.actual, expr,
+			   NULL);
 }
 
 
@@ -5965,7 +5965,7 @@  gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init)
   tree val;
   tree type;
   tree tmp;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   gcc_assert (se->ss == NULL);
   gcc_assert (expr->expr_type == EXPR_STRUCTURE);
@@ -7139,7 +7139,8 @@  gfc_trans_zero_assign (gfc_expr * expr)
      a = {} instead.  */
   if (!POINTER_TYPE_P (TREE_TYPE (dest)))
     return build2_loc (input_location, MODIFY_EXPR, void_type_node,
-		       dest, build_constructor (TREE_TYPE (dest), NULL));
+		       dest, build_constructor (TREE_TYPE (dest),
+					      NULL));
 
   /* Convert arguments to the correct types.  */
   dest = fold_convert (pvoid_type_node, dest);
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index b101cb4..57156a4 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -724,7 +724,7 @@  static tree
 gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr)
 {
   tree type;
-  VEC(tree,gc) *argtypes;
+  vec<tree, va_gc> *argtypes;
   tree fndecl;
   gfc_actual_arglist *actual;
   tree *pdecl;
@@ -809,7 +809,7 @@  gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr)
   for (actual = expr->value.function.actual; actual; actual = actual->next)
     {
       type = gfc_typenode_for_spec (&actual->expr->ts);
-      VEC_safe_push (tree, gc, argtypes, type);
+      vec_safe_push (argtypes, type);
     }
   type = build_function_type_vec (gfc_typenode_for_spec (ts), argtypes);
   fndecl = build_decl (input_location,
@@ -2341,7 +2341,7 @@  static void
 gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr * expr)
 {
   gfc_symbol *sym;
-  VEC(tree,gc) *append_args;
+  vec<tree, va_gc> *append_args;
 
   gcc_assert (!se->ss || se->ss->info->expr == expr);
 
@@ -2381,19 +2381,19 @@  gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr * expr)
 		gemm_fndecl = gfor_fndecl_zgemm;
 	    }
 
-	  append_args = VEC_alloc (tree, gc, 3);
-	  VEC_quick_push (tree, append_args, build_int_cst (cint, 1));
-	  VEC_quick_push (tree, append_args,
-			  build_int_cst (cint, gfc_option.blas_matmul_limit));
-	  VEC_quick_push (tree, append_args,
-			  gfc_build_addr_expr (NULL_TREE, gemm_fndecl));
+	  vec_alloc (append_args, 3);
+	  append_args->quick_push (build_int_cst (cint, 1));
+	  append_args->quick_push (build_int_cst (cint,
+		                                 gfc_option.blas_matmul_limit));
+	  append_args->quick_push (gfc_build_addr_expr (NULL_TREE,
+							gemm_fndecl));
 	}
       else
 	{
-	  append_args = VEC_alloc (tree, gc, 3);
-	  VEC_quick_push (tree, append_args, build_int_cst (cint, 0));
-	  VEC_quick_push (tree, append_args, build_int_cst (cint, 0));
-	  VEC_quick_push (tree, append_args, null_pointer_node);
+	  vec_alloc (append_args, 3);
+	  append_args->quick_push (build_int_cst (cint, 0));
+	  append_args->quick_push (build_int_cst (cint, 0));
+	  append_args->quick_push (null_pointer_node);
 	}
     }
 
@@ -4486,7 +4486,7 @@  conv_generic_with_optional_char_arg (gfc_se* se, gfc_expr* expr,
   unsigned cur_pos;
   gfc_actual_arglist* arg;
   gfc_symbol* sym;
-  VEC(tree,gc) *append_args;
+  vec<tree, va_gc> *append_args;
 
   /* Find the two arguments given as position.  */
   cur_pos = 0;
@@ -4516,8 +4516,8 @@  conv_generic_with_optional_char_arg (gfc_se* se, gfc_expr* expr,
       tree dummy;
 
       dummy = build_int_cst (gfc_charlen_type_node, 0);
-      append_args = VEC_alloc (tree, gc, 1);
-      VEC_quick_push (tree, append_args, dummy);
+      vec_alloc (append_args, 1);
+      append_args->quick_push (dummy);
     }
 
   /* Build the call itself.  */
@@ -5983,7 +5983,7 @@  gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr)
   gfc_actual_arglist *actual;
   tree type;
   gfc_se argse;
-  VEC(tree,gc) *args = NULL;
+  vec<tree, va_gc> *args = NULL;
 
   for (actual = expr->value.function.actual; actual; actual = actual->next)
     {
@@ -6009,7 +6009,7 @@  gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr)
 
       gfc_add_block_to_block (&se->pre, &argse.pre);
       gfc_add_block_to_block (&se->post, &argse.post);
-      VEC_safe_push (tree, gc, args, argse.expr);
+      vec_safe_push (args, argse.expr);
     }
 
   /* Convert it to the required type.  */
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index e843692..a844b08 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1293,8 +1293,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 +1305,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 = vec<dovar_init>();
   dovar_init *di;
   unsigned ix;
 
@@ -1435,7 +1433,7 @@  gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
 	  tmp = fold_build2_loc (input_location, MULT_EXPR, type, count, step);
 	  tmp = fold_build2_loc (input_location, PLUS_EXPR, type, from, tmp);
 	  dovar_init e = {dovar, tmp};
-	  VEC_safe_push (dovar_init, heap, inits, e);
+	  inits.safe_push (e);
 	}
 
       if (!dovar_found)
@@ -1506,9 +1504,9 @@  gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
 
   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.  */
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index b95c8da..b2ba075 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -488,7 +488,8 @@  gfc_trans_call (gfc_code * code, bool dependency_check,
 
       /* Add the subroutine call to the block.  */
       gfc_conv_procedure_call (&loopse, code->resolved_sym,
-			       code->ext.actual, code->expr1, NULL);
+			       code->ext.actual, code->expr1,
+			       NULL);
 
       if (mask && count1)
 	{
@@ -2093,7 +2094,7 @@  gfc_trans_character_select (gfc_code *code)
   gfc_code *c;
   gfc_se se, expr1se;
   int n, k;
-  VEC(constructor_elt,gc) *inits = NULL;
+  vec<constructor_elt, va_gc> *inits = NULL;
 
   tree pchartype = gfc_get_pchar_type (code->expr1->ts.kind);
 
@@ -2321,7 +2322,7 @@  gfc_trans_character_select (gfc_code *code)
   /* Generate the structure describing the branches */
   for (d = cp; d; d = d->right)
     {
-      VEC(constructor_elt,gc) *node = NULL;
+      vec<constructor_elt, va_gc> *node = NULL;
 
       gfc_init_se (&se, NULL);
 
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 81b7fa5..35a39c5 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2690,7 +2690,7 @@  tree
 gfc_get_function_type (gfc_symbol * sym)
 {
   tree type;
-  VEC(tree,gc) *typelist;
+  vec<tree, va_gc> *typelist;
   gfc_formal_arglist *f;
   gfc_symbol *arg;
   int alternate_return;
@@ -2713,7 +2713,7 @@  gfc_get_function_type (gfc_symbol * sym)
 
   if (sym->attr.entry_master)
     /* Additional parameter for selecting an entry point.  */
-    VEC_safe_push (tree, gc, typelist, gfc_array_index_type);
+    vec_safe_push (typelist, gfc_array_index_type);
 
   if (sym->result)
     arg = sym->result;
@@ -2732,17 +2732,16 @@  gfc_get_function_type (gfc_symbol * sym)
 	  || arg->ts.type == BT_CHARACTER)
 	type = build_reference_type (type);
 
-      VEC_safe_push (tree, gc, typelist, type);
+      vec_safe_push (typelist, type);
       if (arg->ts.type == BT_CHARACTER)
 	{
 	  if (!arg->ts.deferred)
 	    /* Transfer by value.  */
-	    VEC_safe_push (tree, gc, typelist, gfc_charlen_type_node);
+	    vec_safe_push (typelist, gfc_charlen_type_node);
 	  else
 	    /* Deferred character lengths are transferred by reference
 	       so that the value can be returned.  */
-	    VEC_safe_push (tree, gc, typelist,
-			   build_pointer_type (gfc_charlen_type_node));
+	    vec_safe_push (typelist, build_pointer_type(gfc_charlen_type_node));
 	}
     }
 
@@ -2780,7 +2779,7 @@  gfc_get_function_type (gfc_symbol * sym)
 	     used without an explicit interface, and cannot be passed as
 	     actual parameters for a dummy procedure.  */
 
-	  VEC_safe_push (tree, gc, typelist, type);
+	  vec_safe_push (typelist, type);
 	}
       else
         {
@@ -2803,11 +2802,11 @@  gfc_get_function_type (gfc_symbol * sym)
 	       so that the value can be returned.  */
 	    type = build_pointer_type (gfc_charlen_type_node);
 
-	  VEC_safe_push (tree, gc, typelist, type);
+	  vec_safe_push (typelist, type);
 	}
     }
 
-  if (!VEC_empty (tree, typelist)
+  if (!vec_safe_is_empty (typelist)
       || sym->attr.is_main_program
       || sym->attr.if_source != IFSRC_UNKNOWN)
     is_varargs = false;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 652893e..954dcd3 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -427,7 +427,7 @@  int gfc_is_intrinsic_libcall (gfc_expr *);
 /* Used to call ordinary functions/subroutines
    and procedure pointer components.  */
 int gfc_conv_procedure_call (gfc_se *, gfc_symbol *, gfc_actual_arglist *,
-			     gfc_expr *, VEC(tree,gc) *);
+			     gfc_expr *, vec<tree, va_gc> *);
 
 void gfc_conv_subref_array_arg (gfc_se *, gfc_expr *, int, sym_intent, bool);