public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] compiling gcc with a C++ compiler 4/n
@ 2007-05-15  7:19 Thomas Neumann
  2007-05-15  7:30 ` Andrew Pinski
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Neumann @ 2007-05-15  7:19 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

:ADDPATCH exception handling:

The attached patch fixes compiling the exception handling logic with a
C++ compiler. It is by far the most invasive patch for full C++
compatibility, as I had to rename members to avoid C++ keywords and
reorganize struct names due to the lack of separate struct namespace in
C++- But the individual changes themselves are trivial, and only 4 files
are affected.

Bootstrapped on i686, testing still running. Ok if it succeeeds?

Thomas


* except.h: Distinguish between struct eh_region_def and eh_region.
* except.c: Likewise.
* tree-eh.c: Likewise.
* tree-cfg.c: Likewise.

* except.c: Move eh_region_type out of struct namespace.Avoid C++
keywords. Use type safe memory macros.
* tree-eh.c: Move goto_queue_node out of struct namespace. Avoid C++
keywords.
* tree-cfg.c: Cast as needed. Use type safe memory macros.

[-- Attachment #2: except.patch --]
[-- Type: text/x-diff, Size: 42367 bytes --]

Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c	(revision 124739)
+++ gcc/tree-eh.c	(working copy)
@@ -83,7 +83,7 @@ struct_ptr_hash (const void *a)
    of space by only allocating memory for those that can throw.  */
 
 static void
-record_stmt_eh_region (struct eh_region *region, tree t)
+record_stmt_eh_region (eh_region region, tree t)
 {
   if (!region)
     return;
@@ -277,8 +277,8 @@ struct leh_state
   /* What's "current" while constructing the eh region tree.  These
      correspond to variables of the same name in cfun->eh, which we
      don't have easy access to.  */
-  struct eh_region *cur_region;
-  struct eh_region *prev_try;
+  eh_region cur_region;
+  eh_region prev_try;
 
   /* Processing of TRY_FINALLY requires a bit more state.  This is
      split out into a separate structure so that we don't have to
@@ -286,6 +286,15 @@ struct leh_state
   struct leh_tf_state *tf;
 };
 
+/* The GOTO_QUEUE is is an array of GOTO_EXPR and RETURN_EXPR statements
+   that are seen to escape this TRY_FINALLY_EXPR node.  */
+struct goto_queue_node {
+  tree stmt;
+  tree repl_stmt;
+  tree cont_stmt;
+  int index;
+};
+
 struct leh_tf_state
 {
   /* Pointer to the TRY_FINALLY node under discussion.  The try_finally_expr
@@ -299,16 +308,11 @@ struct leh_tf_state
   struct leh_state *outer;
 
   /* The exception region created for it.  */
-  struct eh_region *region;
+  eh_region region;
 
   /* The GOTO_QUEUE is is an array of GOTO_EXPR and RETURN_EXPR statements
      that are seen to escape this TRY_FINALLY_EXPR node.  */
-  struct goto_queue_node {
-    tree stmt;
-    tree repl_stmt;
-    tree cont_stmt;
-    int index;
-  } *goto_queue;
+  struct goto_queue_node *goto_queue;
   size_t goto_queue_size;
   size_t goto_queue_active;
 
@@ -373,13 +377,13 @@ static void
 replace_goto_queue_cond_clause (tree *tp, struct leh_tf_state *tf,
 				tree_stmt_iterator *tsi)
 {
-  tree new, one, label;
+  tree new_tree, one, label;
 
-  new = find_goto_replacement (tf, *tp);
-  if (!new)
+  new_tree = find_goto_replacement (tf, *tp);
+  if (!new_tree)
     return;
 
-  one = expr_only (new);
+  one = expr_only (new_tree);
   if (one && TREE_CODE (one) == GOTO_EXPR)
     {
       *tp = one;
@@ -390,7 +394,7 @@ replace_goto_queue_cond_clause (tree *tp
   *tp = build_and_jump (&LABEL_EXPR_LABEL (label));
 
   tsi_link_after (tsi, label, TSI_CONTINUE_LINKING);
-  tsi_link_after (tsi, new, TSI_CONTINUE_LINKING);
+  tsi_link_after (tsi, new_tree, TSI_CONTINUE_LINKING);
 }
 
 /* The real work of replace_goto_queue.  Returns with TSI updated to
@@ -615,7 +619,7 @@ do_return_redirection (struct goto_queue
 	case GIMPLE_MODIFY_STMT:
 	  {
 	    tree result = GIMPLE_STMT_OPERAND (ret_expr, 0);
-	    tree new, old = GIMPLE_STMT_OPERAND (ret_expr, 1);
+	    tree new_tree, old = GIMPLE_STMT_OPERAND (ret_expr, 1);
 
 	    if (!*return_value_p)
 	      {
@@ -626,21 +630,21 @@ do_return_redirection (struct goto_queue
 		    worry about magic return semantics, so we need to use a
 		    temporary to hold the value until we're actually ready
 		    to return.  */
-		  new = result;
+		  new_tree = result;
 		else
-		  new = create_tmp_var (TREE_TYPE (old), "rettmp");
-		*return_value_p = new;
+		  new_tree = create_tmp_var (TREE_TYPE (old), "rettmp");
+		*return_value_p = new_tree;
 	      }
 	    else
-	      new = *return_value_p;
+	      new_tree = *return_value_p;
 
-	    x = build_gimple_modify_stmt (new, old);
+	    x = build_gimple_modify_stmt (new_tree, old);
 	    append_to_statement_list (x, &q->repl_stmt);
 
-	    if (new == result)
+	    if (new_tree == result)
 	      x = result;
 	    else
-	      x = build_gimple_modify_stmt (result, new);
+	      x = build_gimple_modify_stmt (result, new_tree);
 	    q->cont_stmt = build1 (RETURN_EXPR, void_type_node, x);
 	  }
 
@@ -1425,7 +1429,7 @@ lower_try_finally (struct leh_state *sta
 static void
 lower_catch (struct leh_state *state, tree *tp)
 {
-  struct eh_region *try_region;
+  eh_region try_region;
   struct leh_state this_state;
   tree_stmt_iterator i;
   tree out_label;
@@ -1446,15 +1450,15 @@ lower_catch (struct leh_state *state, tr
   out_label = NULL;
   for (i = tsi_start (TREE_OPERAND (*tp, 1)); !tsi_end_p (i); )
     {
-      struct eh_region *catch_region;
-      tree catch, x, eh_label;
+      eh_region catch_region;
+      tree catch_tree, x, eh_label;
 
-      catch = tsi_stmt (i);
-      catch_region = gen_eh_region_catch (try_region, CATCH_TYPES (catch));
+      catch_tree = tsi_stmt (i);
+      catch_region = gen_eh_region_catch (try_region, CATCH_TYPES (catch_tree));
 
       this_state.cur_region = catch_region;
       this_state.prev_try = state->prev_try;
-      lower_eh_constructs_1 (&this_state, &CATCH_BODY (catch));
+      lower_eh_constructs_1 (&this_state, &CATCH_BODY (catch_tree));
 
       eh_label = create_artificial_label ();
       set_eh_region_tree_label (catch_region, eh_label);
@@ -1462,16 +1466,16 @@ lower_catch (struct leh_state *state, tr
       x = build1 (LABEL_EXPR, void_type_node, eh_label);
       tsi_link_before (&i, x, TSI_SAME_STMT);
 
-      if (block_may_fallthru (CATCH_BODY (catch)))
+      if (block_may_fallthru (CATCH_BODY (catch_tree)))
 	{
 	  if (!out_label)
 	    out_label = create_artificial_label ();
 
 	  x = build1 (GOTO_EXPR, void_type_node, out_label);
-	  append_to_statement_list (x, &CATCH_BODY (catch));
+	  append_to_statement_list (x, &CATCH_BODY (catch_tree));
 	}
 
-      tsi_link_before (&i, CATCH_BODY (catch), TSI_SAME_STMT);
+      tsi_link_before (&i, CATCH_BODY (catch_tree), TSI_SAME_STMT);
       tsi_delink (&i);
     }
 
@@ -1486,7 +1490,7 @@ static void
 lower_eh_filter (struct leh_state *state, tree *tp)
 {
   struct leh_state this_state;
-  struct eh_region *this_region;
+  eh_region this_region;
   tree inner = expr_first (TREE_OPERAND (*tp, 1));
   tree eh_label;
 
@@ -1526,7 +1530,7 @@ static void
 lower_cleanup (struct leh_state *state, tree *tp)
 {
   struct leh_state this_state;
-  struct eh_region *this_region;
+  eh_region this_region;
   struct leh_tf_state fake_tf;
 
   /* If not using eh, then exception-only cleanups are no-ops.  */
@@ -1707,7 +1711,7 @@ struct tree_opt_pass pass_lower_eh =
 /* Construct EH edges for STMT.  */
 
 static void
-make_eh_edge (struct eh_region *region, void *data)
+make_eh_edge (eh_region region, void *data)
 {
   tree stmt, lab;
   basic_block src, dst;
@@ -1748,7 +1752,7 @@ static bool mark_eh_edge_found_error;
 /* Mark edge make_eh_edge would create for given region by setting it aux
    field, output error if something goes wrong.  */
 static void
-mark_eh_edge (struct eh_region *region, void *data)
+mark_eh_edge (eh_region region, void *data)
 {
   tree stmt, lab;
   basic_block src, dst;
Index: gcc/except.c
===================================================================
--- gcc/except.c	(revision 124739)
+++ gcc/except.c	(working copy)
@@ -100,7 +100,7 @@ tree (*lang_eh_runtime_type) (tree);
 struct ehl_map_entry GTY(())
 {
   rtx label;
-  struct eh_region *region;
+  struct eh_region_def *region;
 };
 
 static GTY(()) int call_site_base;
@@ -114,16 +114,28 @@ static int sjlj_fc_data_ofs;
 static int sjlj_fc_personality_ofs;
 static int sjlj_fc_lsda_ofs;
 static int sjlj_fc_jbuf_ofs;
+
+/* Each region does exactly one thing.  */
+enum eh_region_type
+{
+  ERT_UNKNOWN = 0,
+  ERT_CLEANUP,
+  ERT_TRY,
+  ERT_CATCH,
+  ERT_ALLOWED_EXCEPTIONS,
+  ERT_MUST_NOT_THROW,
+  ERT_THROW
+};
 \f
 /* Describes one exception region.  */
-struct eh_region GTY(())
+struct eh_region_def GTY(())
 {
   /* The immediately surrounding region.  */
-  struct eh_region *outer;
+  struct eh_region_def *outer;
 
   /* The list of immediately contained regions.  */
-  struct eh_region *inner;
-  struct eh_region *next_peer;
+  struct eh_region_def *inner;
+  struct eh_region_def *next_peer;
 
   /* An identifier for this region.  */
   int region_number;
@@ -133,34 +145,25 @@ struct eh_region GTY(())
   bitmap aka;
 
   /* Each region does exactly one thing.  */
-  enum eh_region_type
-  {
-    ERT_UNKNOWN = 0,
-    ERT_CLEANUP,
-    ERT_TRY,
-    ERT_CATCH,
-    ERT_ALLOWED_EXCEPTIONS,
-    ERT_MUST_NOT_THROW,
-    ERT_THROW
-  } type;
+  enum eh_region_type type;
 
   /* Holds the action to perform based on the preceding type.  */
   union eh_region_u {
     /* A list of catch blocks, a surrounding try block,
        and the label for continuing after a catch.  */
     struct eh_region_u_try {
-      struct eh_region *catch;
-      struct eh_region *last_catch;
-    } GTY ((tag ("ERT_TRY"))) try;
+      struct eh_region_def *current_catch;
+      struct eh_region_def *last_catch;
+    } GTY ((tag ("ERT_TRY"))) try_list;
 
     /* The list through the catch handlers, the list of type objects
        matched, and the list of associated filters.  */
     struct eh_region_u_catch {
-      struct eh_region *next_catch;
-      struct eh_region *prev_catch;
+      struct eh_region_def *next_catch;
+      struct eh_region_def *prev_catch;
       tree type_list;
       tree filter_list;
-    } GTY ((tag ("ERT_CATCH"))) catch;
+    } GTY ((tag ("ERT_CATCH"))) catch_list;
 
     /* A tree_list of allowed types.  */
     struct eh_region_u_allowed {
@@ -172,12 +175,12 @@ struct eh_region GTY(())
        for a throw.  */
     struct eh_region_u_throw {
       tree type;
-    } GTY ((tag ("ERT_THROW"))) throw;
+    } GTY ((tag ("ERT_THROW"))) throw_type;
 
     /* Retain the cleanup expression even after expansion so that
        we can match up fixup regions.  */
     struct eh_region_u_cleanup {
-      struct eh_region *prev_try;
+      struct eh_region_def *prev_try;
     } GTY ((tag ("ERT_CLEANUP"))) cleanup;
   } GTY ((desc ("%0.type"))) u;
 
@@ -199,7 +202,11 @@ struct eh_region GTY(())
   unsigned may_contain_throw : 1;
 };
 
-typedef struct eh_region *eh_region;
+#ifdef __GENGTYPE__
+/* This dummy typdef is required by gengtype which does not handle the
+   forward declaration in except.h */
+typedef struct eh_region_def * eh_region;
+#endif
 
 struct call_site_record GTY(())
 {
@@ -214,16 +221,16 @@ DEF_VEC_ALLOC_P(eh_region, gc);
 struct eh_status GTY(())
 {
   /* The tree of all regions for this function.  */
-  struct eh_region *region_tree;
+  eh_region region_tree;
 
   /* The same information as an indexable array.  */
   VEC(eh_region,gc) *region_array;
 
   /* The most recently open region.  */
-  struct eh_region *cur_region;
+  eh_region cur_region;
 
   /* This is the region for which we are processing catch blocks.  */
-  struct eh_region *try_region;
+  eh_region try_region;
 
   rtx filter;
   rtx exc_ptr;
@@ -281,9 +288,9 @@ static void sjlj_build_landing_pads (voi
 
 static hashval_t ehl_hash (const void *);
 static int ehl_eq (const void *, const void *);
-static void add_ehl_entry (rtx, struct eh_region *);
+static void add_ehl_entry (rtx, eh_region);
 static void remove_exception_handler_label (rtx);
-static void remove_eh_handler (struct eh_region *);
+static void remove_eh_handler (eh_region);
 static int for_each_eh_label_1 (void **, void *);
 
 /* The return value of reachable_next_level.  */
@@ -300,13 +307,13 @@ enum reachable_code
 };
 
 struct reachable_info;
-static enum reachable_code reachable_next_level (struct eh_region *, tree,
+static enum reachable_code reachable_next_level (eh_region, tree,
 						 struct reachable_info *);
 
 static int action_record_eq (const void *, const void *);
 static hashval_t action_record_hash (const void *);
 static int add_action_record (htab_t, int, int);
-static int collect_one_action_chain (htab_t, struct eh_region *);
+static int collect_one_action_chain (htab_t, eh_region);
 static int add_call_site (rtx, int);
 
 static void push_uleb128 (varray_type *, unsigned int);
@@ -438,60 +445,60 @@ init_eh (void)
 void
 init_eh_for_function (void)
 {
-  cfun->eh = ggc_alloc_cleared (sizeof (struct eh_status));
+  cfun->eh = GGC_CNEW (struct eh_status);
 }
 \f
 /* Routines to generate the exception tree somewhat directly.
    These are used from tree-eh.c when processing exception related
    nodes during tree optimization.  */
 
-static struct eh_region *
-gen_eh_region (enum eh_region_type type, struct eh_region *outer)
+static eh_region
+gen_eh_region (enum eh_region_type type, eh_region outer)
 {
-  struct eh_region *new;
+  eh_region new_region;
 
 #ifdef ENABLE_CHECKING
   gcc_assert (doing_eh (0));
 #endif
 
   /* Insert a new blank region as a leaf in the tree.  */
-  new = ggc_alloc_cleared (sizeof (*new));
-  new->type = type;
-  new->outer = outer;
+  new_region = GGC_CNEW (struct eh_region_def);
+  new_region->type = type;
+  new_region->outer = outer;
   if (outer)
     {
-      new->next_peer = outer->inner;
-      outer->inner = new;
+      new_region->next_peer = outer->inner;
+      outer->inner = new_region;
     }
   else
     {
-      new->next_peer = cfun->eh->region_tree;
-      cfun->eh->region_tree = new;
+      new_region->next_peer = cfun->eh->region_tree;
+      cfun->eh->region_tree = new_region;
     }
 
-  new->region_number = ++cfun->eh->last_region_number;
+  new_region->region_number = ++cfun->eh->last_region_number;
 
-  return new;
+  return new_region;
 }
 
-struct eh_region *
-gen_eh_region_cleanup (struct eh_region *outer, struct eh_region *prev_try)
+eh_region
+gen_eh_region_cleanup (eh_region outer, eh_region prev_try)
 {
-  struct eh_region *cleanup = gen_eh_region (ERT_CLEANUP, outer);
+  eh_region cleanup = gen_eh_region (ERT_CLEANUP, outer);
   cleanup->u.cleanup.prev_try = prev_try;
   return cleanup;
 }
 
-struct eh_region *
-gen_eh_region_try (struct eh_region *outer)
+eh_region
+gen_eh_region_try (eh_region outer)
 {
   return gen_eh_region (ERT_TRY, outer);
 }
 
-struct eh_region *
-gen_eh_region_catch (struct eh_region *t, tree type_or_list)
+eh_region
+gen_eh_region_catch (eh_region t, tree type_or_list)
 {
-  struct eh_region *c, *l;
+  eh_region c, l;
   tree type_list, type_node;
 
   /* Ensure to always end up with a type list to normalize further
@@ -508,22 +515,22 @@ gen_eh_region_catch (struct eh_region *t
     }
 
   c = gen_eh_region (ERT_CATCH, t->outer);
-  c->u.catch.type_list = type_list;
-  l = t->u.try.last_catch;
-  c->u.catch.prev_catch = l;
+  c->u.catch_list.type_list = type_list;
+  l = t->u.try_list.last_catch;
+  c->u.catch_list.prev_catch = l;
   if (l)
-    l->u.catch.next_catch = c;
+    l->u.catch_list.next_catch = c;
   else
-    t->u.try.catch = c;
-  t->u.try.last_catch = c;
+    t->u.try_list.current_catch = c;
+  t->u.try_list.last_catch = c;
 
   return c;
 }
 
-struct eh_region *
-gen_eh_region_allowed (struct eh_region *outer, tree allowed)
+eh_region
+gen_eh_region_allowed (eh_region outer, tree allowed)
 {
-  struct eh_region *region = gen_eh_region (ERT_ALLOWED_EXCEPTIONS, outer);
+  eh_region region = gen_eh_region (ERT_ALLOWED_EXCEPTIONS, outer);
   region->u.allowed.type_list = allowed;
 
   for (; allowed ; allowed = TREE_CHAIN (allowed))
@@ -532,32 +539,32 @@ gen_eh_region_allowed (struct eh_region 
   return region;
 }
 
-struct eh_region *
-gen_eh_region_must_not_throw (struct eh_region *outer)
+eh_region
+gen_eh_region_must_not_throw (eh_region outer)
 {
   return gen_eh_region (ERT_MUST_NOT_THROW, outer);
 }
 
 int
-get_eh_region_number (struct eh_region *region)
+get_eh_region_number (eh_region region)
 {
   return region->region_number;
 }
 
 bool
-get_eh_region_may_contain_throw (struct eh_region *region)
+get_eh_region_may_contain_throw (eh_region region)
 {
   return region->may_contain_throw;
 }
 
 tree
-get_eh_region_tree_label (struct eh_region *region)
+get_eh_region_tree_label (eh_region region)
 {
   return region->tree_label;
 }
 
 void
-set_eh_region_tree_label (struct eh_region *region, tree lab)
+set_eh_region_tree_label (eh_region region, tree lab)
 {
   region->tree_label = lab;
 }
@@ -566,8 +573,8 @@ void
 expand_resx_expr (tree exp)
 {
   int region_nr = TREE_INT_CST_LOW (TREE_OPERAND (exp, 0));
-  struct eh_region *reg = VEC_index (eh_region,
-				     cfun->eh->region_array, region_nr);
+  eh_region reg = VEC_index (eh_region,
+			     cfun->eh->region_array, region_nr);
 
   gcc_assert (!reg->resume);
   reg->resume = emit_jump_insn (gen_rtx_RESX (VOIDmode, region_nr));
@@ -578,7 +585,7 @@ expand_resx_expr (tree exp)
    call to a function which itself may contain a throw.  */
 
 void
-note_eh_region_may_contain_throw (struct eh_region *region)
+note_eh_region_may_contain_throw (eh_region region)
 {
   while (region && !region->may_contain_throw)
     {
@@ -631,7 +638,7 @@ get_exception_filter (struct function *f
 void
 collect_eh_region_array (void)
 {
-  struct eh_region *i;
+  eh_region i;
 
   i = cfun->eh->region_tree;
   if (! i)
@@ -671,11 +678,11 @@ remove_unreachable_regions (rtx insns)
 {
   int i, *uid_region_num;
   bool *reachable;
-  struct eh_region *r;
+  eh_region r;
   rtx insn;
 
-  uid_region_num = xcalloc (get_max_uid (), sizeof(int));
-  reachable = xcalloc (cfun->eh->last_region_number + 1, sizeof(bool));
+  uid_region_num = XCNEWVEC (int, get_max_uid ());
+  reachable = XCNEWVEC (bool, cfun->eh->last_region_number + 1);
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
@@ -724,8 +731,9 @@ remove_unreachable_regions (rtx insns)
 	      {
 		/* TRY regions are reachable if any of its CATCH regions
 		   are reachable.  */
-		struct eh_region *c;
-		for (c = r->u.try.catch; c ; c = c->u.catch.next_catch)
+		eh_region c;
+		for (c = r->u.try_list.current_catch; c ;
+		     c = c->u.catch_list.next_catch)
 		  if (reachable[c->region_number])
 		    {
 		      kill_it = false;
@@ -761,7 +769,7 @@ convert_from_eh_region_ranges (void)
      we allocated earlier.  */
   for (i = 1; i <= n; ++i)
     {
-      struct eh_region *region;
+      eh_region region;
 
       region = VEC_index (eh_region, cfun->eh->region_array, i);
       if (region && region->tree_label)
@@ -772,13 +780,13 @@ convert_from_eh_region_ranges (void)
 }
 
 static void
-add_ehl_entry (rtx label, struct eh_region *region)
+add_ehl_entry (rtx label, eh_region region)
 {
   struct ehl_map_entry **slot, *entry;
 
   LABEL_PRESERVE_P (label) = 1;
 
-  entry = ggc_alloc (sizeof (*entry));
+  entry = GGC_NEW (struct ehl_map_entry);
   entry->label = label;
   entry->region = region;
 
@@ -815,7 +823,7 @@ find_exception_handler_labels (void)
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *region;
+      eh_region region;
       rtx lab;
 
       region = VEC_index (eh_region, cfun->eh->region_array, i);
@@ -845,7 +853,7 @@ current_function_has_exception_handlers 
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *region;
+      eh_region region;
 
       region = VEC_index (eh_region, cfun->eh->region_array, i);
       if (region
@@ -885,11 +893,12 @@ duplicate_eh_regions_0 (eh_region o, int
    about the other internal pointers just yet, just the tree-like pointers.  */
 
 static eh_region
-duplicate_eh_regions_1 (eh_region old, eh_region outer, int eh_offset)
+duplicate_eh_regions_1 (eh_region old, eh_region outer,
+			int eh_offset)
 {
   eh_region ret, n;
 
-  ret = n = ggc_alloc (sizeof (struct eh_region));
+  ret = n = GGC_NEW (struct eh_region_def);
 
   *n = *old;
   n->outer = outer;
@@ -1024,17 +1033,17 @@ duplicate_eh_regions (struct function *i
       switch (cur->type)
 	{
 	case ERT_TRY:
-	  if (cur->u.try.catch)
-	    REMAP (cur->u.try.catch);
-	  if (cur->u.try.last_catch)
-	    REMAP (cur->u.try.last_catch);
+	  if (cur->u.try_list.current_catch)
+	    REMAP (cur->u.try_list.current_catch);
+	  if (cur->u.try_list.last_catch)
+	    REMAP (cur->u.try_list.last_catch);
 	  break;
 
 	case ERT_CATCH:
-	  if (cur->u.catch.next_catch)
-	    REMAP (cur->u.catch.next_catch);
-	  if (cur->u.catch.prev_catch)
-	    REMAP (cur->u.catch.prev_catch);
+	  if (cur->u.catch_list.next_catch)
+	    REMAP (cur->u.catch_list.next_catch);
+	  if (cur->u.catch_list.prev_catch)
+	    REMAP (cur->u.catch_list.prev_catch);
 	  break;
 
 	case ERT_CLEANUP:
@@ -1059,7 +1068,7 @@ duplicate_eh_regions (struct function *i
 bool
 eh_region_outer_p (struct function *ifun, int region_a, int region_b)
 {
-  struct eh_region *rp_a, *rp_b;
+  eh_region rp_a, rp_b;
 
   gcc_assert (ifun->eh->last_region_number > 0);
   gcc_assert (ifun->eh->region_tree);
@@ -1086,7 +1095,7 @@ eh_region_outer_p (struct function *ifun
 int
 eh_region_outermost (struct function *ifun, int region_a, int region_b)
 {
-  struct eh_region *rp_a, *rp_b;
+  eh_region rp_a, rp_b;
   sbitmap b_outer;
 
   gcc_assert (ifun->eh->last_region_number > 0);
@@ -1312,7 +1321,7 @@ assign_filter_values (void)
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *r;
+      eh_region r;
 
       r = VEC_index (eh_region, cfun->eh->region_array, i);
 
@@ -1325,21 +1334,21 @@ assign_filter_values (void)
 	case ERT_CATCH:
 	  /* Whatever type_list is (NULL or true list), we build a list
 	     of filters for the region.  */
-	  r->u.catch.filter_list = NULL_TREE;
+	  r->u.catch_list.filter_list = NULL_TREE;
 
-	  if (r->u.catch.type_list != NULL)
+	  if (r->u.catch_list.type_list != NULL)
 	    {
 	      /* Get a filter value for each of the types caught and store
 		 them in the region's dedicated list.  */
-	      tree tp_node = r->u.catch.type_list;
+	      tree tp_node = r->u.catch_list.type_list;
 
 	      for (;tp_node; tp_node = TREE_CHAIN (tp_node))
 		{
 		  int flt = add_ttypes_entry (ttypes, TREE_VALUE (tp_node));
 		  tree flt_node = build_int_cst (NULL_TREE, flt);
 
-		  r->u.catch.filter_list
-		    = tree_cons (NULL_TREE, flt_node, r->u.catch.filter_list);
+		  r->u.catch_list.filter_list
+		    = tree_cons (NULL_TREE, flt_node, r->u.catch_list.filter_list);
 		}
 	    }
 	  else
@@ -1349,8 +1358,8 @@ assign_filter_values (void)
 	      int flt = add_ttypes_entry (ttypes, NULL);
 	      tree flt_node = build_int_cst (NULL_TREE, flt);
 
-	      r->u.catch.filter_list
-		= tree_cons (NULL_TREE, flt_node, r->u.catch.filter_list);
+	      r->u.catch_list.filter_list
+		= tree_cons (NULL_TREE, flt_node, r->u.catch_list.filter_list);
 	    }
 
 	  break;
@@ -1407,7 +1416,7 @@ build_post_landing_pads (void)
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *region;
+      eh_region region;
       rtx seq;
 
       region = VEC_index (eh_region, cfun->eh->region_array, i);
@@ -1434,18 +1443,19 @@ build_post_landing_pads (void)
 	     switch statement generation code in expand_end_case.
 	     Rapid prototyping sez a sequence of ifs.  */
 	  {
-	    struct eh_region *c;
-	    for (c = region->u.try.catch; c ; c = c->u.catch.next_catch)
+	    eh_region c;
+	    for (c = region->u.try_list.current_catch; c ;
+		 c = c->u.catch_list.next_catch)
 	      {
-		if (c->u.catch.type_list == NULL)
+		if (c->u.catch_list.type_list == NULL)
 		  emit_jump (c->label);
 		else
 		  {
 		    /* Need for one cmp/jump per type caught. Each type
 		       list entry has a matching entry in the filter list
 		       (see assign_filter_values).  */
-		    tree tp_node = c->u.catch.type_list;
-		    tree flt_node = c->u.catch.filter_list;
+		    tree tp_node = c->u.catch_list.type_list;
+		    tree flt_node = c->u.catch_list.filter_list;
 
 		    for (; tp_node; )
 		      {
@@ -1472,7 +1482,7 @@ build_post_landing_pads (void)
 	  seq = get_insns ();
 	  end_sequence ();
 
-	  emit_to_new_bb_before (seq, region->u.try.catch->label);
+	  emit_to_new_bb_before (seq, region->u.try_list.current_catch->label);
 
 	  break;
 
@@ -1527,8 +1537,8 @@ connect_post_landing_pads (void)
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *region;
-      struct eh_region *outer;
+      eh_region region;
+      eh_region outer;
       rtx seq;
       rtx barrier;
 
@@ -1604,7 +1614,7 @@ dw2_build_landing_pads (void)
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
-      struct eh_region *region;
+      eh_region region;
       rtx seq;
       basic_block bb;
       edge e;
@@ -1669,7 +1679,7 @@ sjlj_find_directly_reachable_regions (st
 
   for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
     {
-      struct eh_region *region;
+      eh_region region;
       enum reachable_code rc;
       tree type_thrown;
       rtx note;
@@ -1686,7 +1696,7 @@ sjlj_find_directly_reachable_regions (st
       type_thrown = NULL_TREE;
       if (region->type == ERT_THROW)
 	{
-	  type_thrown = region->u.throw.type;
+	  type_thrown = region->u.throw_type.type;
 	  region = region->outer;
 	}
 
@@ -1723,7 +1733,7 @@ sjlj_assign_call_site_values (rtx dispat
   for (i = cfun->eh->last_region_number; i > 0; --i)
     if (lp_info[i].directly_reachable)
       {
-	struct eh_region *r = VEC_index (eh_region, cfun->eh->region_array, i);
+	eh_region r = VEC_index (eh_region, cfun->eh->region_array, i);
 
 	r->landing_pad = dispatch_label;
 	lp_info[i].action_index = collect_one_action_chain (ar_hash, r);
@@ -1780,7 +1790,7 @@ sjlj_mark_call_sites (struct sjlj_lp_inf
 
   for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
     {
-      struct eh_region *region;
+      eh_region region;
       int this_call_site;
       rtx note, before, p;
 
@@ -2021,14 +2031,14 @@ sjlj_emit_dispatch_table (rtx dispatch_l
 
       emit_cmp_and_jump_insns (dispatch, GEN_INT (lp_info[i].dispatch_index),
 			       EQ, NULL_RTX, TYPE_MODE (integer_type_node), 0,
-	                       ((struct eh_region *)VEC_index (eh_region, cfun->eh->region_array, i))
+	                       ((eh_region)VEC_index (eh_region, cfun->eh->region_array, i))
 				->post_landing_pad);
     }
 
   seq = get_insns ();
   end_sequence ();
 
-  before = (((struct eh_region *)VEC_index (eh_region, cfun->eh->region_array, first_reachable))
+  before = (((eh_region)VEC_index (eh_region, cfun->eh->region_array, first_reachable))
 	    ->post_landing_pad);
 
   bb = emit_to_new_bb_before (seq, before);
@@ -2168,9 +2178,9 @@ remove_exception_handler_label (rtx labe
 /* Splice REGION from the region tree etc.  */
 
 static void
-remove_eh_handler (struct eh_region *region)
+remove_eh_handler (eh_region region)
 {
-  struct eh_region **pp, **pp_start, *p, *outer, *inner;
+  eh_region *pp, *pp_start, p, outer, inner;
   rtx lab;
 
   /* For the benefit of efficiently handling REG_EH_REGION notes,
@@ -2229,28 +2239,28 @@ remove_eh_handler (struct eh_region *reg
 
   if (region->type == ERT_CATCH)
     {
-      struct eh_region *try, *next, *prev;
+      eh_region try_region, next, prev;
 
-      for (try = region->next_peer;
-	   try->type == ERT_CATCH;
-	   try = try->next_peer)
+      for (try_region = region->next_peer;
+	   try_region->type == ERT_CATCH;
+	   try_region = try_region->next_peer)
 	continue;
-      gcc_assert (try->type == ERT_TRY);
+      gcc_assert (try_region->type == ERT_TRY);
 
-      next = region->u.catch.next_catch;
-      prev = region->u.catch.prev_catch;
+      next = region->u.catch_list.next_catch;
+      prev = region->u.catch_list.prev_catch;
 
       if (next)
-	next->u.catch.prev_catch = prev;
+	next->u.catch_list.prev_catch = prev;
       else
-	try->u.try.last_catch = prev;
+	try_region->u.try_list.last_catch = prev;
       if (prev)
-	prev->u.catch.next_catch = next;
+	prev->u.catch_list.next_catch = next;
       else
 	{
-	  try->u.try.catch = next;
+	  try_region->u.try_list.current_catch = next;
 	  if (! next)
-	    remove_eh_handler (try);
+	    remove_eh_handler (try_region);
 	}
     }
 }
@@ -2263,7 +2273,7 @@ void
 maybe_remove_eh_handler (rtx label)
 {
   struct ehl_map_entry **slot, tmp;
-  struct eh_region *region;
+  eh_region region;
 
   /* ??? After generating landing pads, it's not so simple to determine
      if the region data is completely unused.  One must examine the
@@ -2317,12 +2327,12 @@ for_each_eh_label_1 (void **pentry, void
 /* Invoke CALLBACK for every exception region in the current function.  */
 
 void
-for_each_eh_region (void (*callback) (struct eh_region *))
+for_each_eh_region (void (*callback) (eh_region))
 {
   int i, n = cfun->eh->last_region_number;
   for (i = 1; i <= n; ++i)
     {
-      struct eh_region *region;
+      eh_region region;
 
       region = VEC_index (eh_region, cfun->eh->region_array, i);
       if (region)
@@ -2337,7 +2347,7 @@ struct reachable_info
 {
   tree types_caught;
   tree types_allowed;
-  void (*callback) (struct eh_region *, void *);
+  void (*callback) (eh_region, void *);
   void *callback_data;
   bool saw_any_handlers;
 };
@@ -2377,7 +2387,7 @@ check_handled (tree handled, tree type)
 
 static void
 add_reachable_handler (struct reachable_info *info,
-		       struct eh_region *lp_region, struct eh_region *region)
+		       eh_region lp_region, eh_region region)
 {
   if (! info)
     return;
@@ -2396,7 +2406,7 @@ add_reachable_handler (struct reachable_
    and caught/allowed type information between invocations.  */
 
 static enum reachable_code
-reachable_next_level (struct eh_region *region, tree type_thrown,
+reachable_next_level (eh_region region, tree type_thrown,
 		      struct reachable_info *info)
 {
   switch (region->type)
@@ -2410,13 +2420,14 @@ reachable_next_level (struct eh_region *
 
     case ERT_TRY:
       {
-	struct eh_region *c;
+	eh_region c;
 	enum reachable_code ret = RNL_NOT_CAUGHT;
 
-	for (c = region->u.try.catch; c ; c = c->u.catch.next_catch)
+	for (c = region->u.try_list.current_catch; c ;
+	     c = c->u.catch_list.next_catch)
 	  {
 	    /* A catch-all handler ends the search.  */
-	    if (c->u.catch.type_list == NULL)
+	    if (c->u.catch_list.type_list == NULL)
 	      {
 		add_reachable_handler (info, region, c);
 		return RNL_CAUGHT;
@@ -2425,7 +2436,7 @@ reachable_next_level (struct eh_region *
 	    if (type_thrown)
 	      {
 		/* If we have at least one type match, end the search.  */
-		tree tp_node = c->u.catch.type_list;
+		tree tp_node = c->u.catch_list.type_list;
 
 		for (; tp_node; tp_node = TREE_CHAIN (tp_node))
 		  {
@@ -2463,7 +2474,7 @@ reachable_next_level (struct eh_region *
 	      ret = RNL_MAYBE_CAUGHT;
 	    else
 	      {
-		tree tp_node = c->u.catch.type_list;
+		tree tp_node = c->u.catch_list.type_list;
 		bool maybe_reachable = false;
 
 		/* Compute the potential reachability of this handler and
@@ -2563,11 +2574,11 @@ reachable_next_level (struct eh_region *
 
 void
 foreach_reachable_handler (int region_number, bool is_resx,
-			   void (*callback) (struct eh_region *, void *),
+			   void (*callback) (eh_region , void *),
 			   void *callback_data)
 {
   struct reachable_info info;
-  struct eh_region *region;
+  eh_region region;
   tree type_thrown;
 
   memset (&info, 0, sizeof (info));
@@ -2587,7 +2598,7 @@ foreach_reachable_handler (int region_nu
     }
   else if (region->type == ERT_THROW)
     {
-      type_thrown = region->u.throw.type;
+      type_thrown = region->u.throw_type.type;
       region = region->outer;
     }
 
@@ -2610,17 +2621,17 @@ foreach_reachable_handler (int region_nu
    reached by a given insn.  */
 
 static void
-arh_to_landing_pad (struct eh_region *region, void *data)
+arh_to_landing_pad (eh_region region, void *data)
 {
-  rtx *p_handlers = data;
+  rtx *p_handlers = (rtx *) data;
   if (! *p_handlers)
     *p_handlers = alloc_INSN_LIST (region->landing_pad, NULL_RTX);
 }
 
 static void
-arh_to_label (struct eh_region *region, void *data)
+arh_to_label (eh_region region, void *data)
 {
-  rtx *p_handlers = data;
+  rtx *p_handlers = (rtx *) data;
   *p_handlers = alloc_INSN_LIST (region->label, *p_handlers);
 }
 
@@ -2660,7 +2671,7 @@ reachable_handlers (rtx insn)
 bool
 can_throw_internal_1 (int region_number, bool is_resx)
 {
-  struct eh_region *region;
+  eh_region region;
   tree type_thrown;
 
   region = VEC_index (eh_region, cfun->eh->region_array, region_number);
@@ -2670,7 +2681,7 @@ can_throw_internal_1 (int region_number,
     region = region->outer;
   else if (region->type == ERT_THROW)
     {
-      type_thrown = region->u.throw.type;
+      type_thrown = region->u.throw_type.type;
       region = region->outer;
     }
 
@@ -2720,7 +2731,7 @@ can_throw_internal (rtx insn)
 bool
 can_throw_external_1 (int region_number, bool is_resx)
 {
-  struct eh_region *region;
+  eh_region region;
   tree type_thrown;
 
   region = VEC_index (eh_region, cfun->eh->region_array, region_number);
@@ -2730,7 +2741,7 @@ can_throw_external_1 (int region_number,
     region = region->outer;
   else if (region->type == ERT_THROW)
     {
-      type_thrown = region->u.throw.type;
+      type_thrown = region->u.throw_type.type;
       region = region->outer;
     }
 
@@ -3070,19 +3081,19 @@ action_record_hash (const void *pentry)
 static int
 add_action_record (htab_t ar_hash, int filter, int next)
 {
-  struct action_record **slot, *new, tmp;
+  struct action_record **slot, *new_record, tmp;
 
   tmp.filter = filter;
   tmp.next = next;
   slot = (struct action_record **) htab_find_slot (ar_hash, &tmp, INSERT);
 
-  if ((new = *slot) == NULL)
+  if ((new_record = *slot) == NULL)
     {
-      new = xmalloc (sizeof (*new));
-      new->offset = VARRAY_ACTIVE_SIZE (cfun->eh->action_record_data) + 1;
-      new->filter = filter;
-      new->next = next;
-      *slot = new;
+      new_record = XNEW (struct action_record);
+      new_record->offset = VARRAY_ACTIVE_SIZE (cfun->eh->action_record_data) + 1;
+      new_record->filter = filter;
+      new_record->next = next;
+      *slot = new_record;
 
       /* The filter value goes in untouched.  The link to the next
 	 record is a "self-relative" byte offset, or zero to indicate
@@ -3095,13 +3106,13 @@ add_action_record (htab_t ar_hash, int f
       push_sleb128 (&cfun->eh->action_record_data, next);
     }
 
-  return new->offset;
+  return new_record->offset;
 }
 
 static int
-collect_one_action_chain (htab_t ar_hash, struct eh_region *region)
+collect_one_action_chain (htab_t ar_hash, eh_region region)
 {
-  struct eh_region *c;
+  eh_region c;
   int next;
 
   /* If we've reached the top of the region chain, then we have
@@ -3132,14 +3143,15 @@ collect_one_action_chain (htab_t ar_hash
 	 search outer regions.  Use a magic -3 value to record
 	 that we haven't done the outer search.  */
       next = -3;
-      for (c = region->u.try.last_catch; c ; c = c->u.catch.prev_catch)
+      for (c = region->u.try_list.last_catch; c ;
+	   c = c->u.catch_list.prev_catch)
 	{
-	  if (c->u.catch.type_list == NULL)
+	  if (c->u.catch_list.type_list == NULL)
 	    {
 	      /* Retrieve the filter from the head of the filter list
 		 where we have stored it (see assign_filter_values).  */
 	      int filter
-		= TREE_INT_CST_LOW (TREE_VALUE (c->u.catch.filter_list));
+		= TREE_INT_CST_LOW (TREE_VALUE (c->u.catch_list.filter_list));
 
 	      next = add_action_record (ar_hash, filter, 0);
 	    }
@@ -3164,7 +3176,7 @@ collect_one_action_chain (htab_t ar_hash
 		    next = add_action_record (ar_hash, 0, 0);
 		}
 
-	      flt_node = c->u.catch.filter_list;
+	      flt_node = c->u.catch_list.filter_list;
 	      for (; flt_node; flt_node = TREE_CHAIN (flt_node))
 		{
 		  int filter = TREE_INT_CST_LOW (TREE_VALUE (flt_node));
@@ -3219,7 +3231,7 @@ add_call_site (rtx landing_pad, int acti
   if (used >= size)
     {
       size = (size ? size * 2 : 64);
-      data = ggc_realloc (data, sizeof (*data) * size);
+      data = GGC_RESIZEVEC (struct call_site_record, data, size);
       cfun->eh->call_site_data = data;
       cfun->eh->call_site_data_size = size;
     }
@@ -3257,7 +3269,7 @@ convert_to_eh_region_ranges (void)
   for (iter = get_insns (); iter ; iter = NEXT_INSN (iter))
     if (INSN_P (iter))
       {
-	struct eh_region *region;
+	eh_region region;
 	int this_action;
 	rtx this_landing_pad;
 
@@ -3301,7 +3313,7 @@ convert_to_eh_region_ranges (void)
 	   landing pads.  Collect the landing pad for this region.  */
 	if (this_action >= 0)
 	  {
-	    struct eh_region *o;
+	    eh_region o;
 	    for (o = region; ! o->landing_pad ; o = o->outer)
 	      continue;
 	    this_landing_pad = o->landing_pad;
@@ -3552,7 +3564,7 @@ switch_to_exception_section (const char 
 #ifdef HAVE_LD_EH_GC_SECTIONS
 	  if (flag_function_sections)
 	    {
-	      char *section_name = xmalloc (strlen (fnname) + 32);
+	      char *section_name = XNEWVEC (char, strlen (fnname) + 32);
 	      sprintf (section_name, ".gcc_except_table.%s", fnname);
 	      s = get_section (section_name, flags, NULL);
 	      free (section_name);
@@ -3580,7 +3592,7 @@ static void
 output_ttype (tree type, int tt_format, int tt_format_size)
 {
   rtx value;
-  bool public = true;
+  bool public_symbol = true;
 
   if (type == NULL_TREE)
     value = const0_rtx;
@@ -3603,7 +3615,7 @@ output_ttype (tree type, int tt_format, 
 	      node = varpool_node (type);
 	      if (node)
 		varpool_mark_needed_node (node);
-	      public = TREE_PUBLIC (type);
+	      public_symbol = TREE_PUBLIC (type);
 	    }
 	}
       else
@@ -3618,7 +3630,7 @@ output_ttype (tree type, int tt_format, 
     assemble_integer (value, tt_format_size,
 		      tt_format_size * BITS_PER_UNIT, 1);
   else
-    dw2_asm_output_encoded_addr_rtx (tt_format, value, public, NULL);
+    dw2_asm_output_encoded_addr_rtx (tt_format, value, public_symbol, NULL);
 }
 
 void
@@ -3826,7 +3838,7 @@ get_eh_throw_stmt_table (struct function
 void
 dump_eh_tree (FILE *out, struct function *fun)
 {
-  struct eh_region *i;
+  eh_region i;
   int depth = 0;
   static const char * const type_name[] = {"unknown", "cleanup", "try", "catch",
 					   "allowed_exceptions", "must_not_throw",
@@ -3872,7 +3884,7 @@ dump_eh_tree (FILE *out, struct function
 void
 verify_eh_tree (struct function *fun)
 {
-  struct eh_region *i, *outer = NULL;
+  eh_region i, outer = NULL;
   bool err = false;
   int nvisited = 0;
   int count = 0;
Index: gcc/except.h
===================================================================
--- gcc/except.h	(revision 124739)
+++ gcc/except.h	(working copy)
@@ -28,14 +28,17 @@ struct function;
 struct eh_status;
 
 /* Internal structure describing a region.  */
-struct eh_region;
+struct eh_region_def;
+
+/** Pointer to a region */
+typedef struct eh_region_def* eh_region;
 
 /* Test: is exception handling turned on?  */
 extern int doing_eh (int);
 
 /* Note that the current EH region (if any) may contain a throw, or a
    call to a function which itself may contain a throw.  */
-extern void note_eh_region_may_contain_throw (struct eh_region *);
+extern void note_eh_region_may_contain_throw (eh_region);
 extern void note_current_region_may_contain_throw (void);
 
 /* Invokes CALLBACK for every exception handler label.  Only used by old
@@ -43,7 +46,7 @@ extern void note_current_region_may_cont
 extern void for_each_eh_label (void (*) (rtx));
 
 /* Invokes CALLBACK for every exception region in the current function.  */
-extern void for_each_eh_region (void (*) (struct eh_region *));
+extern void for_each_eh_region (void (*) (eh_region));
 
 /* Determine if the given INSN can throw an exception.  */
 extern bool can_throw_internal_1 (int, bool);
@@ -88,19 +91,19 @@ extern int duplicate_eh_regions (struct 
 extern void sjlj_emit_function_exit_after (rtx);
 extern void default_init_unwind_resume_libfunc (void);
 
-extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
-						struct eh_region *);
-extern struct eh_region *gen_eh_region_try (struct eh_region *);
-extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
-extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
-extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
-extern int get_eh_region_number (struct eh_region *);
-extern bool get_eh_region_may_contain_throw (struct eh_region *);
-extern tree get_eh_region_tree_label (struct eh_region *);
-extern void set_eh_region_tree_label (struct eh_region *, tree);
+extern eh_region gen_eh_region_cleanup (eh_region,
+					eh_region);
+extern eh_region gen_eh_region_try (eh_region);
+extern eh_region gen_eh_region_catch (eh_region, tree);
+extern eh_region gen_eh_region_allowed (eh_region, tree);
+extern eh_region gen_eh_region_must_not_throw (eh_region);
+extern int get_eh_region_number (eh_region);
+extern bool get_eh_region_may_contain_throw (eh_region);
+extern tree get_eh_region_tree_label (eh_region);
+extern void set_eh_region_tree_label (eh_region, tree);
 
 extern void foreach_reachable_handler (int, bool,
-				       void (*) (struct eh_region *, void *),
+				       void (*) (eh_region, void *),
 				       void *);
 
 extern void collect_eh_region_array (void);
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 124739)
+++ gcc/tree-cfg.c	(working copy)
@@ -847,7 +847,7 @@ static struct label_record
 
 /* Callback for for_each_eh_region.  Helper for cleanup_dead_labels.  */
 static void
-update_eh_label (struct eh_region *region)
+update_eh_label (eh_region region)
 {
   tree old_label = get_eh_region_tree_label (region);
   if (old_label)
@@ -2726,7 +2726,7 @@ bsi_insert_before (block_stmt_iterator *
 {
   set_bb_for_stmt (t, i->bb);
   update_modified_stmts (t);
-  tsi_link_before (&i->tsi, t, m);
+  tsi_link_before (&i->tsi, t, (enum tsi_iterator_update) m);
 }
 
 
@@ -2739,7 +2739,7 @@ bsi_insert_after (block_stmt_iterator *i
 {
   set_bb_for_stmt (t, i->bb);
   update_modified_stmts (t);
-  tsi_link_after (&i->tsi, t, m);
+  tsi_link_after (&i->tsi, t, (enum tsi_iterator_update) m);
 }
 
 
@@ -4538,7 +4538,9 @@ move_stmt_r (tree *tp, int *walk_subtree
 	    {
 	      struct tree_map in, *out;
 	      in.base.from = t;
-	      out = htab_find_with_hash (p->new_label_map, &in, DECL_UID (t));
+	      out = (struct tree_map *) htab_find_with_hash (p->new_label_map,
+							     &in,
+							     DECL_UID (t));
 	      if (out)
 		*tp = t = out->to;
 	    }
@@ -4727,7 +4729,7 @@ new_label_mapper (tree decl, void *data)
 
   gcc_assert (TREE_CODE (decl) == LABEL_DECL);
 
-  m = xmalloc (sizeof (struct tree_map));
+  m = XNEW (struct tree_map);
   m->hash = DECL_UID (decl);
   m->base.from = decl;
   m->to = create_artificial_label ();

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15  7:19 [PATCH] compiling gcc with a C++ compiler 4/n Thomas Neumann
@ 2007-05-15  7:30 ` Andrew Pinski
  2007-05-15  7:46   ` Thomas Neumann
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Pinski @ 2007-05-15  7:30 UTC (permalink / raw)
  To: Thomas Neumann; +Cc: gcc-patches

On 5/15/07, Thomas Neumann <tneumann@users.sourceforge.net> wrote:
> :ADDPATCH exception handling:
>
> The attached patch fixes compiling the exception handling logic with a
> C++ compiler. It is by far the most invasive patch for full C++
> compatibility, as I had to rename members to avoid C++ keywords and
> reorganize struct names due to the lack of separate struct namespace in
> C++- But the individual changes themselves are trivial, and only 4 files
> are affected.

I don't see why you are doing:
-typedef struct eh_region *eh_region;

+typedef struct eh_region_def * eh_region;

In fact, you the code worse to read as you used:
#ifdef __GENGTYPE__

why not change the typedef to be en_region_ptr instead?  It gets
around the need for this hackery and the amount of changes you are
doing.  Also by the way you need to list all the functions you are
changing.  And say more of what you are doing in your changelog
entries because right now they are lacking and not to what the coding
style says they should be.


Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15  7:30 ` Andrew Pinski
@ 2007-05-15  7:46   ` Thomas Neumann
  2007-05-15  8:05     ` Andrew Pinski
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Neumann @ 2007-05-15  7:46 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

Hi,

> I don't see why you are doing:
> -typedef struct eh_region *eh_region;
>
> +typedef struct eh_region_def * eh_region;
the old typedef created one eh_region type (a struct) in the struct
namespace, and a different eh_region type (a pointer to a struct) in the
global namespace. This is unfortunately not valid C++. So I had to
rename either the struct or the pointer to the struct.

I renamed the struct, as I thought the pointer would be the proper
outside representation (i.e. users of the exception handling logic do
not care about the struct). By looking at the code I think this is right
(forward declaration only plus typedef in header), only that most code
did not use the typedef to begin with... But of course I can rename the
typedef and keep the struct if you prefer.


> In fact, you the code worse to read as you used:
> #ifdef __GENGTYPE__
this is true, and indeed an ugly piece of code. Strictly speaking a
limitation of gengtype (as the proper typedef is in the header), but I
am open to suggestions to eliminate it. Unfortunately this does not seem
to be simple:

> why not change the typedef to be en_region_ptr instead?  It gets
> around the need for this hackery and the amount of changes you are
> doing.
Renaming the typedef does not solve the problem, I think. Of course you
will know better, but I thought the issue is that the typedef is on a
forward-declaration of a struct, which is then defined later. Perhaps I
misunderstood the gengtype output, though, I can try to the other way if
you think it works.


> Also by the way you need to list all the functions you are
> changing.  And say more of what you are doing in your changelog
> entries because right now they are lacking and not to what the coding
> style says they should be.
sorry for this, I only submit patches since a few days... Could you be a
bit more specific about what I should write? I interpreted the FSF
instructions such that:
- if a changes is all over the place (renaming a member e.g.) you just
write "func:c: What did I change"
- if it is indeed limited to a function you write "func.c (func): What
did I change in the func".

Or do you mean that "Cast as needed" etc. is too generic? I will write
as detailed descriptions as you like, but I thought that explaining the
reasons for obvious casts was not really helpful.


Thomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15  7:46   ` Thomas Neumann
@ 2007-05-15  8:05     ` Andrew Pinski
  2007-05-15 10:39       ` Thomas Neumann
  2007-05-15 11:50       ` Joseph S. Myers
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Pinski @ 2007-05-15  8:05 UTC (permalink / raw)
  To: Thomas Neumann; +Cc: gcc-patches

On 5/15/07, Thomas Neumann <tneumann@users.sourceforge.net> wrote:
>
> > Also by the way you need to list all the functions you are
> > changing.  And say more of what you are doing in your changelog
> > entries because right now they are lacking and not to what the coding
> > style says they should be.
> sorry for this, I only submit patches since a few days... Could you be a
> bit more specific about what I should write? I interpreted the FSF
> instructions such that:
> - if a changes is all over the place (renaming a member e.g.) you just
> write "func:c: What did I change"

Nobody does that ever really.  An example of where (yes it was mine)
something used all over the place changed the name can be found in
ChangeLog-2006:
2006-12-12  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/28436
        * tree.h (DECL_COMPLEX_GIMPLE_REG_P): Rename to ...
        (DECL_GIMPLE_REG_P): This.
        * fold-const.c (fold_indirect_ref_1): Fold *(foo *)&vectorfoo into
        using BIT_FIELD_REF.
        * omp-low.c (omp_copy_decl_2): Use the renamed DECL_GIMPLE_REG_P.
        * tree-gimple.c (is_gimple_reg): Use the renamed DECL_GIMPLE_REG_P
        and check for VECTOR_TYPE.
....
        * gimplify.c (internal_get_tmp_var): Use the renamed DECL_GIMPLE_REG_P
        and check for VECTOR_TYPE.
        (gimplify_bind_expr): Likewise.
        (gimplify_function_tree): Likewise.

You can use likewise if needed to make the changeLog a little shorter.
The only time I know of a "toplevel" changelog entry is when you are
changing includes.
Another example can be found with "2006-12-10  Andrew MacLeod
<amacleod@redhat.com>".

> - if it is indeed limited to a function you write "func.c (func): What
> did I change in the func".
If this was true then the changelogs in GCC would be much smaller than they are.


