[flang] Implement Posix version of DATE_AND_TIME runtime
authorJean Perier <jperier@nvidia.com>
Wed, 25 Aug 2021 09:15:22 +0000 (11:15 +0200)
committerJean Perier <jperier@nvidia.com>
Wed, 25 Aug 2021 09:16:52 +0000 (11:16 +0200)
commitb3e392c081ea8d04798d58631b6f61e2901c204f
tree646416706212931915d8ac57d963d506aabfec9c
parentb5088cb408222eba4611e6121293166904ca48e6
[flang] Implement Posix version of DATE_AND_TIME runtime

Use gettimeofday and localtime_r to implement DATE_AND_TIME intrinsic.
The Windows version fallbacks to the "no date and time information
available" defined by the standard (strings set to blanks and values to
-HUGE).

The implementation uses an ifdef between windows and the rest because
from my tests, the SFINAE approach leads to undeclared name bogus errors
with clang 8 that seems to ignore failure to instantiate is not an error
for the function names (i.e., it understands it should not instantiate
the version using gettimeofday if it is not there, but still yields an
error that it is not declared on the spot where it is called in the
uninstantiated version).

Differential Revision: https://reviews.llvm.org/D108622
flang/runtime/time-intrinsic.cpp
flang/runtime/time-intrinsic.h
flang/test/Runtime/no-cpp-dep.c
flang/test/lit.cfg.py
flang/unittests/Runtime/Time.cpp