summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-04 19:07:49 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-03-04 19:07:49 +0000
commit42f7211e7b5b74c35c91ca97f2cccc740e80eb76 (patch)
tree5c113b2f153cd7081f4f600fd26e915dce0b2c07 /libgfortran/intrinsics
parentaa29908f1b5f6e4434471b2bd0ff9586b6224ca6 (diff)
downloadgcc-42f7211e7b5b74c35c91ca97f2cccc740e80eb76.tar.gz
PR 47802 Use builtins to check localtime_r return type
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170683 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r--libgfortran/intrinsics/ctime.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/ctime.c b/libgfortran/intrinsics/ctime.c
index 29a0e6f00f2..92c0431357e 100644
--- a/libgfortran/intrinsics/ctime.c
+++ b/libgfortran/intrinsics/ctime.c
@@ -40,11 +40,16 @@ strctime (char *s, size_t max, const time_t *timep)
{
#ifdef HAVE_STRFTIME
struct tm ltm;
- /* Note: We can't use the return value of localtime_r, as some
- targets provide localtime_r based on a draft of the POSIX
+ int failed;
+ /* Some targets provide a localtime_r based on a draft of the POSIX
standard where the return type is int rather than the
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);
#else
return 0;