From e782b5bb98fccb65fbc15d5c8fac09db2afaab44 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 16 May 2014 14:18:51 -0400
Subject: [PATCH 28/29] Use geh_mnt

This corresponds to:
  "[PATCH 27/89] Introduce gimple_eh_must_not_throw"
    https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01218.html
from v1 of the patch series.

gcc/
	* coretypes.h (geh_mnt): Add forward declaration.

	* gimple-pretty-print.c (dump_gimple_eh_must_not_throw): Require
	a geh_mnt rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to geh_mnt within
	GIMPLE_EH_MUST_NOT_THROW case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Likewise.

	* gimple-streamer-out.c (output_gimple_stmt): Likewise.

	* gimple.c (gimple_build_eh_must_not_throw): Return a
	geh_mnt rather than a plain gimple.

	* gimple.h (gimple_build_eh_must_not_throw): Return a geh_mnt
	rather than a plain gimple.
	(gimple_eh_must_not_throw_fndecl): Require a
	geh_mnt rather than a plain gimple.
	(gimple_eh_must_not_throw_set_fndecl): Likewise.

	* tree-eh.c (lower_eh_must_not_throw): Add checked cast.
---
 gcc/coretypes.h           | 1 +
 gcc/gimple-pretty-print.c | 5 +++--
 gcc/gimple-streamer-in.c  | 3 ++-
 gcc/gimple-streamer-out.c | 5 ++++-
 gcc/gimple.c              | 4 ++--
 gcc/gimple.h              | 8 +++-----
 gcc/tree-eh.c             | 2 +-
 7 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 131f6a6..8d576f6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -83,6 +83,7 @@ class greturn;
 class gbind;
 class gcatch;
 class geh_filter;
+class geh_mnt;
 class gphi;
 
 union section;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d391fcd..3add205 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1009,7 +1009,7 @@ dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc, int flag
 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
 
 static void
-dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple *gs,
+dump_gimple_eh_must_not_throw (pretty_printer *buffer, geh_mnt *gs,
 			       int spc, int flags)
 {
   if (flags & TDF_RAW)
@@ -2200,7 +2200,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
+      dump_gimple_eh_must_not_throw (buffer, as_a <geh_mnt *> (gs), spc,
+				     flags);
       break;
 
     case GIMPLE_EH_ELSE:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index b1476c8..ff60a49 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -127,7 +127,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      gimple_eh_must_not_throw_set_fndecl (stmt, stream_read_tree (ib, data_in));
+      gimple_eh_must_not_throw_set_fndecl (as_a <geh_mnt *> (stmt),
+					   stream_read_tree (ib, data_in));
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index d1b0303..146869d 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -101,7 +101,10 @@ output_gimple_stmt (struct output_block *ob, gimple *stmt)
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      stream_write_tree (ob, gimple_eh_must_not_throw_fndecl (stmt), true);
+      stream_write_tree (ob,
+			 gimple_eh_must_not_throw_fndecl (
+			   as_a <geh_mnt *> (stmt)),
+			 true);
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b6e1095..5663edc 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -640,10 +640,10 @@ gimple_build_eh_filter (tree types, gimple_seq failure)
 
 /* Build a GIMPLE_EH_MUST_NOT_THROW statement.  */
 
-gimple *
+geh_mnt *
 gimple_build_eh_must_not_throw (tree decl)
 {
-  gimple *p = gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0);
+  geh_mnt *p = as_a <geh_mnt *> (gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0));
 
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
   gcc_assert (flags_from_decl_or_type (decl) & ECF_NORETURN);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index ac05f1b..f766c07 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1317,7 +1317,7 @@ gasm *gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 			    vec<tree, va_gc> *);
 gcatch *gimple_build_catch (tree, gimple_seq);
 geh_filter *gimple_build_eh_filter (tree, gimple_seq);
-gimple *gimple_build_eh_must_not_throw (tree);
+geh_mnt *gimple_build_eh_must_not_throw (tree);
 gimple *gimple_build_eh_else (gimple_seq, gimple_seq);
 gtry *gimple_build_try (gimple_seq, gimple_seq,
 			enum gimple_try_flags);
@@ -3597,18 +3597,16 @@ gimple_eh_filter_set_failure (gimple *gs, gimple_seq failure)
 /* Get the function decl to be called by the MUST_NOT_THROW region.  */
 
 static inline tree
-gimple_eh_must_not_throw_fndecl (gimple *gs)
+gimple_eh_must_not_throw_fndecl (geh_mnt *eh_mnt_stmt)
 {
-  geh_mnt *eh_mnt_stmt = as_a <geh_mnt *> (gs);
   return eh_mnt_stmt->fndecl;
 }
 
 /* Set the function decl to be called by GS to DECL.  */
 
 static inline void
-gimple_eh_must_not_throw_set_fndecl (gimple *gs, tree decl)
+gimple_eh_must_not_throw_set_fndecl (geh_mnt *eh_mnt_stmt, tree decl)
 {
-  geh_mnt *eh_mnt_stmt = as_a <geh_mnt *> (gs);
   eh_mnt_stmt->fndecl = decl;
 }
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index cf2f7fb..8bcff67 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1889,7 +1889,7 @@ lower_eh_must_not_throw (struct leh_state *state, gimple *tp)
 
       this_region = gen_eh_region_must_not_throw (state->cur_region);
       this_region->u.must_not_throw.failure_decl
-	= gimple_eh_must_not_throw_fndecl (inner);
+	= gimple_eh_must_not_throw_fndecl (as_a <geh_mnt *> (inner));
       this_region->u.must_not_throw.failure_loc
 	= LOCATION_LOCUS (gimple_location (tp));
 
-- 
1.8.5.3

