public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH v7] c++: Add diagnostic when operator= is used as truth cond [PR25689]
@ 2022-02-16  7:16 Zhao Wei Liew
  2022-02-16 16:59 ` Jason Merrill
  0 siblings, 1 reply; 7+ messages in thread
From: Zhao Wei Liew @ 2022-02-16  7:16 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 3160 bytes --]

Before I start, sincere apologies for the email mishaps! I was setting up
an email client and somehow the emails I sent did not initially seem to
go through, but they actually did. You might have received several
duplicate emails as a result.

On Wed Feb 16, 2022 at 4:06 AM +08, Jason Merrill wrote:
> > Ah, I see. I found it a bit odd that gcc-commit-mklog auto-generated a
> > subject with "c:",
> > but I just went with it as I didn't know any better. Unfortunately, I
> > can't change it now on the current thread.
>
> That came from this line in the testcase:
>
>  > +/* PR c/25689 */
>
> The PR should be c++/25689.  Also, sometimes the bugzilla component
> isn't the same as the area of the compiler you're changing; the latter
> is what you want in the patch subject, so that the right people know to
> review it.

Oh, I see. Thanks for the explanation. I've fixed the line.

> > Ah, I didn't notice that. Sorry about that! I'm kinda new to the whole
> > mailing list setup so there are some kinks I have to iron out.
>
> FWIW it's often easier to send the patch as an attachment.

Alright, I'll send patches as attachments instead. I originally sent
them as text as it is easier to comment on them.
> > +/* Test non-empty class */
> > +void f2(B b1, B b2)
> > +{
> > + if (b1 = 0); /* { dg-warning "suggest parentheses" } */
> > + if (b1 = 0.); /* { dg-warning "suggest parentheses" } */
> > + if (b1 = b2); /* { dg-warning "suggest parentheses" } */
> > + if (b1.operator= (0));
> > +
> > + /* Ideally, we wouldn't warn for non-empty classes using trivial
> > +  operator= (below), but we currently do as it is a MODIFY_EXPR. */
> > + // if (b1.operator= (b2));
>
> You can avoid it by calling suppress_warning on that MODIFY_EXPR in
> build_over_call.

Unfortunately, that also affects the warning for if (b1 = b2) just 5
lines above. Both expressions seem to generate the same tree structure.

v6: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590419.html
1. Check for error_mark_node in is_assignment_op_expr_pr.
2. Change "c:" to "c++:".

v5: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590393.html
Changes since v5:
1. Revert changes in v4.
2. Replace gcc_assert with a return NULL_TREE in extract_call_expr.

v4: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590379.html
Changes since v4:
1. Refactor the non-assert-related code out of extract_call_expr and
   call that function instead to check for call expressions.

v3: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590310.html
Changes since v3:
1. Also handle COMPOUND_EXPRs and TARGET_EXPRs.

v2: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590236.html
Changes since v2:
1. Add more test cases in Wparentheses-31.C.
2. Refactor added logic to a function (is_assignment_overload_ref_p).
3. Use REFERENCE_REF_P instead of INDIRECT_REF_P.

v1: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590158.html
Changes since v1:
1. Use CALL_EXPR_OPERATOR_SYNTAX to avoid warnings for explicit
   operator=() calls.
2. Use INDIRECT_REF_P to filter implicit operator=() calls.
3. Use cp_get_callee_fndecl_nofold.
4. Add spaces before (.

[-- Attachment #2: 0001-c-Add-diagnostic-when-operator-is-used-as-truth-cond.patch --]
[-- Type: application/x-patch, Size: 5231 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-24 22:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16  7:16 [PATCH v7] c++: Add diagnostic when operator= is used as truth cond [PR25689] Zhao Wei Liew
2022-02-16 16:59 ` Jason Merrill
2022-02-18  0:32   ` Zhao Wei Liew
2022-02-18  3:30     ` Zhao Wei Liew
2022-03-11 22:15       ` Jason Merrill
2022-03-13 23:43         ` Zhao Wei Liew
2022-03-24 22:12           ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).