> Or do you mean that "Cast as needed" etc. is too generic? I will write
> as detailed descriptions as you like, but I thought that explaining the
> reasons for obvious casts was not really helpful.

Both.  I would take a look at the existing changelogs.  A better entry
for "Cast as needed" would be "Add casts for coding style."  Plus the
entries should always be full sentences.


>Bootstrapped on i686, testing still running. Ok if it succeeeds?
Don't send out patches until they are fully tested, it just wastes
time on both your part and the reviewer's part.


Oh and double checking you have your copyright assignment in place right?

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15  8:05     ` Andrew Pinski
@ 2007-05-15 10:39       ` Thomas Neumann
  2007-05-19 13:33         ` Gerald Pfeifer
  2007-05-15 11:50       ` Joseph S. Myers
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Neumann @ 2007-05-15 10:39 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

> Don't send out patches until they are fully tested, it just wastes
> time on both your part and the reviewer's part.
ok, I will do that. As finished now (on i686), I will give the ChangeLog
entry another try below.

> Oh and double checking you have your copyright assignment in place right?
hm, I do not know how to "double check". I looked at my copy of the
papers signed by me and the FSF (Peter Brown) again, if that is what you
mean. Only someone with a gnu.org account can double check my
assignment, I think.

Here is a new attempt of a change log entry, still for my original patch
(i.e. renaming struct eh_region etc.).

