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]
Other format: [Raw text]

Re: PR c++/36921 [4.3/4.4 Regression] warning "comparison does not have mathematical meaning" is not correct for overloaded operators that do not return boolean


On Fri, Dec 19, 2008 at 05:47:36PM -0500, Jason Merrill wrote:
> I agree that we don't want to warn for this code, but I think the right  
> place to fix it is in warn_about_parentheses; your patch will also  
> disable the parenthesis warnings for overloaded comparison ops, which we  
> don't want, since precedence is the same regardless of the return type.

warn_about_parentheses isn't passed the whole expr though, so it can't check
its type.

Manu's patch just stopped calling warn_about_parentheses for (non-bool
returning overloaded) comparison other than ==/!=, but when code
has tcc_comparison class other than EQ_EXPR/NE_EXPR,
    default:
      if (TREE_CODE_CLASS (code) == tcc_comparison
           && ((TREE_CODE_CLASS (code_left) == tcc_comparison
                && code_left != NE_EXPR && code_left != EQ_EXPR)
               || (TREE_CODE_CLASS (code_right) == tcc_comparison
                   && code_right != NE_EXPR && code_right != EQ_EXPR)))
        warning (OPT_Wparentheses, "comparisons like %<X<=Y<=Z%> do not "
                 "have their mathematical meaning");
is the only thing warn_about_parentheses warns about.
We already have a precedent in build_x_binary_op for avoiding
warn_about_parentheses call in other situations, in particular about
obj << x + y.

	Jakub


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