This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 27/89] Introduce gimple_eh_must_not_throw


gcc/
	* coretypes.h (gimple_eh_must_not_throw): New typedef.
	(const_gimple_eh_must_not_throw): New typedef.

	* gimple-pretty-print.c (dump_gimple_eh_must_not_throw): Require
	a gimple_eh_must_not_throw rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_eh_must_not_throw
	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
	gimple_eh_must_not_throw rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_eh_must_not_throw):
	New.
	(gimple_build_eh_must_not_throw): Return a gimple_eh_must_not_throw
	rather than a plain gimple.
	(gimple_eh_must_not_throw_fndecl): Require a
	gimple_eh_must_not_throw 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           |  4 ++++
 gcc/gimple-pretty-print.c |  8 +++++---
 gcc/gimple-streamer-in.c  |  4 +++-
 gcc/gimple-streamer-out.c |  5 ++++-
 gcc/gimple.c              |  6 ++++--
 gcc/gimple.h              | 15 ++++++++++-----
 gcc/tree-eh.c             |  3 ++-
 7 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 592b9e5..512967c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -121,6 +121,10 @@ struct gimple_statement_eh_filter;
 typedef struct gimple_statement_eh_filter *gimple_eh_filter;
 typedef const struct gimple_statement_eh_filter *const_gimple_eh_filter;
 
+struct gimple_statement_eh_mnt;
+typedef struct gimple_statement_eh_mnt *gimple_eh_must_not_throw;
+typedef const struct gimple_statement_eh_mnt *const_gimple_eh_must_not_throw;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 37f28d9..027bb94 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1011,8 +1011,8 @@ dump_gimple_eh_filter (pretty_printer *buffer, gimple_eh_filter gs, int spc,
 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
 
 static void
-dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
-			       int spc, int flags)
+dump_gimple_eh_must_not_throw (pretty_printer *buffer,
+			       gimple_eh_must_not_throw gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
@@ -2209,7 +2209,9 @@ 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,
+				     gs->as_a_gimple_eh_must_not_throw (),
+				     spc, flags);
       break;
 
     case GIMPLE_EH_ELSE:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 0e94369..949e9af 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -127,7 +127,9 @@ 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 (
+	stmt->as_a_gimple_eh_must_not_throw (),
+	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 b3c3b25..52130ac 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 (
+			   stmt->as_a_gimple_eh_must_not_throw ()),
+			 true);
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 42eef46..b487e46 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -640,10 +640,12 @@ gimple_build_eh_filter (tree types, gimple_seq failure)
 
 /* Build a GIMPLE_EH_MUST_NOT_THROW statement.  */
 
-gimple
+gimple_eh_must_not_throw
 gimple_build_eh_must_not_throw (tree decl)
 {
-  gimple p = gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0);
+  gimple_eh_must_not_throw p =
+    gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0)
+      ->as_a_gimple_eh_must_not_throw ();
 
   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 38b257c..47377e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -300,6 +300,12 @@ public:
     return as_a <gimple_statement_eh_filter> (this);
   }
 
+  inline gimple_eh_must_not_throw
+  as_a_gimple_eh_must_not_throw ()
+  {
+    return as_a <gimple_statement_eh_mnt> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1519,7 +1525,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *);
 gimple_catch gimple_build_catch (tree, gimple_seq);
 gimple_eh_filter gimple_build_eh_filter (tree, gimple_seq);
-gimple gimple_build_eh_must_not_throw (tree);
+gimple_eh_must_not_throw gimple_build_eh_must_not_throw (tree);
 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
 gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
@@ -3811,18 +3817,17 @@ 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 (gimple_eh_must_not_throw eh_mnt_stmt)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_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 (gimple_eh_must_not_throw eh_mnt_stmt,
+				     tree decl)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_mnt> (gs);
   eh_mnt_stmt->fndecl = decl;
 }
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 940b565..5a8f9e1 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1888,7 +1888,8 @@ 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 (
+	    inner->as_a_gimple_eh_must_not_throw ());
       this_region->u.must_not_throw.failure_loc
 	= LOCATION_LOCUS (gimple_location (tp));
 
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]