FreeBSD/contrib/gcc/c-common.c
/* Walk a gimplified function and warn for functions whose return value is
   ignored and attribute((warn_unused_result)) is set.  This is done before
   inlining, so we don't have to worry about that.  */
Walk a gimplified function and warn for functions whose return value is
ignored and attribute((warn_unused_result)) is set.  This is done before
inlining, so we don't have to worry about that.
Walk a gimplified function and warn for functions whose return value is ignored and attribute (( warn_unused_result )) is set . This is done before inlining so we don ' t have to worry about that .
void
c_warn_unused_result (tree *top_p)
{
  tree t = *top_p;
  tree_stmt_iterator i;
  tree fdecl, ftype;
  switch (TREE_CODE (t))
    {
    case STATEMENT_LIST:
      for (i = tsi_start (*top_p); !tsi_end_p (i); tsi_next (&i))
	c_warn_unused_result (tsi_stmt_ptr (i));
      break;
    case COND_EXPR:
      c_warn_unused_result (&COND_EXPR_THEN (t));
      c_warn_unused_result (&COND_EXPR_ELSE (t));
      break;
    case BIND_EXPR:
      c_warn_unused_result (&BIND_EXPR_BODY (t));
      break;
    case TRY_FINALLY_EXPR:
    case TRY_CATCH_EXPR:
      c_warn_unused_result (&TREE_OPERAND (t, 0));
      c_warn_unused_result (&TREE_OPERAND (t, 1));
      break;
    case CATCH_EXPR:
      c_warn_unused_result (&CATCH_BODY (t));
      break;
    case EH_FILTER_EXPR:
      c_warn_unused_result (&EH_FILTER_FAILURE (t));
      break;
    case CALL_EXPR:
      if (TREE_USED (t))
	break;
      fdecl = get_callee_fndecl (t);
      if (fdecl)
	ftype = TREE_TYPE (fdecl);
      else
	{
	  ftype = TREE_TYPE (TREE_OPERAND (t, 0));
	  ftype = TREE_TYPE (ftype);
	}
      if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype)))
	{
	  if (fdecl)
	    warning (0, "%Hignoring return value of %qD, "
		     "declared with attribute warn_unused_result",
		     EXPR_LOCUS (t), fdecl);
	  else
	    warning (0, "%Hignoring return value of function "
		     "declared with attribute warn_unused_result",
		     EXPR_LOCUS (t));
	}
      break;
    default:
      break;
    }
}
void c_warn_unused_result ( tree * top_p ) { tree t = * top_p ; tree_stmt_iterator i ; tree fdecl , ftype ; switch ( TREE_CODE ( t ) ) { case STATEMENT_LIST : for ( i = tsi_start ( * top_p ) ; ! tsi_end_p ( i ) ; tsi_next ( & i ) ) c_warn_unused_result ( tsi_stmt_ptr ( i ) ) ; break ; case COND_EXPR : c_warn_unused_result ( & COND_EXPR_THEN ( t ) ) ; c_warn_unused_result ( & COND_EXPR_ELSE ( t ) ) ; break ; case BIND_EXPR : c_warn_unused_result ( & BIND_EXPR_BODY ( t ) ) ; break ; case TRY_FINALLY_EXPR : case TRY_CATCH_EXPR : c_warn_unused_result ( & TREE_OPERAND ( t , 0 ) ) ; c_warn_unused_result ( & TREE_OPERAND ( t , 1 ) ) ; break ; case CATCH_EXPR : c_warn_unused_result ( & CATCH_BODY ( t ) ) ; break ; case EH_FILTER_EXPR : c_warn_unused_result ( & EH_FILTER_FAILURE ( t ) ) ; break ; case CALL_EXPR : if ( TREE_USED ( t ) ) break ; fdecl = get_callee_fndecl ( t ) ; if ( fdecl ) ftype = TREE_TYPE ( fdecl ) ; else { ftype = TREE_TYPE ( TREE_OPERAND ( t , 0 ) ) ; ftype = TREE_TYPE ( ftype ) ; } if ( lookup_attribute ( " " , TYPE_ATTRIBUTES ( ftype ) ) ) { if ( fdecl ) warning ( 0 , " " " " , EXPR_LOCUS ( t ) , fdecl ) ; else warning ( 0 , " " " " , EXPR_LOCUS ( t ) ) ; } break ; default : break ; } }
Walk a gimplified function and warn for functions whose return value is
ignored and attribute((warn_unused_result)) is set.
Walk a gimplified function and warn for functions whose return value is ignored and attribute (( warn_unused_result )) is set .
/* This is a naked call, as opposed to a CALL_EXPR nested inside
	 a MODIFY_EXPR.  All calls whose value is ignored should be
	 represented like this.  Look for the attribute.  */ /* Look past pointer-to-function to the function type itself.  */ /* Not a container, not a call, or a call whose value is used.  */