[flang] Prepare for review.
authorpeter klausler <pklausler@nvidia.com>
Wed, 13 Jun 2018 16:22:50 +0000 (09:22 -0700)
committerpeter klausler <pklausler@nvidia.com>
Thu, 14 Jun 2018 20:53:03 +0000 (13:53 -0700)
Original-commit: flang-compiler/f18@266d25f630b459d1e20aa4dc9074732ad1fd07b5
Reviewed-on: https://github.com/flang-compiler/f18/pull/101
Tree-same-pre-rewrite: false

flang/lib/evaluate/integer.h
flang/lib/evaluate/real.h
flang/lib/evaluate/type.h
flang/lib/semantics/resolve-names.cc
flang/test/evaluate/CMakeLists.txt
flang/test/evaluate/fp-testing.cc
flang/test/evaluate/real.cc

index b525fb8..cdeb0ba 100644 (file)
@@ -804,7 +804,10 @@ public:
   }
 
 private:
-  constexpr Integer(std::nullptr_t) {}  // does not initialize parts
+  // A private constructor, selected by the use of nullptr,
+  // that is used by member functions when it would be a waste
+  // of time to initialize parts_[].
+  constexpr Integer(std::nullptr_t) {}
 
   // Accesses parts in little-endian order.
   constexpr const Part &LEPart(int part) const {
index c4c6307..288a6dd 100644 (file)
@@ -419,7 +419,7 @@ public:
         }
         bool guard{NextQuotientBit(top, msb, divisor)};
         bool round{NextQuotientBit(top, msb, divisor)};
-        bool sticky{msb | !top.IsZero()};
+        bool sticky{msb || !top.IsZero()};
         RoundingBits roundingBits{guard, round, sticky};
         if (exponent < 1) {
           std::int64_t rshift{1 - exponent};
index 20cac65..1880a65 100644 (file)
@@ -68,11 +68,12 @@ template<> struct Real<16> {
   using ValueType = value::Real<typename Integer<kind>::ValueType, 112>;
 };
 
+// The KIND type parameter on COMPLEX is the kind of each of its components.
 template<int KIND> struct Complex {
   static constexpr Classification classification{Classification::Complex};
   static constexpr int kind{KIND};
   static constexpr bool hasLen{false};
-  using ValueType = value::Complex<typename Real<(8 * kind / 2)>::ValueType>;
+  using ValueType = value::Complex<typename Real<kind>::ValueType>;
 };
 
 template<int KIND> struct Logical {
@@ -98,7 +99,7 @@ template<int KIND> struct Character {
 using DefaultReal = Real<4>;
 using DefaultInteger = Integer<DefaultReal::kind>;
 using IntrinsicTypeParameterType = DefaultInteger;
-using DefaultComplex = Complex<2 * DefaultReal::kind>;
+using DefaultComplex = Complex<DefaultReal::kind>;
 using DefaultLogical = Logical<DefaultReal::kind>;
 using DefaultCharacter = Character<1>;
 
index 61f7dbc..d1b7d55 100644 (file)
@@ -586,6 +586,16 @@ public:
   bool Pre(const parser::CallStmt &);
   void Post(const parser::CallStmt &);
 
+  // TODO(tkeith): Needed for clang build only (!?)
+  bool Pre(const parser::ProcedureDeclarationStmt &stmt) {
+    return DeclarationVisitor::Pre(stmt) ||
+           ImplicitRulesVisitor::Pre(stmt);
+  }
+  void Post(const parser::ProcedureDeclarationStmt &stmt) {
+    DeclarationVisitor::Post(stmt);
+    ImplicitRulesVisitor::Post(stmt);
+  }
+
 private:
   // Kind of procedure we are expecting to see in a ProcedureDesignator
   std::optional<Symbol::Flag> expectedProcFlag_;
index 9ee4c08..5f48478 100644 (file)
@@ -60,4 +60,5 @@ add_executable(real-test
 target_link_libraries(real-test
   FortranEvaluate
   FortranEvaluateTesting
+  m
 )
index 5dc718f..616d328 100644 (file)
@@ -30,7 +30,7 @@ ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
     std::fprintf(stderr, "fegetenv() failed: %s\n", std::strerror(errno));
     std::abort();
   }
-#ifdef __x86_64__
+#if defined __x86_64__
   if (treatDenormalOperandsAsZero) {
     currentFenv_.__mxcsr |= 0x0040;
   } else {
index 8327fce..42ad1fd 100644 (file)
@@ -179,6 +179,9 @@ std::uint32_t NormalizeNaN(std::uint32_t x) {
 
 std::uint32_t FlagsToBits(const RealFlags &flags) {
   std::uint32_t bits{0};
+#ifndef __clang__
+  // TODO: clang support for fenv.h is broken, so tests of flag settings
+  // are disabled.
   if (flags.test(RealFlag::Overflow)) {
     bits |= 1;
   }
@@ -194,6 +197,7 @@ std::uint32_t FlagsToBits(const RealFlags &flags) {
   if (flags.test(RealFlag::Inexact)) {
     bits |= 0x10;
   }
+#endif  // __clang__
   return bits;
 }
 
@@ -206,7 +210,9 @@ void inttest(std::int64_t x, int pass, Rounding rounding) {
   Integer8 ix{x};
   ValueWithRealFlags<Real4> real;
   real = real.value.ConvertSigned(ix, rounding);
+#ifndef __clang__  // broken and also slow
   fpenv.ClearFlags();
+#endif
   float fcheck = x;  // TODO unsigned too
   auto actualFlags{FlagsToBits(fpenv.CurrentFlags())};
   u.f = fcheck;
@@ -244,7 +250,9 @@ void subset32bit(int pass, Rounding rounding, std::uint32_t opds) {
       Real4 y{Integer4{std::uint64_t{rk}}};
       {
         ValueWithRealFlags<Real4> sum{x.Add(y, rounding)};
+#ifndef __clang__  // broken and also slow
         fpenv.ClearFlags();
+#endif
         float fcheck{fj + fk};
         auto actualFlags{FlagsToBits(fpenv.CurrentFlags())};
         u.f = fcheck;
@@ -256,7 +264,9 @@ void subset32bit(int pass, Rounding rounding, std::uint32_t opds) {
       }
       {
         ValueWithRealFlags<Real4> diff{x.Subtract(y, rounding)};
+#ifndef __clang__  // broken and also slow
         fpenv.ClearFlags();
+#endif
         float fcheck{fj - fk};
         auto actualFlags{FlagsToBits(fpenv.CurrentFlags())};
         u.f = fcheck;
@@ -268,7 +278,9 @@ void subset32bit(int pass, Rounding rounding, std::uint32_t opds) {
       }
       {
         ValueWithRealFlags<Real4> prod{x.Multiply(y, rounding)};
+#ifndef __clang__  // broken and also slow
         fpenv.ClearFlags();
+#endif
         float fcheck{fj * fk};
         auto actualFlags{FlagsToBits(fpenv.CurrentFlags())};
         u.f = fcheck;
@@ -280,7 +292,9 @@ void subset32bit(int pass, Rounding rounding, std::uint32_t opds) {
       }
       {
         ValueWithRealFlags<Real4> quot{x.Divide(y, rounding)};
+#ifndef __clang__  // broken and also slow
         fpenv.ClearFlags();
+#endif
         float fcheck{fj / fk};
         auto actualFlags{FlagsToBits(fpenv.CurrentFlags())};
         u.f = fcheck;