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: C PATCH to fix missing -Wlogical-op warning (PR c/80525)


On 05/04/2017 06:23 AM, Marek Polacek wrote:
On Thu, May 04, 2017 at 02:13:24PM +0200, Richard Biener wrote:
On Thu, May 4, 2017 at 2:11 PM, Marek Polacek <polacek@redhat.com> wrote:
On Thu, May 04, 2017 at 12:42:03PM +0200, Richard Biener wrote:
+static tree
+unwrap_c_maybe_const (tree *tp, int *walk_subtrees, void *)
+{
+  if (TREE_CODE (*tp) == C_MAYBE_CONST_EXPR)
+    {
+      *tp = C_MAYBE_CONST_EXPR_EXPR (*tp);
+      /* C_MAYBE_CONST_EXPRs don't nest.  */
+      *walk_subtrees = false;

This changes trees in-place -- do you need to operate on a copy?

Ugh, yes.  But I can't simply copy_node, because that creates new VAR_DECLs,
and operand_equal_p would consider them unequal.  Hmm...  We need something
else.

unshare_expr?

Yeah, so:

2017-05-04  Marek Polacek  <polacek@redhat.com>

	PR c/80525
	* c-warn.c (unwrap_c_maybe_const): New.
	(warn_logical_operator): Call it.

	* c-c++-common/Wlogical-op-1.c: Don't use -fwrapv anymore.
	* c-c++-common/Wlogical-op-2.c: New test.
OK.
jeff


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