[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] clang: disable the gcc-compat warnings for read_atomic
commit b0ad468512df579d71650acbbcd65ef9307c3f45 Author: Roger Pau Monné <roger.pau@xxxxxxxxxx> AuthorDate: Thu Apr 13 17:33:21 2017 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Apr 13 17:33:21 2017 +0200 clang: disable the gcc-compat warnings for read_atomic clang gcc-compat warnings can wrongly fire when certain constructions are used, at least the following flow: switch ( ... ) { case ...: while ( ({ int x; switch ( foo ) { case 1: x = 1; break; } x }) ) { ... Will cause clang to emit the following warning "'break' is bound to loop, GCC binds it to switch", which is a false positive, and both gcc and clang bind the break to the inner switch. In order to workaround this issue, disable the gcc-compat checks for the usage of the read_atomic macro. This has been reported upstream as http://bugs.llvm.org/show_bug.cgi?id=32595. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> Release-acked-by: Julien Grall <julien.grall@xxxxxxx> --- xen/include/asm-x86/atomic.h | 2 ++ xen/include/xen/compiler.h | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/xen/include/asm-x86/atomic.h b/xen/include/asm-x86/atomic.h index 2fbe705..b997a17 100644 --- a/xen/include/asm-x86/atomic.h +++ b/xen/include/asm-x86/atomic.h @@ -45,6 +45,7 @@ void __bad_atomic_size(void); #define read_atomic(p) ({ \ unsigned long x_; \ + CLANG_DISABLE_WARN_GCC_COMPAT_START \ switch ( sizeof(*(p)) ) { \ case 1: x_ = read_u8_atomic((uint8_t *)(p)); break; \ case 2: x_ = read_u16_atomic((uint16_t *)(p)); break; \ @@ -52,6 +53,7 @@ void __bad_atomic_size(void); case 8: x_ = read_u64_atomic((uint64_t *)(p)); break; \ default: x_ = 0; __bad_atomic_size(); break; \ } \ + CLANG_DISABLE_WARN_GCC_COMPAT_END \ (typeof(*(p)))x_; \ }) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index 16aeeea..533a8ea 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -100,4 +100,31 @@ # define ASM_FLAG_OUT(yes, no) no #endif +/* + * NB: we need to disable the gcc-compat warnings for clang in some places or + * else it will complain with: "'break' is bound to loop, GCC binds it to + * switch" when a switch is used inside of a while expression inside of a + * switch statement, ie: + * + * switch ( ... ) + * { + * case ...: + * while ( ({ int x; switch ( foo ) { case 1: x = 1; break; } x }) ) + * { + * ... + * + * This has already been reported upstream: + * http://bugs.llvm.org/show_bug.cgi?id=32595 + */ +#ifdef __clang__ +# define CLANG_DISABLE_WARN_GCC_COMPAT_START \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") +# define CLANG_DISABLE_WARN_GCC_COMPAT_END \ + _Pragma("clang diagnostic pop") +#else +# define CLANG_DISABLE_WARN_GCC_COMPAT_START +# define CLANG_DISABLE_WARN_GCC_COMPAT_END +#endif + #endif /* __LINUX_COMPILER_H */ -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |