The uses of vec<T> in get_all_loop_exits and process_conditional were memory
leaks, as .release() was never called for them.  The other changes are some
cases that did have proper release handling, but it's simpler to leave
releasing to the auto_vec destructor.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/ChangeLog:

        * sel-sched-ir.h (get_all_loop_exits): Use auto_vec.

gcc/cp/ChangeLog:

        * class.c (struct find_final_overrider_data): Use auto_vec.
        (find_final_overrider): Remove explicit release.
        * coroutines.cc (process_conditional): Use auto_vec.
        * cp-gimplify.c (struct cp_genericize_data): Use auto_vec.
        (cp_genericize_tree): Remove explicit release.
        * parser.c (cp_parser_objc_at_property_declaration): Use
        auto_delete_vec.
        * semantics.c (omp_reduction_lookup): Use auto_vec.
---
 gcc/sel-sched-ir.h   | 2 +-
 gcc/cp/class.c       | 4 +---
 gcc/cp/coroutines.cc | 2 +-
 gcc/cp/cp-gimplify.c | 3 +--
 gcc/cp/parser.c      | 6 +-----
 gcc/cp/semantics.c   | 3 +--
 6 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
index 78b2566ad3e..8ee0529d5a8 100644
--- a/gcc/sel-sched-ir.h
+++ b/gcc/sel-sched-ir.h
@@ -1166,7 +1166,7 @@ get_all_loop_exits (basic_block bb)
             || (inner_loop_header_p (e->dest)))
            && loop_depth (e->dest->loop_father) >= this_depth)
          {
-           vec<edge> next_exits = get_all_loop_exits (e->dest);
+           auto_vec<edge> next_exits = get_all_loop_exits (e->dest);
 
            if (next_exits.exists ())
              {
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 33093e1e1ef..14db06692dc 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2391,7 +2391,7 @@ struct find_final_overrider_data {
   /* The candidate overriders.  */
   tree candidates;
   /* Path to most derived.  */
-  vec<tree> path;
+  auto_vec<tree> path;
 };
 
 /* Add the overrider along the current path to FFOD->CANDIDATES.
@@ -2504,8 +2504,6 @@ find_final_overrider (tree derived, tree binfo, tree fn)
   dfs_walk_all (derived, dfs_find_final_overrider_pre,
                dfs_find_final_overrider_post, &ffod);
 
-  ffod.path.release ();
-
   /* If there was no winner, issue an error message.  */
   if (!ffod.candidates || TREE_CHAIN (ffod.candidates))
     return error_mark_node;
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 54ffdc8d062..712a5c0ab37 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3081,7 +3081,7 @@ process_conditional (var_nest_node *n, tree& vlist)
 {
   tree init = n->init;
   hash_map<tree, tree> var_flags;
-  vec<tree> var_list = vNULL;
+  auto_vec<tree> var_list;
   tree new_then = push_stmt_list ();
   handle_nested_conditionals (n->then_cl, var_list, var_flags);
   new_then = pop_stmt_list (new_then);
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 00b7772fe0d..de37f2cdfdc 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -807,7 +807,7 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg 
*omp_ctx, tree decl)
 struct cp_genericize_data
 {
   hash_set<tree> *p_set;
-  vec<tree> bind_expr_stack;
+  auto_vec<tree> bind_expr_stack;
   struct cp_genericize_omp_taskreg *omp_ctx;
   tree try_block;
   bool no_sanitize_p;
@@ -1582,7 +1582,6 @@ cp_genericize_tree (tree* t_p, bool 
handle_invisiref_parm_p)
   wtd.handle_invisiref_parm_p = handle_invisiref_parm_p;
   cp_walk_tree (t_p, cp_genericize_r, &wtd, NULL);
   delete wtd.p_set;
-  wtd.bind_expr_stack.release ();
   if (sanitize_flags_p (SANITIZE_VPTR))
     cp_ubsan_instrument_member_accesses (t_p);
 }
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 93698aa14c9..821ce1771a4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -35247,7 +35247,7 @@ cp_parser_objc_at_property_declaration (cp_parser 
*parser)
   /* Parse the optional attribute list.
 
      A list of parsed, but not verified, attributes.  */
-  vec<property_attribute_info *> prop_attr_list = vNULL;
+  auto_delete_vec<property_attribute_info> prop_attr_list;
   location_t loc = cp_lexer_peek_token (parser->lexer)->location;
 
   cp_lexer_consume_token (parser->lexer);  /* Eat '@property'.  */
@@ -35423,10 +35423,6 @@ cp_parser_objc_at_property_declaration (cp_parser 
*parser)
     }
 
   cp_parser_consume_semicolon_at_end_of_statement (parser);
-
-  while (!prop_attr_list.is_empty())
-    delete prop_attr_list.pop ();
-  prop_attr_list.release ();
 }
 
 /* Parse an Objective-C++ @synthesize declaration.  The syntax is:
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index b080259083e..b97dc1f6624 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5774,7 +5774,7 @@ omp_reduction_lookup (location_t loc, tree id, tree type, 
tree *baselinkp,
 
   if (!id && CLASS_TYPE_P (type) && TYPE_BINFO (type))
     {
-      vec<tree> ambiguous = vNULL;
+      auto_vec<tree> ambiguous;
       tree binfo = TYPE_BINFO (type), base_binfo, ret = NULL_TREE;
       unsigned int ix;
       if (ambiguousp == NULL)
@@ -5811,7 +5811,6 @@ omp_reduction_lookup (location_t loc, tree id, tree type, 
tree *baselinkp,
              if (idx == 0)
                str = get_spaces (str);
            }
-         ambiguous.release ();
          ret = error_mark_node;
          baselink = NULL_TREE;
        }

base-commit: b15e301748f0e042379909e32b3ade439dd8f8f9
-- 
2.27.0

Reply via email to