================
@@ -4880,6 +4884,14 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, 
SourceRange ExprRange,
   // For an arithmetic operation, the implied arithmetic must be well-formed.
   // For _n operations, the value type must also be a valid atomic type.
   if (Form == Arithmetic || IsN) {
+    // C23 ยง7.17.7.5p1: atomic arithmetic operations are not permitted on
+    // atomic_bool (_Bool). GCC similarly rejects this. Only applies to
+    // arithmetic forms; non-arithmetic _n ops (load, store, exchange) are 
fine.
+    if (Form == Arithmetic && ValType->isBooleanType()) {
----------------
AaronBallman wrote:

Also applicable are atomic enums with an underlying type of bool:
```
enum E : bool {
  False,
  True
};

_Atomic enum E e = False;
atomic_fetch_add(&e, 1); // Should also be diagnosed
```

https://github.com/llvm/llvm-project/pull/186940
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to