This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: PATCH RFA: Add support for -Wparentheses to the C++ frontend (PR c++/19564)


Mark Mitchell <mark@codesourcery.com> writes:

> Ian Lance Taylor wrote:
> 
> >  tree
> > -build_x_binary_op (enum tree_code code, tree arg1, tree arg2,
> > -		   bool *overloaded_p)
> > +build_x_binary_op (enum tree_code code, tree arg1, enum tree_code arg1_code,
> > +		   tree arg2, enum tree_code arg2_code, bool *overloaded_p)
> 
> Please add documentation for the new arguments, documenting, in
> particular, the ERROR_MARK case.

Whoops, yeah.

> And, why not just have
> build_x_binary_op check TREE_NO_WARNING itself?

Because when called from cp_parser_binary_expression, arg1_code need
not be TREE_CODE (arg1), because the parser may have done constant
folding.

> And, could we just have
> one "bool honor_warn_parentheses_p" parameter?

Nope.

> > +  /* Check for cases such as x+y<<z which users are likely to
> > +     misinterpret.  But don't warn about obj << x + y, since that is a
> > +     common idiom for I/O.  */
> > +  if (warn_parentheses
> > +      && !processing_template_decl
> > +      && !error_operand_p (arg1)
> > +      && !error_operand_p (arg2)
> > +      && (code != LSHIFT_EXPR
> > +	  || !IS_AGGR_TYPE (TREE_TYPE (arg1))))
> > +    warn_about_parentheses (code, arg1_code, arg2_code);
> 
> It would be better to check !CLASS_TYPE_P here.  IS_AGGR_TYPE should
> really be named MAYBE_CLASS_TYPE_P -- and since we know we're not in a
> template, MAYBE_CLASS_TYPE_P is just CLASS_TYPE_P. :-)
> 
> OK with those changes.

Thanks--I will update and commit later today.

Ian


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