[flang-commits] [flang] [flang] Update to: Adjust checks of ICHAR/IACHAR argument length (PR #73972)
via flang-commits
flang-commits at lists.llvm.org
Thu Nov 30 11:23:12 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
When applying ICHAR/IACHAR to a character constant with length greater than one, resize the character constant to its first character.
---
Full diff: https://github.com/llvm/llvm-project/pull/73972.diff
1 Files Affected:
- (modified) flang/lib/Evaluate/fold-integer.cpp (+4-2)
``````````diff
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
},
``````````
</details>
https://github.com/llvm/llvm-project/pull/73972
More information about the flang-commits
mailing list