git: 58a2ebf3294f - stable/12 - Disable clang 12 -Wcompound-token-split-by-macro warning for atomic-v4.h

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Thu, 23 Dec 2021 23:34:48 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=58a2ebf3294f0b6ac3f92e66d477595073b2bf54

commit 58a2ebf3294f0b6ac3f92e66d477595073b2bf54
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-12-23 23:25:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-23 23:34:22 +0000

    Disable clang 12 -Wcompound-token-split-by-macro warning for atomic-v4.h
    
    Otherwise, the macros will in sys/arm/include/atomic-v4.h will result in
    warnings (causing -Werror errors), similar to:
    
    arm.arm/tmp/usr/include/machine/atomic-v4.h:125:2: error: '(' and '{'
    tokens introducing statement expression appear in different macro
    expansion contexts [-Werror,-Wcompound-token-split-by-macro]
            __with_interrupts_disabled(
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    The macros could be restructured to avoid this splitting of statement
    expressions, but it is less disruptive to silence the warning for clang
    >= 12.
    
    Direct commit to stable/12, since atomic-v4.h is gone (together with
    arm.arm) in stable/13 and later.
---
 sys/arm/include/atomic-v4.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/arm/include/atomic-v4.h b/sys/arm/include/atomic-v4.h
index a0083e00deaa..1d1df74af5f9 100644
--- a/sys/arm/include/atomic-v4.h
+++ b/sys/arm/include/atomic-v4.h
@@ -55,6 +55,11 @@
 #define wmb()  dmb()
 #define rmb()  dmb()
 
+#if defined(__clang_major__) && __clang_major__ >= 12
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcompound-token-split-by-macro"
+#endif
+
 #define __with_interrupts_disabled(expr) \
 	do {						\
 		u_int cpsr_save, tmp;			\
@@ -566,6 +571,10 @@ atomic_swap_32(volatile u_int32_t *p, u_int32_t v)
 #define atomic_load_acq_long		atomic_load_long
 #undef __with_interrupts_disabled
 
+#if defined(__clang_major__) && __clang_major__ >= 12
+#pragma clang diagnostic pop
+#endif
+
 static __inline void
 atomic_add_long(volatile u_long *p, u_long v)
 {