Apply fix from D81179 only from GCC < 8
authorValentin Clement <clementval@gmail.com>
Mon, 8 Jun 2020 18:38:18 +0000 (14:38 -0400)
committerValentin Clement <clementval@gmail.com>
Mon, 8 Jun 2020 19:51:57 +0000 (15:51 -0400)
Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.

Reviewers: DavidTruby, klausler, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits, tskeith, isuruf, klausler

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D81208

flang/include/flang/Evaluate/integer.h
flang/lib/Decimal/big-radix-floating-point.h

index ecefbc4..6b91cb2 100644 (file)
@@ -805,9 +805,13 @@ public:
           if (Part ypart{y.LEPart(k)}) {
             BigPart xy{xpart};
             xy *= ypart;
-            // && to < (2 * parts) was added to avoid GCC < 8 build failure
-            // on -Werror=array-bounds
-            for (int to{ j + k }; xy != 0 && to < (2 * parts); ++to) {
+#if defined __GNUC__ && __GNUC__ < 8
+            // && to < (2 * parts) was added to avoid GCC < 8 build failure on
+            // -Werror=array-bounds. This can be removed if -Werror is disable.
+            for (int to{j + k}; xy != 0 && to < (2 * parts); ++to) {
+#else
+            for (int to{j + k}; xy != 0; ++to) {
+#endif
               xy += product[to];
               product[to] = xy & partMask;
               xy >>= partBits;
index 67f0b46..18626e2 100644 (file)
@@ -179,10 +179,13 @@ private:
       if (remove >= digits_) {
         digits_ = 0;
       } else if (remove > 0) {
+#if defined __GNUC__ && __GNUC__ < 8
         // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
-        // on -Werror=array-bounds
-        for (int j{ 0 }; j + remove < digits_ && (j + remove < maxDigits);
-             ++j) {
+        // on -Werror=array-bounds. This can be removed if -Werror is disable.
+        for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) {
+#else
+        for (int j{0}; j + remove < digits_; ++j) {
+#endif
           digit_[j] = digit_[j + remove];
         }
         digits_ -= remove;