changeset 39715:13210948175b

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'
author Jim Meyering <meyering@fb.com>
date Sun, 24 Jun 2018 15:58:09 -0700
parents c0f4ce19bf80
children e8a021a8664e
files ChangeLog lib/parse-datetime.y
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jun 24 11:51:48 2018 -0700
+++ b/ChangeLog	Sun Jun 24 15:58:09 2018 -0700
@@ -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.
 
--- a/lib/parse-datetime.y	Sun Jun 24 11:51:48 2018 -0700
+++ b/lib/parse-datetime.y	Sun Jun 24 15:58:09 2018 -0700
@@ -1766,6 +1766,11 @@
 
   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 @@
   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;