re PR target/84945 (UBSAN: gcc/config/i386/i386.c:33312:22: runtime error: shift exponent 32 is too large for 32-bit type 'int')

PR target/84945
	* config/i386/cpuinfo.c (set_feature): Wrap into do while (0) to avoid
	-Wdangling-else warnings.  Mask shift counts to avoid
	-Wshift-count-negative and -Wshift-count-overflow false positives.

From-SVN: r259398
This commit is contained in:
Jakub Jelinek 2018-04-16 13:22:40 +02:00 committed by Jakub Jelinek
parent c814ac9e69
commit a57f99ba1c
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2018-04-16 Jakub Jelinek <jakub@redhat.com>
PR target/84945
* config/i386/cpuinfo.c (set_feature): Wrap into do while (0) to avoid
-Wdangling-else warnings. Mask shift counts to avoid
-Wshift-count-negative and -Wshift-count-overflow false positives.
2018-04-06 Ruslan Bukin <br@bsdpad.com>
* config.host (riscv*-*-freebsd*): Add RISC-V FreeBSD support.

View File

@ -275,7 +275,14 @@ get_available_features (unsigned int ecx, unsigned int edx,
}
#define set_feature(f) \
if (f < 32) features |= (1U << f); else features2 |= (1U << (f - 32))
do \
{ \
if (f < 32) \
features |= (1U << (f & 31)); \
else \
features2 |= (1U << ((f - 32) & 31)); \
} \
while (0)
if (edx & bit_CMOV)
set_feature (FEATURE_CMOV);