# HG changeset patch # User kent # Date 1260243811 -32400 # Node ID c845c9fe357a7c753247dbaa697830d0dc94a47b # Parent cc07adb178554a0fbab328e4db075cdd768fefee add cbc_replace_arguments function. diff -r cc07adb17855 -r c845c9fe357a gcc/c-parser.c --- a/gcc/c-parser.c Thu Nov 26 13:27:48 2009 +0900 +++ b/gcc/c-parser.c Tue Dec 08 12:43:31 2009 +0900 @@ -3733,6 +3733,31 @@ } #endif +static tree +cbc_replace_arguments (location_t loc, tree call) +{ + tree args; + tree tmp_decl; + int i=0; + + 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; + } + + return call; +} + /* Parse a statement, other than a labeled statement. */ static void @@ -3796,6 +3821,9 @@ expr = c_parser_expr_no_commas (parser, NULL); if (TREE_CODE(expr.value) == CALL_EXPR ) { + location_t loc = c_parser_peek_token (parser)->location; + cbc_replace_arguments (loc, expr.value); + TREE_TYPE(expr.value) = void_type_node; //tree env = NULL_TREE; CbC_IS_CbC_GOTO (expr.value) = 1; @@ -5185,7 +5213,7 @@ */ static void -cbc_finish_labeled_goto (location_t loc, tree label) +cbc_finish_labeled_goto (location_t loc, tree label, tree retval) { /* add statement below. * @@ -5194,10 +5222,8 @@ * return retval; * } */ - tree name; tree tlab; tree cond; - tree retval; tree cstmt = c_begin_compound_stmt (true); @@ -5206,7 +5232,6 @@ decl_attributes (&tlab, NULL_TREE, 0); add_stmt (build_stmt (LABEL_EXPR, tlab)); - retval = build_external_ref (get_identifier("retval"), false, loc); tree ret = c_finish_return (retval); TREE_USED(ret) = 1; @@ -5232,25 +5257,27 @@ */ tree fnbody; + tree _retval_decl, _envp_decl; struct c_declarator *declarator; tree ident; struct c_arg_info *args; struct c_declspecs *specs; struct c_typespec t; { - tree _retval_decl, _envp_decl; push_scope (); declare_parm_level (); //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; + DECL_ARTIFICIAL (_retval_decl) = 1; DECL_ARG_TYPE (_retval_decl) = TREE_TYPE(retval_decl); pushdecl (_retval_decl); finish_decl (_retval_decl, NULL_TREE, NULL_TREE); _envp_decl = build_decl (PARM_DECL, get_identifier ("_envp"), ptr_type_node); DECL_SOURCE_LOCATION (_envp_decl) = loc; + DECL_ARTIFICIAL (_envp_decl) = 1; DECL_ARG_TYPE (_envp_decl) = ptr_type_node; pushdecl (_envp_decl); finish_decl (_envp_decl, NULL_TREE, NULL_TREE); @@ -5284,9 +5311,7 @@ /* start compound statement. */ tree cstmt = c_begin_compound_stmt (true); - //tree lhs = build_external_ref (get_identifier("retval"), false, loc); - tree rhs = build_external_ref (get_identifier("_retval"), false, loc); - add_stmt (build_modify_expr (loc, retval_decl, NOP_EXPR, rhs)); + add_stmt (build_modify_expr (loc, retval_decl, NOP_EXPR, _retval_decl)); tree stmt = c_finish_goto_label (label); /* end compound statement. */ @@ -5861,6 +5886,7 @@ build_decl (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); /* define nested function. */ @@ -5869,7 +5895,7 @@ //tree nested_func = cbc_make_nested_function (location); /* define if-ed goto label and return statement. */ - cbc_finish_labeled_goto (location, label); + cbc_finish_labeled_goto (location, label, decl_cond); /* get pointer to nested function. */ value = build_addr (decl , current_function_decl);