diff gcc/c-parser.c @ 87:4a89a0a804df

modify c-parser.c:RID_CbC_RET
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 20 Dec 2011 18:51:07 +0900
parents dbfc0d2dde36
children f214c1d5b862
line wrap: on
line diff
--- a/gcc/c-parser.c	Sat Sep 24 02:43:04 2011 +0900
+++ b/gcc/c-parser.c	Tue Dec 20 18:51:07 2011 +0900
@@ -2113,9 +2113,11 @@
       attrs = build_tree_list(attrs, NULL_TREE);
       declspecs_add_attrs(specs, attrs);
       */
-      attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE);
-      /*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/
-      declspecs_add_attrs(specs, attrs);
+      if(!TARGET_64BIT) { 
+	attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE);
+	/*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/
+	declspecs_add_attrs(specs, attrs);
+      }
 
       c_parser_consume_token (parser);
       break;
@@ -6158,20 +6160,54 @@
   tree tlab;
   tree cond;
 
+  /*
   tree cstmt = c_begin_compound_stmt (true);
-
   tlab = define_label (loc, label);
   gcc_assert (tlab);
   decl_attributes (&tlab, NULL_TREE, 0);
   add_stmt (build_stmt (loc, LABEL_EXPR, tlab));
 
-  tree ret = c_finish_return (loc, retval, retval); /*tree ret = c_finish_return (retval);*/
+  tree ret = c_finish_return (loc, retval, retval); //tree ret = c_finish_return (retval);
   TREE_USED(ret) = 1;
 
-  cond = integer_zero_node;
+
   tree if_body = c_end_compound_stmt (loc, cstmt, true);
   TREE_SIDE_EFFECTS (cstmt) = 1;
   c_finish_if_stmt (loc, cond, if_body, NULL_TREE, false);
+  */
+
+  cond = integer_zero_node;
+  tree block_outside = c_begin_compound_stmt (false);
+  tree block_inside = c_begin_compound_stmt (false);
+
+  tree stmt = c_begin_compound_stmt (true);
+  tlab = define_label (loc, label);
+  gcc_assert (tlab);
+  decl_attributes (&tlab, NULL_TREE, 0);
+  TREE_USED (tlab) = 1;
+  /* add_stmt (LABEL_EXPR) */
+  add_stmt (build_stmt (loc, LABEL_EXPR, tlab));
+
+  /* add_stmt (RETURN_EXPR) */
+  tree ret = c_finish_return (loc, retval, retval);
+  //  TREE_USED(ret) = 1;
+  tree stmt_body = c_end_compound_stmt (loc, stmt, true);
+
+  /* add_stmt (STATEMENT_LIST) : STATEMENT_LIST -> LABEL_EXPR -> RETURN_EXPR */
+  add_stmt (stmt_body);
+  
+  tree body = c_end_compound_stmt (loc, block_inside, false);
+
+  /* add_stmt (COND_EXPR) */
+  c_finish_if_stmt (loc, cond, body, NULL_TREE, false);
+
+  /* add_stmt (BIND_EXPR) : BIND_EXPR -> COND_EXPR -> STATEMENT_LIST */
+  tree bind = c_end_compound_stmt (loc, block_outside, false);
+  TREE_SIDE_EFFECTS (bind) = 1;
+  add_stmt (bind);
+
+  TREE_USED (retval) = 1;
+
 }
 
 static tree
@@ -6739,9 +6775,17 @@
         tree decl_cond =
           build_decl (location, VAR_DECL, get_identifier ("retval"),
           TREE_TYPE (TREE_TYPE (current_function_decl)));
-        TREE_STATIC (decl_cond) = 1;
-        DECL_ARTIFICIAL (decl_cond) = 1;
-        pushdecl (decl_cond);
+	TREE_STATIC (decl_cond) = 1;
+
+	/* use thread-local */
+	//DECL_TLS_MODEL (decl_cond) = decl_default_tls_model (decl_cond);
+	//	DECL_TLS_MODEL (decl_cond) = TLS_MODEL_REAL;
+
+	/* Linux: TLS_MODEL_LOCAL_EXEC  OS X: TlS_MODE_REAL */
+	DECL_TLS_MODEL (decl_cond) = TLS_MODEL_LOCAL_EXEC;
+	//DECL_ARTIFICIAL (decl_cond) = 1;
+	//	pushdecl (decl_cond);
+	add_stmt (build_stmt(location, DECL_EXPR,  pushdecl (decl_cond)));
 
         /* define nested function.  */
         decl =
@@ -6752,6 +6796,7 @@
 
         /* get pointer to nested function.  */
         value = build_addr (decl , current_function_decl);
+	TREE_USED (current_function_decl) = 1; 
         SET_EXPR_LOCATION (value, location);
         add_stmt (value);