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