Thomas

* tree-eh.c (record_stmt_eh_region): Use the eh_region typedef instead
of the internal struct.
(struct leh_state): Likewise.
(struct goto_queue_node): Move out of...
(struct leh_tf_state). ... here to avoid struct scope. Use the eh_region
typedef instead of the internal struct.
(replace_goto_queue_cond_clause): Avoid using C++ keywords as variable
names.
(do_return_redirection): Likewise.
(lower_catch): Use the eh_region typedef instead of the internal struct.
Avoid using C++ keywords as variable names.
(lower_eh_filter): Use the eh_region typedef instead of the internal struct.
(lower_eh_cleanup): Likewise.
(make_eh_edge): Likewise.
(mark_eh_edge): Likewise.
* except.c (struct ehl_map_entry): Renamed struct eh_region into struct
eh_region_def.
(enum eh_region_type): Moved out of...
(struct eh_region_def): ... here to avoid struct scope. Renamed struct
eh_region into struct eh_region_def to avoid name collisions in C++.
Renamed struct memembers to avoid C++ keywords.
(after struct eh_region_def): Added an additional typedef for eh_region
for gengtype that did not got the forward in except.h.
(struct call_site_record): Use the eh_region typedef instead of the
internal struct.
(add_ehl_entry): Likewise.
(remove_eh_handler): Likewise.
(reachable_next_level): Likewise.
(collect_one_action_chain): Likewise.
(init_eh_for_function): Use type safe memory macros.
(gen_eh_region). Likewise. Use the eh_region typedef instead of the
internal struct. Avoid using C++ keywords as variable names.
(gen_eh_region_cleanup): Use the eh_region typedef instead of the
internal struct.
(gen_eh_region_try): Likewise.
(gen_eh_region_catch): Likewise. Use renamed members to avoid C++ keywords.
(gen_eh_region_allowed): Use the eh_region typedef instead of the
internal struct.
(gen_eh_region_must_not_thow): Likewise.
(gen_eh_region_number): Likewise.
(gen_eh_region_may_contain_throw): Likewise.
(gen_eh_region_tree_label): Likewise.
(set_eh_region_tree_label): Likewise.
(expand_resc_expr): Likewise.
(note_eh_region_may_contain_throw): Likewise.
(collect_eh_region_array): Likewise.
(remove_unreachable_regions): Likewise. Use type safe memory macros. USe
renamed members to avoid C++ keywords.
(convert_from_eh_region_ranges): Use the eh_region typedef instead of
the internal struct.
(add_ehl_entry): Likewise. Use type safe memory macros.
(find_exception_handler_labels): Use the eh_region typedef instead of
the internal struct.
(current_function_has_exception_handlers): Likewise.
(duplicate_eh_regions_1): Use type safe memory macros. Use renamed
members to avoid C++ keywords.
(eh_region_outer_p): Use type safe memory macros.
(eh_region_outermost): Use the eh_region typedef instead of the internal
struct.
(assign_filtr_values): Likewise. Use renamed members to avoid C++ keywords.
(build_post_landing_pads): Likewise.
(connect_post_landing_pads): Use the eh_region typedef instead of the
internal struct.
(dw_build_landing_pads): Likewise.
(sjlj_find_directly_reachable_regions): Likewise. Use renamed members to
avoid C++ keywords.
(sjlj_assign_call_site_values): Use the eh_region typedef instead of the
internal struct.
(sjlj_mark_call_sites): Likewise.
(sjlj_emit_dispatch_table): Likewise.
(remove_eh_handler): Likewise. Use renamed members to avoid C++ keywords.
(maybe_remove_eh_handler): Use the eh_region typedef instead of the
internal struct.
(for_each_eh_region): Likewise.
(struct reachable_info): Likewise.
(add_reachable_handler): Likewise.
(reachable_next_level): Likewise. Use renamed members to avoid C++ keywords.
(foreach_reachable_handler): Use the eh_region typedef instead of the
internal struct.
(arh_to_landing_pad): Likewise. Cast according to the coding conventions.
(arh_to_label): Likewise.
(can_throw_internal_1): Use the eh_region typedef instead of the
internal struct. Use renamed members to avoid C++ keywords.
(can_throw_external_1): Likewise.
(add_actioNrecord): Avoid using C++ keywords as variable names. Use
typesafe memory macros.
(collect_one_action_chain): Use the eh_region typedef instead of the
internal struct. Use renamed members to avoid C++ keywords.
(add_call_site): Use typesafe memory macros.
(convert_to_eh_region_ranges): Use the eh_region typedef instead of the
internal struct.
(switch_to_exception_section): Use typesafe memory macros.
(output_ttype): Avoid using C++ keywords as variable names.
(get_eh_throw_stmt_table): Use the eh_region typedef instead of the
internal struct.
(dump_eh_tree): Likewise.
(verify_eh_tree): Likewise.
* except.h (struct eh_region): Renamed to eh_region_def, to avoid a
collision with...
(typedef eh_region): ... the eh_region typedef. Moved here from except.c
to consistently use the typedef as opaque data type.
(note_eh_region_may_contain_throw): Use the eh_region typedef instead of
the internal struct.
(for_each_eh_region): Likewise.
(gen_eh_region_cleanup): Likewise.
(gen_eh_region_try): Likewise.
(gen_eh_region_catch): Likewise.
(gen_eh_region_allowed): Likewise.
(gen_eh_region_must_not_throw): Likewise.
(get_eh_region_number): Likewise.
(get_eh_region_may_contain_throw): Likewise.
(get_eh_region_tree_label): Likewise.
(set_eh_region_tree_label): Likewise.
(foreach_reachable_handler): Likewise.
* tree-cfg.c (update_eh_label): Use the eh_region typedef instead of the
internal struct. Cast according to the coding conventions.
(bsi_insert_after): Cast according to the coding conventions.
(move_stmt_r): Cast according to the coding convertions.
(new_label_mapper): Use typesafe memory macros.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15  8:05     ` Andrew Pinski
  2007-05-15 10:39       ` Thomas Neumann
@ 2007-05-15 11:50       ` Joseph S. Myers
  2007-05-15 15:28         ` Richard Kenner
  1 sibling, 1 reply; 8+ messages in thread
From: Joseph S. Myers @ 2007-05-15 11:50 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Thomas Neumann, gcc-patches

On Tue, 15 May 2007, Andrew Pinski wrote:

>        * tree.h (DECL_COMPLEX_GIMPLE_REG_P): Rename to ...
>        (DECL_GIMPLE_REG_P): This.

>        * omp-low.c (omp_copy_decl_2): Use the renamed DECL_GIMPLE_REG_P.

I should point out that for this sort of thing the GNU Coding Standards 
allow you to say "All callers changed." rather than enumerating the 
callers individually.  (I think it may still be useful to list the files 
changed, but not the functions within them - "* a.c, b.c, c.c: All callers 
changed.".)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15 11:50       ` Joseph S. Myers
@ 2007-05-15 15:28         ` Richard Kenner
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Kenner @ 2007-05-15 15:28 UTC (permalink / raw)
  To: joseph; +Cc: gcc-patches, pinskia, tneumann

> I should point out that for this sort of thing the GNU Coding Standards 
> allow you to say "All callers changed." rather than enumerating the 
> callers individually.  (I think it may still be useful to list the files 
> changed, but not the functions within them - "* a.c, b.c, c.c: All callers 
> changed.".)

I would definitely recommend listing the files, but I agree that the above
is enough for mechanical edits such as this.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] compiling gcc with a C++ compiler 4/n
  2007-05-15 10:39       ` Thomas Neumann
@ 2007-05-19 13:33         ` Gerald Pfeifer
  0 siblings, 0 replies; 8+ messages in thread
From: Gerald Pfeifer @ 2007-05-19 13:33 UTC (permalink / raw)
  To: Thomas Neumann; +Cc: Andrew Pinski, gcc-patches

On Tue, 15 May 2007, Thomas Neumann wrote:
>> Oh and double checking you have your copyright assignment in place right?
> hm, I do not know how to "double check". I looked at my copy of the
> papers signed by me and the FSF (Peter Brown) again, if that is what you
> mean. Only someone with a gnu.org account can double check my
> assignment, I think.

I just did that, and your records seem fine.

Gerald

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-19 13:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-15  7:19 [PATCH] compiling gcc with a C++ compiler 4/n Thomas Neumann
2007-05-15  7:30 ` Andrew Pinski
2007-05-15  7:46   ` Thomas Neumann
2007-05-15  8:05     ` Andrew Pinski
2007-05-15 10:39       ` Thomas Neumann
2007-05-19 13:33         ` Gerald Pfeifer
2007-05-15 11:50       ` Joseph S. Myers
2007-05-15 15:28         ` Richard Kenner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).