https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99588

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
More complete testcase:
void bar (int, ...);
void f1 (void) { static _Atomic int x = 0; bar (0, x); }
void f2 (void) { static _Atomic int x = 0; bar (0, x += 1); }
void f3 (void) { static _Atomic int x = 0; bar (x); }
void f4 (void) { static _Atomic int x = 0; bar (x += 1); }
void f5 (void) { static _Atomic int x = 0; bar (x = 1); }
void f6 (void) { static _Atomic int x = 0; x = 1; }
void f7 (void) { static _Atomic int x = 0; x += 3; }
void f8 (void) { _Atomic int x = 0; bar (0, x); }
void f9 (void) { _Atomic int x = 0; bar (0, x += 1); }
void f10 (void) { _Atomic int x = 0; bar (x); }
void f11 (void) { _Atomic int x = 0; bar (x += 1); }
void f12 (void) { _Atomic int x = 0; bar (x = 1); }
void f13 (void) { _Atomic int x = 0; x = 1; }
void f14 (void) { _Atomic int x = 0; x += 3; }

With -D_Atomic= we warn on f6 and f13 and nothing else,
otherwise on everything but f1, f3, f8, f10.
The reason for not warning on the f{1,3,8,10} is
convert_lvalue_to_rvalue:
      /* EXPR is always read.  */
      mark_exp_read (exp.value);
So for consistency with the non-_Atomic x op= expr at least should
mark_exp_read too in build_atomic_assign (i.e. something like:
  if (modifycode != NOP_EXPR)
    mark_exp_read (lhs);
somewhere early.  That results in warning on f{5,6,12,13}, f5 and f12 still
being false positives.

Reply via email to