[flang-commits] [flang] 26f2f93 - [flang] Update to: Adjust checks of ICHAR/IACHAR argument length (#73972)

via flang-commits flang-commits at lists.llvm.org
Thu Nov 30 11:23:12 PST 2023


Author: Peter Klausler
Date: 2023-11-30T11:23:04-08:00
New Revision: 26f2f9397a681fd6a580bf80104c2e4afd599dca

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

LOG: [flang] Update to: Adjust checks of ICHAR/IACHAR argument length (#73972)

When applying ICHAR/IACHAR to a character constant with length greater
than one, resize the character constant to its first character.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp
index c60648fb195f22e..ba4bc6a04750ff7 100644
--- a/flang/lib/Evaluate/fold-integer.cpp
+++ b/flang/lib/Evaluate/fold-integer.cpp
@@ -697,7 +697,8 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
                   ScalarFunc<T, Char>(
 #ifndef _MSC_VER
                       [&FromInt64](const Scalar<Char> &c) {
-                        return FromInt64(CharacterUtils<Char::kind>::ICHAR(c));
+                        return FromInt64(CharacterUtils<Char::kind>::ICHAR(
+                            CharacterUtils<Char::kind>::Resize(c, 1)));
                       }));
 #else // _MSC_VER
       // MSVC 14 get confused by the original code above and
@@ -707,7 +708,8 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
       // so remove the FromInt64 error checking lambda that
       // seems to have caused the proble.
                       [](const Scalar<Char> &c) {
-                        return CharacterUtils<Char::kind>::ICHAR(c);
+                        return CharacterUtils<Char::kind>::ICHAR(
+                            CharacterUtils<Char::kind>::Resize(c, 1));
                       }));
 #endif // _MSC_VER
             },


        


More information about the flang-commits mailing list