1 From 4a06ceea33ecc220bbfe264d8f1e74de2f04e90d Mon Sep 17 00:00:00 2001
2 From: Martin Jansa <Martin.Jansa@gmail.com>
3 Date: Tue, 2 Oct 2018 15:38:43 +0000
4 Subject: [PATCH] sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O
7 * with -O, -O1, -Os it fails with:
9 In file included from ../soft-fp/soft-fp.h:318,
10 from ../sysdeps/ieee754/soft-fp/s_fdiv.c:28:
11 ../sysdeps/ieee754/soft-fp/s_fdiv.c: In function '__fdiv':
12 ../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
13 X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \
15 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f1' was declared here
18 ../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2'
19 _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
21 ../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
22 # define FP_DECL_D(X) _FP_DECL (2, X)
24 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
27 ../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
28 : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
30 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f0' was declared here
33 ../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2'
34 _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
36 ../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
37 # define FP_DECL_D(X) _FP_DECL (2, X)
39 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
43 Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
45 For AARCH64 it needs one more fix in locale for -Os.
48 * sysdeps/ieee754/soft-fp/s_fdiv.c: Include <libc-diag.h> and use
49 DIAG_PUSH_NEEDS_COMMENT, DIAG_IGNORE_NEEDS_COMMENT and
50 DIAG_POP_NEEDS_COMMENT to disable -Wmaybe-uninitialized.
53 Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
55 sysdeps/ieee754/soft-fp/s_fdiv.c | 12 ++++++++++++
56 1 files changed, 12 insertions(+)
58 diff --git a/sysdeps/ieee754/soft-fp/s_fdiv.c b/sysdeps/ieee754/soft-fp/s_fdiv.c
59 index 341339f5ed..7a15cbeee6 100644
60 --- a/sysdeps/ieee754/soft-fp/s_fdiv.c
61 +++ b/sysdeps/ieee754/soft-fp/s_fdiv.c
65 #include <math-narrow.h>
66 +#include <libc-diag.h>
68 +/* R_f[01] are not set in cases where they are not used in packing,
69 + but the compiler does not see that they are set in all cases where
70 + they are used, resulting in warnings that they may be used
71 + uninitialized. The location of the warning differs in different
72 + versions of GCC, it may be where R is defined using a macro or it
73 + may be where the macro is defined. This happens only with -O1. */
74 +DIAG_PUSH_NEEDS_COMMENT;
75 +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
79 @@ -53,4 +63,6 @@ __fdiv (double x, double y)
80 CHECK_NARROW_DIV (ret, x, y);
83 +DIAG_POP_NEEDS_COMMENT;
85 libm_alias_float_double (div)