[flang] Dodge build problem in some Power environments
authorpeter klausler <pklausler@nvidia.com>
Thu, 9 Jan 2020 22:01:40 +0000 (14:01 -0800)
committerpeter klausler <pklausler@nvidia.com>
Thu, 9 Jan 2020 22:01:40 +0000 (14:01 -0800)
Original-commit: flang-compiler/f18@f24abf19c4aac3869459cd0984473ea3b5232d12
Reviewed-on: https://github.com/flang-compiler/f18/pull/919

flang/runtime/main.cc
flang/runtime/stop.cc

index dbfcd2b..58053b1 100644 (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();
index 250031e..5027c70 100644 (file)
 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);