Commit 246a2730 by Janne Blomqvist

PR 47802 Use builtins to check localtime_r return type

From-SVN: r170683
parent 87e7b310
2011-03-04 Janne Blomqvist <jb@gcc.gnu.org> 2011-03-04 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802 PR libfortran/47802
* intrinsics/ctime.c (strctime): Use builtins to check localtime_r
return type.
2011-03-04 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
* intrinsics/ctime.c (strctime): Don't use return value of * intrinsics/ctime.c (strctime): Don't use return value of
localtime_r. localtime_r.
......
...@@ -40,11 +40,16 @@ strctime (char *s, size_t max, const time_t *timep) ...@@ -40,11 +40,16 @@ strctime (char *s, size_t max, const time_t *timep)
{ {
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
struct tm ltm; struct tm ltm;
/* Note: We can't use the return value of localtime_r, as some int failed;
targets provide localtime_r based on a draft of the POSIX /* Some targets provide a localtime_r based on a draft of the POSIX
standard where the return type is int rather than the standard where the return type is int rather than the
standardized struct tm*. */ standardized struct tm*. */
localtime_r (timep, &ltm); __builtin_choose_expr (__builtin_classify_type (localtime_r (timep, &ltm))
== 5,
failed = localtime_r (timep, &ltm) == NULL,
failed = localtime_r (timep, &ltm) != 0);
if (failed)
return 0;
return strftime (s, max, "%c", &ltm); return strftime (s, max, "%c", &ltm);
#else #else
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment