gcc源代码分析,expand_expr_stmt()函数

终于调用的顺序清楚了,yyparse()函数调用了expand_expr_stmt()函数,expand_expr_stmt()函数调用了expand_expr()函数。

下面的语法规则对应printf("Hello,World!\n");。


stmt:
      compstmt    {}
    | expr ‘;‘
        { emit_line_note (input_filename, lineno);
          /* Do default conversion if safe and possibly important,
             in case within ({...}).  */
          if ((TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
               && lvalue_p ($1))
              || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
            $1 = default_conversion ($1);
          expand_expr_stmt ($1);
          clear_momentary (); }




/* Generate RTL to evaluate the expression EXP

   and remember it in case this is the VALUE in a ({... VALUE; }) constr.  */

void
expand_expr_stmt (exp)
     tree exp;
{
  /* If -W, warn about statements with no side effects,
     except inside a ({...}) where they may be useful.  */
  if (expr_stmts_for_value == 0 && exp != error_mark_node)
    {
      if (! TREE_VOLATILE (exp) && (extra_warnings || warn_unused))
    warning_with_file_and_line (emit_filename, emit_lineno,
                    "statement with no effect");
      else if (warn_unused)
    warn_if_unused_value (exp);
    }
  last_expr_type = TREE_TYPE (exp);
  if (! flag_syntax_only)
    last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
                   VOIDmode, 0);
  emit_queue ();
}

gcc源代码分析,expand_expr_stmt()函数

上一篇:云栖干货回顾 | 行业*NoSQL成员坐阵,NoSQL数据库专场重点解析!


下一篇:JAVA之String类及String类方法总结