[flang-commits] [flang] fc4f457 - [flang] Fix ARM/POWER test failure (folding20.f90)

peter klausler via flang-commits flang-commits at lists.llvm.org
Wed Jun 16 16:41:17 PDT 2021


Author: peter klausler
Date: 2021-06-16T16:41:08-07:00
New Revision: fc4f457fcc531871e86ecaaffc46ef98249b8e6a

URL: https://github.com/llvm/llvm-project/commit/fc4f457fcc531871e86ecaaffc46ef98249b8e6a
DIFF: https://github.com/llvm/llvm-project/commit/fc4f457fcc531871e86ecaaffc46ef98249b8e6a.diff

LOG: [flang] Fix ARM/POWER test failure (folding20.f90)

Recent code for folding MINVAL() didn't allow for architectures
whose C/C++ char type is unsigned, so the value of the maximum
Fortran character was incorrect.  This was caught by the
folding20.f90 test.  The fix is to avoid numeric_limits<> and
use hard values for max signed integers of various character kinds.

Pushing into llvm-project/main to restore ARM/POWER buildbots.

Added: 
    

Modified: 
    flang/lib/Evaluate/fold-character.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/fold-character.cpp b/flang/lib/Evaluate/fold-character.cpp
index a73ed52672bb..385159ed2d5b 100644
--- a/flang/lib/Evaluate/fold-character.cpp
+++ b/flang/lib/Evaluate/fold-character.cpp
@@ -79,7 +79,8 @@ Expr<Type<TypeCategory::Character, KIND>> FoldIntrinsicFunction(
   } else if (name == "min") {
     return FoldMINorMAX(context, std::move(funcRef), Ordering::Less);
   } else if (name == "minval") {
-    auto most{std::numeric_limits<SingleCharType>::max()};
+    // Collating sequences correspond to positive integers (3.31)
+    SingleCharType most{0x7fffffff >> (8 * (4 - KIND))};
     if (auto identity{Identity<T>(
             StringType{most}, GetConstantLength(context, funcRef, 0))}) {
       return FoldMaxvalMinval<T>(


        


More information about the flang-commits mailing list