This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: value computed is not used warnings


>>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:

    Richard>    void f() { ({ (void) 0; }); }

    Richard> We'll currently give a warning for this function with
    Richard> -Wall.  Given that this ocurrs rather a lot during a
    Richard> bootstrap, I'd like to fix it.

That looks pretty sane.  You could also do that only if the TREE_TYPE
of the STMT_EXPR is `void'.  That way, a statement-expression like:

  ({ 3; })

would still trigger the warning, which seems OK, but your example
wouldn't cause the warning.

Does the STMT_EXPR in your example have `void' type?  If not, that's
probably a bug.

Actually, I think maybe the right fix is to have warn_if_unused_value
ignore `void' expressions.  It already tries hard to avoid things that
are explicitly cast to `void' and functions that return `void', but it
doesn't deal with values that are magically `void' like a `void'
STMT_EXPR.  Does that sound like a better fix?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]