]> Savannah Git Hosting - gnulib.git/commitdiff
parse-datetime.y: avoid spurious GCC 9 warning
authorJim Meyering <meyering@fb.com>
Sun, 24 Jun 2018 22:58:09 +0000 (15:58 -0700)
committerJim Meyering <meyering@fb.com>
Sun, 24 Jun 2018 23:10:54 +0000 (16:10 -0700)
* lib/parse-datetime.y (parse_datetime2): Save RELATIVE_TIME_0 into
a function local prior to the first "goto fail".  The prior use would
evoke this:
parse-datetime.y: In function 'parse_datetime2':
parse-datetime.y:1791:19: error: jump skips variable initialization \
  [-Werror=jump-misses-init]
parse-datetime.y:2385:2: note: label 'fail' defined here
parse-datetime.y:188:43: note: '({anonymous})' declared here
parse-datetime.y:1841:12: note: in expansion of macro 'RELATIVE_TIME_0'

ChangeLog
lib/parse-datetime.y

index 1a7110935c0630552427fbc56ab9f7cc5131a46c..ad10fbc35a97546a6b89a568ddebb7a07b610c0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2018-06-24  Jim Meyering  <meyering@fb.com>
 
+       parse-datetime.y: avoid spurious GCC 9 warning
+       * lib/parse-datetime.y (parse_datetime2): Save RELATIVE_TIME_0 into
+       a function local prior to the first "goto fail".  The prior use would
+       evoke this:
+       parse-datetime.y: In function 'parse_datetime2':
+       parse-datetime.y:1791:19: error: jump skips variable initialization \
+         [-Werror=jump-misses-init]
+       parse-datetime.y:2385:2: note: label 'fail' defined here
+       parse-datetime.y:188:43: note: '({anonymous})' declared here
+       parse-datetime.y:1841:12: note: in expansion of macro 'RELATIVE_TIME_0'
+
        canon-host.c: avoid spurious GCC 9 warning
        * lib/canon-host.c: Suppress GCC9's -Wsuggest-attribute=malloc.
 
index f14bb31dc5641bd26028535dac6736c5bc297c11..3d8666a4dfe38044136a82152b6c4be0a2a9eabc 100644 (file)
@@ -1766,6 +1766,11 @@ parse_datetime2 (struct timespec *result, char const *p,
 
   timezone_t tz = tzdefault;
 
+  /* Store a local copy prior to first "goto".  Without this, a prior use
+     below of RELATIVE_TIME_0 on the RHS might translate to an assignment-
+     to-temporary, which would trigger a -Wjump-misses-init warning.  */
+  static const relative_time rel_time_0 = RELATIVE_TIME_0;
+
   if (strncmp (p, "TZ=\"", 4) == 0)
     {
       char const *tzbase = p + 4;
@@ -1838,7 +1843,7 @@ parse_datetime2 (struct timespec *result, char const *p,
   tm.tm_isdst = tmp.tm_isdst;
 
   pc.meridian = MER24;
-  pc.rel = RELATIVE_TIME_0;
+  pc.rel = rel_time_0;
   pc.timespec_seen = false;
   pc.rels_seen = false;
   pc.dates_seen = 0;