Mercurial > hg > CbC > CbC_gcc
diff gcc/c-parser.c @ 35:3f5886e153cb
modify cbc_replace_args
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Dec 2009 20:49:36 +0900 |
parents | c845c9fe357a |
children | 9117c3b65bc3 |
line wrap: on
line diff
--- a/gcc/c-parser.c Tue Dec 22 20:46:05 2009 +0900 +++ b/gcc/c-parser.c Tue Dec 22 20:49:36 2009 +0900 @@ -1552,9 +1552,9 @@ 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); + //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; @@ -3737,22 +3737,34 @@ cbc_replace_arguments (location_t loc, tree call) { tree args; + tree fn; tree tmp_decl; int i=0; + fn = CALL_EXPR_FN (call); + if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) ) + { + tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(fn)); + pushdecl (tmp_decl); + + add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, fn)); + CALL_EXPR_FN (call) = tmp_decl; + } + args = CALL_EXPR_ARGS (call); for ( ;args; args = TREE_CHAIN (args), i++) { tree arg = TREE_VALUE (args); - if (CONSTANT_CLASS_P (arg) || VAR_OR_FUNCTION_DECL_P (arg) ) - continue; - - tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(arg)); - pushdecl (tmp_decl); - - add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, arg)); - CALL_EXPR_ARG (call, i) = tmp_decl; + //if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) ) + if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) ) + { + tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(arg)); + pushdecl (tmp_decl); + + add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, arg)); + CALL_EXPR_ARG (call, i) = tmp_decl; + } } return call; @@ -3825,7 +3837,7 @@ cbc_replace_arguments (loc, expr.value); TREE_TYPE(expr.value) = void_type_node; - //tree env = NULL_TREE; + /*tree env = NULL_TREE;**/ CbC_IS_CbC_GOTO (expr.value) = 1; CALL_EXPR_TAILCALL (expr.value) = 1; add_stmt(expr.value); @@ -5266,7 +5278,7 @@ { push_scope (); declare_parm_level (); - //tree retval_type = TREE_TYPE(retval_decl); + /*tree retval_type = TREE_TYPE(retval_decl);*/ _retval_decl = build_decl (PARM_DECL, get_identifier ("_retval"), TREE_TYPE(retval_decl)); DECL_SOURCE_LOCATION (_retval_decl) = loc; @@ -5293,9 +5305,7 @@ finish_declspecs (specs); /* make nested function. */ - //ident = build_decl (/*TODO:*/VAR_DECL, get_identifier ("_cbc_internal_return"), specs->type); declarator = build_id_declarator (get_identifier ("_cbc_internal_return")); - //declarator->id_loc = ; declarator = build_function_declarator (args, declarator); c_push_function_context (); @@ -5892,7 +5902,6 @@ /* define nested function. */ decl = cbc_finish_nested_function (location, label, decl_cond); - //tree nested_func = cbc_make_nested_function (location); /* define if-ed goto label and return statement. */ cbc_finish_labeled_goto (location, label, decl_cond); @@ -5901,9 +5910,9 @@ value = build_addr (decl , current_function_decl); SET_EXPR_LOCATION (value, location); add_stmt (value); - //value = build_external_ref (get_identifier("_cbc_internal_return"), false, location); - //value = build_unary_op (location, ADDR_EXPR, value, 0); - //add_stmt (value); + /*value = build_external_ref (get_identifier("_cbc_internal_return"), false, location);*/ + /*value = build_unary_op (location, ADDR_EXPR, value, 0);*/ + /*add_stmt (value);*/ TREE_SIDE_EFFECTS (stmt) = 1; expr.value = c_finish_stmt_expr (stmt);