glibc/time
Joseph Myers e4043b84c4 Fix strftime build with GCC 8.
Building with current GCC mainline fails with:

strftime_l.c: In function '__strftime_internal':
strftime_l.c:719:4: error: macro expands to multiple statements [-Werror=multistatement-macros]
    digits = d > width ? d : width;          \
    ^
strftime_l.c:1260:6: note: in expansion of macro 'DO_NUMBER'
      DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);
      ^~~~~~~~~
strftime_l.c:1259:4: note: some parts of macro expansion are not guarded by this 'else' clause
    else
    ^~~~

In fact this particular instance is harmless; the code looks like:

          if (modifier == L_('O'))
            goto bad_format;
          else
            DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE);

and because of the goto, it doesn't matter that part of the expansion
isn't under the "else" conditional.  But it's also clearly bad style
to rely on that.  This patch changes DO_NUMBER and DO_NUMBER_SPACEPAD
to use do { } while (0) to avoid such problems.

Tested (full testsuite) for x86_64 (GCC 6), and with
build-many-glibcs.py with GCC mainline, in conjunction with my libgcc
patch <https://gcc.gnu.org/ml/gcc-patches/2017-06/msg02032.html>.

	* time/strftime_l.c (DO_NUMBER): Define using do { } while (0).
	(DO_NUMBER_SPACEPAD): Likewise.
2017-06-27 17:12:13 +00:00
..
bits/types Remove C++ namespace handling from glibc headers. 2017-03-16 13:31:57 +00:00
sys
Depend
Makefile
Versions
adjtime.c
alt_digit.c
asctime.c
bug-asctime.c
bug-asctime_r.c
bug-getdate1.c
bug-mktime1.c
clock.c
clocktest.c
ctime.c
ctime_r.c
datemsk
difftime.c
dysize.c
era.c
ftime.c
getdate.c
getitimer.c
gettimeofday.c
gmtime.c
lc-time-cleanup.c
localtime.c
mktime.c
offtime.c
setitimer.c
settimeofday.c
stime.c
strftime.c
strftime_l.c Fix strftime build with GCC 8. 2017-06-27 17:12:13 +00:00
strptime.c
strptime_l.c Use locale_t, not __locale_t, throughout glibc 2017-06-20 20:30:06 -04:00
test_time.c
time.c
time.h Use locale_t, not __locale_t, throughout glibc 2017-06-20 20:30:06 -04:00
timegm.c
timespec_get.c
tst-ftime.c
tst-ftime_l.c
tst-getdate.c
tst-mktime.c
tst-mktime2.c
tst-mktime3.c
tst-posixtz.c
tst-strftime.c
tst-strptime-whitespace.c
tst-strptime.c
tst-strptime2.c
tst-strptime3.c
tst-tzname.c
tst_wcsftime.c
tzfile.c timezone: Remove TZNAME_MAX limit from sysconf [BZ #15576] 2017-03-07 17:45:38 +01:00
tzset.c Update timezone code from tzcode 2017b. 2017-06-16 11:09:21 +00:00
wcsftime.c
wcsftime_l.c