static void
gimplify_expr_stmt (tree *stmt_p)
{
  tree stmt = EXPR_STMT_EXPR (*stmt_p);

  if (stmt == error_mark_node)
    stmt = NULL;

  /* Gimplification of a statement expression will nullify the
     statement if all its side effects are moved to *PRE_P and *POST_P.

     In this case we will not want to emit the gimplified statement.
     However, we may still want to emit a warning, so we do that before
     gimplification.  */
  if (stmt && (extra_warnings || warn_unused_value))
    {
      if (!TREE_SIDE_EFFECTS (stmt))
	{
	  if (!IS_EMPTY_STMT (stmt)
	      && !VOID_TYPE_P (TREE_TYPE (stmt))
	      && !TREE_NO_WARNING (stmt))
	    warning (0, "statement with no effect");
	}
      else if (warn_unused_value)
	warn_if_unused_value (stmt, input_location);
    }

  if (stmt == NULL_TREE)
    stmt = alloc_stmt_list ();

  *stmt_p = stmt;
}
Example #2
0
expression make_comma(location loc, expression elist)
{
  expression result = CAST(expression, new_comma(parse_region, loc, elist));
  expression e;

  scan_expression (e, elist)
    if (e->next) /* Not last */
      {
#if 0
	if (!e->side_effects)
	  {
	    /* The left-hand operand of a comma expression is like an expression
	       statement: with -W or -Wunused, we should warn if it doesn't have
	       any side-effects, unless it was explicitly cast to (void).  */
	    if ((extra_warnings || warn_unused)
		&& !(TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR
		      && TREE_TYPE (TREE_VALUE (list)) == void_type_node))
	      warning ("left-hand operand of comma expression has no effect");
	  }
	else if (warn_unused)
	  warn_if_unused_value(e);
#endif
      }
    else
      {
	if (type_array(e->type))
	  result->type = default_conversion(e);
	else
	  result->type = e->type;

	if (!pedantic)
	  {
	    /* XXX: I seemed to believe that , could be a constant expr in GCC,
	       but cst3.c seems to disagree. Check gcc code again ?
	       (It's a bad idea anyway) */
	    result->lvalue = e->lvalue;
	    result->isregister = e->isregister;
	    result->bitfield = e->bitfield;
	  }
      }

  return result;
}