[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.
GitOrigin-RevId: fc4f457fcc531871e86ecaaffc46ef98249b8e6a
diff --git a/lib/Evaluate/fold-character.cpp b/lib/Evaluate/fold-character.cpp
index a73ed52..385159e 100644
--- a/lib/Evaluate/fold-character.cpp
+++ b/lib/Evaluate/fold-character.cpp
@@ -79,7 +79,8 @@
} 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>(