|
|
00db10 |
commit e4043b84c49e1cf9bcf1e8320233343ecc34f8eb
|
|
|
00db10 |
Author: Joseph Myers <joseph@codesourcery.com>
|
|
|
00db10 |
Date: Tue Jun 27 17:12:13 2017 +0000
|
|
|
00db10 |
|
|
|
00db10 |
Fix strftime build with GCC 8.
|
|
|
00db10 |
|
|
|
00db10 |
Building with current GCC mainline fails with:
|
|
|
00db10 |
|
|
|
00db10 |
strftime_l.c: In function '__strftime_internal':
|
|
|
00db10 |
strftime_l.c:719:4: error: macro expands to multiple statements [-Werror=multistatement-macros]
|
|
|
00db10 |
digits = d > width ? d : width; \
|
|
|
00db10 |
^
|
|
|
00db10 |
strftime_l.c:1260:6: note: in expansion of macro 'DO_NUMBER'
|
|
|
00db10 |
DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
|
|
|
00db10 |
^~~~~~~~~
|
|
|
00db10 |
strftime_l.c:1259:4: note: some parts of macro expansion are not guarded by this 'else' clause
|
|
|
00db10 |
else
|
|
|
00db10 |
^~~~
|
|
|
00db10 |
|
|
|
00db10 |
In fact this particular instance is harmless; the code looks like:
|
|
|
00db10 |
|
|
|
00db10 |
if (modifier == L_('O'))
|
|
|
00db10 |
goto bad_format;
|
|
|
00db10 |
else
|
|
|
00db10 |
DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
|
|
|
00db10 |
|
|
|
00db10 |
and because of the goto, it doesn't matter that part of the expansion
|
|
|
00db10 |
isn't under the "else" conditional. But it's also clearly bad style
|
|
|
00db10 |
to rely on that. This patch changes DO_NUMBER and DO_NUMBER_SPACEPAD
|
|
|
00db10 |
to use do { } while (0) to avoid such problems.
|
|
|
00db10 |
|
|
|
00db10 |
Tested (full testsuite) for x86_64 (GCC 6), and with
|
|
|
00db10 |
build-many-glibcs.py with GCC mainline, in conjunction with my libgcc
|
|
|
00db10 |
patch <https://gcc.gnu.org/ml/gcc-patches/2017-06/msg02032.html>.
|
|
|
00db10 |
|
|
|
00db10 |
* time/strftime_l.c (DO_NUMBER): Define using do { } while (0).
|
|
|
00db10 |
(DO_NUMBER_SPACEPAD): Likewise.
|
|
|
00db10 |
|
|
|
00db10 |
Index: b/time/strftime_l.c
|
|
|
00db10 |
===================================================================
|
|
|
00db10 |
--- a/time/strftime_l.c
|
|
|
00db10 |
+++ b/time/strftime_l.c
|
|
|
00db10 |
@@ -715,12 +715,22 @@ __strftime_internal (CHAR_T *s, size_t m
|
|
|
00db10 |
format_char = *f;
|
|
|
00db10 |
switch (format_char)
|
|
|
00db10 |
{
|
|
|
00db10 |
-#define DO_NUMBER(d, v) \
|
|
|
00db10 |
- digits = d > width ? d : width; \
|
|
|
00db10 |
- number_value = v; goto do_number
|
|
|
00db10 |
-#define DO_NUMBER_SPACEPAD(d, v) \
|
|
|
00db10 |
- digits = d > width ? d : width; \
|
|
|
00db10 |
- number_value = v; goto do_number_spacepad
|
|
|
00db10 |
+#define DO_NUMBER(d, v) \
|
|
|
00db10 |
+ do \
|
|
|
00db10 |
+ { \
|
|
|
00db10 |
+ digits = d > width ? d : width; \
|
|
|
00db10 |
+ number_value = v; \
|
|
|
00db10 |
+ goto do_number; \
|
|
|
00db10 |
+ } \
|
|
|
00db10 |
+ while (0)
|
|
|
00db10 |
+#define DO_NUMBER_SPACEPAD(d, v) \
|
|
|
00db10 |
+ do \
|
|
|
00db10 |
+ { \
|
|
|
00db10 |
+ digits = d > width ? d : width; \
|
|
|
00db10 |
+ number_value = v; \
|
|
|
00db10 |
+ goto do_number_spacepad; \
|
|
|
00db10 |
+ } \
|
|
|
00db10 |
+ while (0)
|
|
|
00db10 |
|
|
|
00db10 |
case L_('%'):
|
|
|
00db10 |
if (modifier != 0)
|