Mercurial > hg > CbC > CbC_gcc
comparison gcc/c/c-parser.c @ 140:4e440907fcbf
copy CbC goto flang in cfgexpand
remove some CbC unnecessary code
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Nov 2018 00:24:45 +0900 |
parents | d34655255c78 |
children | 351920fa3827 |
comparison
equal
deleted
inserted
replaced
138:fc828634a951 | 140:4e440907fcbf |
---|---|
5416 if (loc_after_labels) | 5416 if (loc_after_labels) |
5417 *loc_after_labels = c_parser_peek_token (parser)->location; | 5417 *loc_after_labels = c_parser_peek_token (parser)->location; |
5418 c_parser_statement_after_labels (parser, if_p, NULL); | 5418 c_parser_statement_after_labels (parser, if_p, NULL); |
5419 } | 5419 } |
5420 | 5420 |
5421 /* Parse a statement, other than a labeled statement. CHAIN is a vector | 5421 /* |
5422 of if-else-if conditions. | 5422 * To avoid complication, compute argments and function pointer before tail call |
5423 | 5423 */ |
5424 IF_P is used to track whether there's a (possibly labeled) if statement | |
5425 which is not enclosed in braces and has an else clause. This is used to | |
5426 implement -Wparentheses. */ | |
5427 | 5424 |
5428 static tree | 5425 static tree |
5429 cbc_replace_arguments (location_t loc, tree call) | 5426 cbc_replace_arguments (location_t loc, tree call) |
5430 { | 5427 { |
5431 tree arg; | 5428 tree arg; |
5436 | 5433 |
5437 fn = CALL_EXPR_FN (call); | 5434 fn = CALL_EXPR_FN (call); |
5438 if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) ) | 5435 if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) ) |
5439 { | 5436 { |
5440 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn)); | 5437 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn)); |
5438 DECL_SOURCE_LOCATION (tmp_decl) = loc; | |
5439 DECL_ARTIFICIAL (tmp_decl) = 1; | |
5440 TREE_USED (tmp_decl) = 1; | |
5441 DECL_CONTEXT (tmp_decl) = current_function_decl; | |
5441 pushdecl (tmp_decl); | 5442 pushdecl (tmp_decl); |
5443 finish_decl (tmp_decl, loc, NULL_TREE, NULL_TREE, NULL_TREE); | |
5442 | 5444 |
5443 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE)); | 5445 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE)); |
5444 CALL_EXPR_FN (call) = tmp_decl; | 5446 CALL_EXPR_FN (call) = tmp_decl; |
5445 } | 5447 } |
5446 | 5448 |
5447 FOR_EACH_CALL_EXPR_ARG (arg, iter, call) | 5449 FOR_EACH_CALL_EXPR_ARG (arg, iter, call) |
5448 { | 5450 { |
5449 /* if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) ) */ | |
5450 if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) ) | 5451 if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) ) |
5451 { | 5452 { |
5452 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg)); | 5453 tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg)); |
5454 DECL_SOURCE_LOCATION (tmp_decl) = loc; | |
5455 DECL_ARTIFICIAL (tmp_decl) = 1; | |
5456 TREE_USED (tmp_decl) = 1; | |
5457 DECL_CONTEXT (tmp_decl) = current_function_decl; | |
5453 pushdecl (tmp_decl); | 5458 pushdecl (tmp_decl); |
5459 finish_decl (tmp_decl, loc, NULL_TREE, NULL_TREE, NULL_TREE); | |
5454 | 5460 |
5455 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE)); | 5461 add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE)); |
5456 CALL_EXPR_ARG (call, i) = tmp_decl; | 5462 CALL_EXPR_ARG (call, i) = tmp_decl; |
5457 } | 5463 } |
5458 i++; | 5464 i++; |
5459 } | 5465 } |
5460 | 5466 |
5461 return call; | 5467 return call; |
5462 } | 5468 } |
5469 | |
5470 /* Parse a statement, other than a labeled statement. CHAIN is a vector | |
5471 of if-else-if conditions. | |
5472 | |
5473 IF_P is used to track whether there's a (possibly labeled) if statement | |
5474 which is not enclosed in braces and has an else clause. This is used to | |
5475 implement -Wparentheses. */ | |
5463 | 5476 |
5464 static void | 5477 static void |
5465 c_parser_statement_after_labels (c_parser *parser, bool *if_p, | 5478 c_parser_statement_after_labels (c_parser *parser, bool *if_p, |
5466 vec<tree> *chain) | 5479 vec<tree> *chain) |
5467 { | 5480 { |
5529 { | 5542 { |
5530 if (c_parser_next_token_is (parser, CPP_NAME)) | 5543 if (c_parser_next_token_is (parser, CPP_NAME)) |
5531 { | 5544 { |
5532 tree id = c_parser_peek_token (parser)->value; | 5545 tree id = c_parser_peek_token (parser)->value; |
5533 location_t loc = c_parser_peek_token (parser)->location; | 5546 location_t loc = c_parser_peek_token (parser)->location; |
5534 /** build_external_ref (id,RID_CbC_CODE , loc); **/ | |
5535 build_external_ref (loc, id, RID_CbC_CODE, &expr.original_type); | 5547 build_external_ref (loc, id, RID_CbC_CODE, &expr.original_type); |
5536 } | 5548 } |
5537 expr = c_parser_expr_no_commas (parser, NULL); | 5549 expr = c_parser_expr_no_commas (parser, NULL); |
5538 if (TREE_CODE(expr.value) == CALL_EXPR ) | 5550 if (TREE_CODE(expr.value) == CALL_EXPR ) |
5539 { | 5551 { |
5540 location_t loc = c_parser_peek_token (parser)->location; | 5552 location_t loc = c_parser_peek_token (parser)->location; |
5541 cbc_replace_arguments (loc, expr.value); | 5553 // cbc_replace_arguments (loc, expr.value); |
5542 | 5554 |
5543 TREE_TYPE(expr.value) = void_type_node; | 5555 TREE_TYPE(expr.value) = void_type_node; |
5544 /*tree env = NULL_TREE;**/ | |
5545 CbC_IS_CbC_GOTO (expr.value) = 1; | 5556 CbC_IS_CbC_GOTO (expr.value) = 1; |
5546 CALL_EXPR_TAILCALL (expr.value) = 1; | 5557 CALL_EXPR_TAILCALL (expr.value) = 1; |
5547 add_stmt(expr.value); | 5558 add_stmt(expr.value); |
5548 bool warn_return_type_save = warn_return_type; | 5559 bool warn_return_type_save = warn_return_type; |
5549 bool flag_isoc99_save = flag_isoc99; | 5560 bool flag_isoc99_save = flag_isoc99; |
5550 warn_return_type = false; | 5561 warn_return_type = false; |
5551 flag_isoc99 = false; | 5562 flag_isoc99 = false; |
5552 stmt = c_finish_return(loc, NULL_TREE, NULL_TREE); /* stmt = c_finish_return (0); */ | 5563 stmt = c_finish_return(loc, NULL_TREE, NULL_TREE); |
5553 warn_return_type = warn_return_type_save; | 5564 warn_return_type = warn_return_type_save; |
5554 flag_isoc99 = flag_isoc99_save; | 5565 flag_isoc99 = flag_isoc99_save; |
5555 } | 5566 } |
5556 else | 5567 else |
5557 c_parser_error (parser, "expected code segment jump or %<*%>"); | 5568 c_parser_error (parser, "expected code segment jump or %<*%>"); |
7978 TREE_USED (tlab) = 1; | 7989 TREE_USED (tlab) = 1; |
7979 /* add_stmt (LABEL_EXPR) */ | 7990 /* add_stmt (LABEL_EXPR) */ |
7980 add_stmt (build_stmt (loc, LABEL_EXPR, tlab)); | 7991 add_stmt (build_stmt (loc, LABEL_EXPR, tlab)); |
7981 | 7992 |
7982 /* add_stmt (RETURN_EXPR) */ | 7993 /* add_stmt (RETURN_EXPR) */ |
7983 tree ret = c_finish_return (loc, retval, retval); | 7994 /*tree ret = */ c_finish_return (loc, retval, retval); |
7984 DECL_READ_P(retval) = 1; // (NODE)->decl_common.decl_read_flag = 1; | 7995 DECL_READ_P(retval) = 1; // (NODE)->decl_common.decl_read_flag = 1; |
7985 // TREE_USED(ret) = 1; | 7996 // TREE_USED(ret) = 1; |
7986 tree stmt_body = c_end_compound_stmt (loc, stmt, true); | 7997 tree stmt_body = c_end_compound_stmt (loc, stmt, true); |
7987 | 7998 |
7988 /* add_stmt (STATEMENT_LIST) : STATEMENT_LIST -> LABEL_EXPR -> RETURN_EXPR */ | 7999 /* add_stmt (STATEMENT_LIST) : STATEMENT_LIST -> LABEL_EXPR -> RETURN_EXPR */ |
7999 add_stmt (bind); | 8010 add_stmt (bind); |
8000 | 8011 |
8001 TREE_USED (retval) = 1; | 8012 TREE_USED (retval) = 1; |
8002 | 8013 |
8003 } | 8014 } |
8015 | |
8004 static tree | 8016 static tree |
8005 cbc_finish_nested_function (location_t loc, tree label, tree retval_decl) | 8017 cbc_finish_nested_function (location_t loc, tree label, tree retval_decl) |
8006 { | 8018 { |
8007 | 8019 |
8008 /* add statement below. | 8020 /* add statement below. |
8067 | 8079 |
8068 /* start compound statement. */ | 8080 /* start compound statement. */ |
8069 tree cstmt = c_begin_compound_stmt (true); | 8081 tree cstmt = c_begin_compound_stmt (true); |
8070 | 8082 |
8071 add_stmt (build_modify_expr (loc, retval_decl, NULL_TREE, NOP_EXPR, loc, _retval_decl, NULL_TREE)); | 8083 add_stmt (build_modify_expr (loc, retval_decl, NULL_TREE, NOP_EXPR, loc, _retval_decl, NULL_TREE)); |
8072 tree stmt = c_finish_goto_label (loc, label); | 8084 /*tree stmt = */ c_finish_goto_label (loc, label); |
8073 | 8085 |
8074 /* end compound statement. */ | 8086 /* end compound statement. */ |
8075 fnbody = c_end_compound_stmt (loc, cstmt, true); | 8087 fnbody = c_end_compound_stmt (loc, cstmt, true); |
8076 TREE_SIDE_EFFECTS (cstmt) = 1; | 8088 TREE_SIDE_EFFECTS (cstmt) = 1; |
8077 | 8089 |