state of clang(1)'s -Wshift-count-negative and -Wshift-overflow
warnings
Alexander Best
arundel at freebsd.org
Thu Nov 3 19:03:12 UTC 2011
On Thu Nov 3 11, Dimitry Andric wrote:
> On 2011-11-03 11:45, Alexander Best wrote:
> ...
> > /usr/git-freebsd-head/sys/dev/ath/ath_hal/ar5210/ar5210_power.c:36:3: warning: signed shift result (0x200000000) requires 35 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
> > OS_REG_RMW_FIELD(ah, AR_SCR, AR_SCR_SLE, AR_SCR_SLE_ALLOW);
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /usr/git-freebsd-head/sys/dev/ath/ath_hal/ah_internal.h:471:42: note: expanded from macro 'OS_REG_RMW_FIELD'
> > (OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))
> > ^
> > /usr/git-freebsd-head/sys/dev/ath/ah_osdep.h:127:49: note: expanded from macro 'OS_REG_WRITE'
> > (bus_space_handle_t)(_ah)->ah_sh, (_reg), (_val))
> >
> > iirc, back then, it was labeled as a clang bug. however testing with clang tot,
> > i still get those warnings. so i just wanted to ask again, whether the warnings
> > are really bogus, or if these warnings actually indicate issues during
> > shifting?
>
> Those warnings are bogus, and due to this bug:
>
> http://llvm.org/bugs/show_bug.cgi?id=10030
>
> Unfortunately, it is still not fixed for the 3.0 release branch, and I
> don't expect it will be fixed for the actual release.
thanks for the info. so how about something like
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index a0a595f..3cb13de 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -1,12 +1,28 @@
# $FreeBSD$
#
-# Warning flags for compiling the kernel and components of the kernel:
+# XXX Disable bogus llvm warnings, complaining about perfectly valid shifts.
+# See http://llvm.org/bugs/show_bug.cgi?id=10030 for more details.
+#
+.if ${CC:T:Mclang} == "clang"
+NOSHIFTWARNS= -Wno-shift-count-negative -Wno-shift-count-overflow \
+ -Wno-shift-overflow
+.endif
+
...and then add ${NOSHIFTWARNS} to the end of CWARNFLAGS?
cheers.
alex
More information about the freebsd-toolchain
mailing list