comparison gcc/c-parser.c @ 76:6381ea127240

call argument iterator fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 20 Sep 2011 16:58:47 +0900
parents f26ecf70364b
children d8bf5c8fdea8
comparison
equal deleted inserted replaced
75:3c5ea37d9068 76:6381ea127240
4354 env_struct_type = start_struct (RECORD_TYPE, NULL_TREE); 4354 env_struct_type = start_struct (RECORD_TYPE, NULL_TREE);
4355 field = build_decl (FIELD_DECL, get_identifier("sp"), ptr_type_node); 4355 field = build_decl (FIELD_DECL, get_identifier("sp"), ptr_type_node);
4356 fields = chainon (field, fields); 4356 fields = chainon (field, fields);
4357 field = build_decl (FIELD_DECL, get_identifier("argsp"), ptr_type_node); 4357 field = build_decl (FIELD_DECL, get_identifier("argsp"), ptr_type_node);
4358 fields = chainon (field, fields); 4358 fields = chainon (field, fields);
4359 //field = build_decl (FIELD_DECL, get_identifier("retval"), intSI_type_node); 4359 /* field = build_decl (FIELD_DECL, get_identifier("retval"), intSI_type_node); */
4360 //fields = chainon (field, fields); 4360 /* fields = chainon (field, fields); */
4361 fields = nreverse(fields); 4361 fields = nreverse(fields);
4362 finish_struct (env_struct_type, fields, NULL_TREE); 4362 finish_struct (env_struct_type, fields, NULL_TREE);
4363 4363
4364 env_struct = build_c_cast (build_pointer_type(env_struct_type), env.value); 4364 env_struct = build_c_cast (build_pointer_type(env_struct_type), env.value);
4365 //build_component_ref (cbc_env, get_identifier("argsp")); 4365 /* build_component_ref (cbc_env, get_identifier("argsp")); */
4366 ebp = build_component_ref (build_indirect_ref (loc,env_struct, "CbCenv->sp"), get_identifier("sp")); 4366 ebp = build_component_ref (build_indirect_ref (loc,env_struct, "CbCenv->sp"), get_identifier("sp"));
4367 argsp = build_component_ref (build_indirect_ref (loc, env_struct, "CbCenv->sp"), get_identifier("argsp")); 4367 argsp = build_component_ref (build_indirect_ref (loc, env_struct, "CbCenv->sp"), get_identifier("argsp"));
4368 //ebp = chainon (ebp, argsp); 4368 /* ebp = chainon (ebp, argsp); */
4369 tmp = build_tree_list (ebp, argsp); 4369 tmp = build_tree_list (ebp, argsp);
4370 4370
4371 return tmp; 4371 return tmp;
4372 } 4372 }
4373 #endif 4373 #endif
4374 4374
4375 static tree 4375 static tree
4376 cbc_replace_arguments (location_t loc, tree call) 4376 cbc_replace_arguments (location_t loc, tree call)
4377 { 4377 {
4378 tree args; 4378 tree arg;
4379 tree fn; 4379 tree fn;
4380 tree tmp_decl; 4380 tree tmp_decl;
4381 int i=0; 4381 int i=0;
4382 call_expr_arg_iterator iter;
4382 4383
4383 fn = CALL_EXPR_FN (call); 4384 fn = CALL_EXPR_FN (call);
4384 if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) ) 4385 if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) )
4385 { 4386 {
4386 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn)); 4387 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn));
4388 4389
4389 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE)); 4390 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE));
4390 CALL_EXPR_FN (call) = tmp_decl; 4391 CALL_EXPR_FN (call) = tmp_decl;
4391 } 4392 }
4392 4393
4393 args = CALL_EXPR_ARGS (call); 4394 FOR_EACH_CALL_EXPR_ARG (arg, iter, call)
4394 for ( ;args; args = TREE_CHAIN (args), i++) 4395 {
4395 { 4396 /* if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) ) */
4396 tree arg = TREE_VALUE (args);
4397
4398 //if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) )
4399 if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) ) 4397 if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) )
4400 { 4398 {
4401 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg)); 4399 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg));
4402 pushdecl (tmp_decl); 4400 pushdecl (tmp_decl);
4403 4401
4404 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE)); 4402 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE));
4405 CALL_EXPR_ARG (call, i) = tmp_decl; 4403 CALL_EXPR_ARG (call, i) = tmp_decl;
4406 } 4404 }
4405 i++;
4407 } 4406 }
4408 4407
4409 return call; 4408 return call;
4410 } 4409 }
4411 4410