[PATCH] D122656: [C11] Improve the diagnostic when accessing a member of an atomic struct

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 07:22:53 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/Sema/SemaExprMember.cpp:1300
+  // warning defaults to an error.
+  if (const auto *ATy = BaseType->getAs<AtomicType>()) {
+    S.Diag(OpLoc, diag::warn_atomic_member_access);
----------------
This seems to apply to both C and C++.  I guess "_Atomic" is C only, so we get to define its behavior for C++?

What does GCC do in C++ mode?


================
Comment at: clang/test/Sema/atomic-expr.c:85
+  x.val = 12; // expected-error {{accessing a member of an atomic structure or union is undefined behavior}}
+  xp->val = 12; // expected-error {{accessing a member of an atomic structure or union is undefined behavior}}
+
----------------
This still catches RHS access as well, right?  

Also, does it still 'work' with the non-qualifier version of _Atomic?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122656/new/

https://reviews.llvm.org/D122656



More information about the cfe-commits mailing list