[flang] Dodge build problem in some Power environments

Original-commit: flang-compiler/f18@f24abf19c4
Reviewed-on: https://github.com/flang-compiler/f18/pull/919
This commit is contained in:
peter klausler 2020-01-09 14:01:40 -08:00
parent 1c21916785
commit 9e6d1a7892
2 changed files with 17 additions and 1 deletions

View file

@ -22,11 +22,22 @@ extern "C" {
void __FortranProgram(); // PROGRAM statement
int main(int argc, const char *argv[], const char *envp[]) {
Fortran::runtime::argc = argc;
Fortran::runtime::argv = argv;
Fortran::runtime::envp = envp;
#ifdef feclearexcept // a macro in some environments; omit std::
feclearexcept(FE_ALL_EXCEPT);
#else
std::feclearexcept(FE_ALL_EXCEPT);
#endif
#ifdef fesetround
fesetround(FE_TONEAREST);
#else
std::fesetround(FE_TONEAREST);
#endif
std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd);
// TODO: Runtime configuration settings from environment
__FortranProgram();

View file

@ -15,7 +15,12 @@
extern "C" {
static void DescribeIEEESignaledExceptions() {
if (auto excepts{std::fetestexcept(FE_ALL_EXCEPT)}) {
#ifdef fetestexcept // a macro in some environments; omit std::
auto excepts{fetestexcept(FE_ALL_EXCEPT)};
#else
auto excepts{std::fetestexcept(FE_ALL_EXCEPT)};
#endif
if (excepts) {
std::fputs("IEEE arithmetic exceptions signaled:", stderr);
if (excepts & FE_DIVBYZERO) {
std::fputs(" DIVBYZERO", stderr);