This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFA: Add support for -Wparentheses to the C++ frontend (PR c++/19564)
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Wed, 13 Dec 2006 11:26:06 -0800
- Subject: Re: PATCH RFA: Add support for -Wparentheses to the C++ frontend (PR c++/19564)
- References: <m37iwxxaqh.fsf@localhost.localdomain>
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. And, why not just have
build_x_binary_op check TREE_NO_WARNING itself? And, could we just have
one "bool honor_warn_parentheses_p" parameter?
I'm sure I'm being dense here, but I'm hoping you can tell me the answer
quicker than I can work it out.
> + /* 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.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713