diff 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
line wrap: on
line diff
--- a/gcc/c/c-parser.c	Thu Nov 08 14:17:14 2018 +0900
+++ b/gcc/c/c-parser.c	Wed Nov 14 00:24:45 2018 +0900
@@ -5418,12 +5418,9 @@
   c_parser_statement_after_labels (parser, if_p, NULL);
 }
 
-/* Parse a statement, other than a labeled statement.  CHAIN is a vector
-   of if-else-if conditions.
-
-   IF_P is used to track whether there's a (possibly labeled) if statement
-   which is not enclosed in braces and has an else clause.  This is used to
-   implement -Wparentheses.  */
+/*
+ *  To avoid complication, compute argments and function pointer before tail call
+ */
 
 static tree
 cbc_replace_arguments (location_t loc, tree call)
@@ -5438,7 +5435,12 @@
   if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) )
     {
       tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(fn));
+      DECL_SOURCE_LOCATION (tmp_decl) = loc;
+      DECL_ARTIFICIAL (tmp_decl) = 1;
+      TREE_USED (tmp_decl) = 1;
+      DECL_CONTEXT (tmp_decl) = current_function_decl;
       pushdecl (tmp_decl);
+      finish_decl (tmp_decl, loc, NULL_TREE, NULL_TREE, NULL_TREE);
 
       add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, fn, NULL_TREE));
       CALL_EXPR_FN (call) = tmp_decl;
@@ -5446,11 +5448,15 @@
 
   FOR_EACH_CALL_EXPR_ARG (arg, iter, call) 
     {
-      /* if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) ) */
       if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) )
        {
          tmp_decl = build_decl (loc, VAR_DECL, NULL_TREE, TREE_TYPE(arg));
+         DECL_SOURCE_LOCATION (tmp_decl) = loc;
+         DECL_ARTIFICIAL (tmp_decl) = 1;
+         TREE_USED (tmp_decl) = 1;
+         DECL_CONTEXT (tmp_decl) = current_function_decl;
          pushdecl (tmp_decl);
+         finish_decl (tmp_decl, loc, NULL_TREE, NULL_TREE, NULL_TREE);
 
          add_stmt (build_modify_expr (loc, tmp_decl, NULL_TREE, NOP_EXPR, loc, arg, NULL_TREE));
          CALL_EXPR_ARG (call, i) = tmp_decl;
@@ -5461,6 +5467,13 @@
   return call;
 }
 
+/* Parse a statement, other than a labeled statement.  CHAIN is a vector
+   of if-else-if conditions.
+
+   IF_P is used to track whether there's a (possibly labeled) if statement
+   which is not enclosed in braces and has an else clause.  This is used to
+   implement -Wparentheses.  */
+
 static void
 c_parser_statement_after_labels (c_parser *parser, bool *if_p,
 				 vec<tree> *chain)
@@ -5531,17 +5544,15 @@
           {
               tree id = c_parser_peek_token (parser)->value;
               location_t loc = c_parser_peek_token (parser)->location;
-              /** build_external_ref (id,RID_CbC_CODE , loc); **/
               build_external_ref (loc, id, RID_CbC_CODE, &expr.original_type);
           }
           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);
+              // cbc_replace_arguments (loc, expr.value);
 
               TREE_TYPE(expr.value) = void_type_node;
-              /*tree env = NULL_TREE;**/
               CbC_IS_CbC_GOTO (expr.value) = 1;
               CALL_EXPR_TAILCALL (expr.value) = 1;
               add_stmt(expr.value);
@@ -5549,7 +5560,7 @@
               bool flag_isoc99_save = flag_isoc99;
               warn_return_type = false;
               flag_isoc99 = false;
-              stmt = c_finish_return(loc, NULL_TREE, NULL_TREE); /* stmt = c_finish_return (0); */
+              stmt = c_finish_return(loc, NULL_TREE, NULL_TREE); 
               warn_return_type = warn_return_type_save;
               flag_isoc99 = flag_isoc99_save;
           }
@@ -7980,7 +7991,7 @@
   add_stmt (build_stmt (loc, LABEL_EXPR, tlab));
 
   /* add_stmt (RETURN_EXPR) */
-  tree ret = c_finish_return (loc, retval, retval);
+  /*tree ret = */ c_finish_return (loc, retval, retval);
   DECL_READ_P(retval) = 1; // (NODE)->decl_common.decl_read_flag = 1;
   //  TREE_USED(ret) = 1;
   tree stmt_body = c_end_compound_stmt (loc, stmt, true);
@@ -8001,6 +8012,7 @@
   TREE_USED (retval) = 1;
 
 }
+
 static tree
 cbc_finish_nested_function (location_t loc, tree label, tree retval_decl)
 {
@@ -8069,7 +8081,7 @@
   tree cstmt = c_begin_compound_stmt (true);
 
   add_stmt (build_modify_expr (loc, retval_decl, NULL_TREE, NOP_EXPR, loc, _retval_decl, NULL_TREE));
-  tree stmt = c_finish_goto_label (loc, label);
+  /*tree stmt = */ c_finish_goto_label (loc, label);
 
   /* end compound statement.  */
   fnbody = c_end_compound_stmt (loc, cstmt, true);