febcd36f791eafc8816d1f36d27223ee70227232
[buildroot.git] /
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
5 [BZ #19444]
6
7 * with -O, -O1, -Os it fails with:
8
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) \
14 ^~
15 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f1' was declared here
16 FP_DECL_D (R);
17 ^
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
20 ^
21 ../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
22 # define FP_DECL_D(X) _FP_DECL (2, X)
23 ^~~~~~~~
24 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
25 FP_DECL_D (R);
26 ^~~~~~~~~
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)); \
29 ^~
30 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f0' was declared here
31 FP_DECL_D (R);
32 ^
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
35 ^
36 ../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
37 # define FP_DECL_D(X) _FP_DECL (2, X)
38 ^~~~~~~~
39 ../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
40 FP_DECL_D (R);
41 ^~~~~~~~~
42
43 Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
44 with -O, -O1, -Os.
45 For AARCH64 it needs one more fix in locale for -Os.
46
47 [BZ #19444]
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.
51
52
53 Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
54 ---
55 sysdeps/ieee754/soft-fp/s_fdiv.c | 12 ++++++++++++
56 1 files changed, 12 insertions(+)
57
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
62 @@ -25,6 +25,16 @@
63 #undef fdivl
64
65 #include <math-narrow.h>
66 +#include <libc-diag.h>
67 +
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");
76 #include <soft-fp.h>
77 #include <single.h>
78 #include <double.h>
79 @@ -53,4 +63,6 @@ __fdiv (double x, double y)
80 CHECK_NARROW_DIV (ret, x, y);
81 return ret;
82 }
83 +DIAG_POP_NEEDS_COMMENT;
84 +
85 libm_alias_float_double (div)
86 --
87 2.17.0
88