changeset 11:8f2e43f937f3

add cbc_make_lebeled_return function.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Wed, 09 Sep 2009 18:47:06 +0900
parents 26e357f6275f
children ab98828ce7a7
files gcc/c-parser.c
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gcc/c-parser.c	Tue Sep 08 21:04:27 2009 +0900
+++ b/gcc/c-parser.c	Wed Sep 09 18:47:06 2009 +0900
@@ -60,6 +60,7 @@
 #ifndef noCbC
 #include "cbc-tree.h"
 static tree cbc_make_nested_function (location_t);
+static void cbc_make_labeled_goto (location_t loc);
 #endif
 
 
@@ -5722,6 +5723,8 @@
 	  tree nested_func = cbc_make_nested_function (location);
 	  add_stmt (build_stmt (DECL_EXPR, nested_func));
 
+	  cbc_make_labeled_goto (location);
+
 	  tree value = build_addr (nested_func , current_function_decl);
 	  SET_EXPR_LOCATION (value, location);
 	  add_stmt (value);
@@ -5765,6 +5768,34 @@
   return c_parser_postfix_expression_after_primary (parser, expr);
 }
 
+static void
+cbc_make_labeled_goto (location_t loc)
+{
+  tree name;
+  tree tlab;
+  tree cond;
+  tree retval;
+  //tree fwlabel = create_artificial_label ();
+
+  tree cstmt = c_begin_compound_stmt (true);
+  name = get_identifier("_cbc_exit0");
+
+  tlab = define_label (loc, name);
+  gcc_assert (tlab);
+  decl_attributes (&tlab, NULL_TREE, 0);
+  add_stmt (build_stmt (LABEL_EXPR, tlab));
+  //TREE_USED(decl) = 1;
+
+  retval = build_external_ref (get_identifier("retval"), false, loc);
+  tree ret = c_finish_return (retval); 
+  TREE_USED(ret) = 1;
+
+  cond = integer_zero_node;
+  tree if_body = c_end_compound_stmt (cstmt, true);
+  TREE_SIDE_EFFECTS (cstmt) = 1;
+  c_finish_if_stmt (loc, cond, if_body, NULL_TREE, false);
+}
+
 static tree
 cbc_make_nested_function (location_t loc)
 {