[flang-commits] [PATCH] D127795: [flang][runtime] Make NCOPIES= argument of REPEAT a signed integer, & check it
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Jun 15 14:33:51 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb6c3ecd2c7a: [flang][runtime] Make NCOPIES= argument of REPEAT a signed integer, & check it (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127795/new/
https://reviews.llvm.org/D127795
Files:
flang/include/flang/Runtime/character.h
flang/runtime/character.cpp
Index: flang/runtime/character.cpp
===================================================================
--- flang/runtime/character.cpp
+++ flang/runtime/character.cpp
@@ -953,8 +953,12 @@
}
void RTNAME(Repeat)(Descriptor &result, const Descriptor &string,
- std::size_t ncopies, const char *sourceFile, int sourceLine) {
+ std::int64_t ncopies, const char *sourceFile, int sourceLine) {
Terminator terminator{sourceFile, sourceLine};
+ if (ncopies < 0) {
+ terminator.Crash(
+ "REPEAT has negative NCOPIES=%jd", static_cast<std::intmax_t>(ncopies));
+ }
std::size_t origBytes{string.ElementBytes()};
result.Establish(string.type(), origBytes * ncopies, nullptr, 0, nullptr,
CFI_attribute_allocatable);
Index: flang/include/flang/Runtime/character.h
===================================================================
--- flang/include/flang/Runtime/character.h
+++ flang/include/flang/Runtime/character.h
@@ -13,6 +13,7 @@
#define FORTRAN_RUNTIME_CHARACTER_H_
#include "flang/Runtime/entry-names.h"
#include <cstddef>
+#include <cstdint>
namespace Fortran::runtime {
@@ -97,7 +98,7 @@
void RTNAME(LenTrim)(Descriptor &result, const Descriptor &, int kind,
const char *sourceFile = nullptr, int sourceLine = 0);
void RTNAME(Repeat)(Descriptor &result, const Descriptor &string,
- std::size_t ncopies, const char *sourceFile = nullptr, int sourceLine = 0);
+ std::int64_t ncopies, const char *sourceFile = nullptr, int sourceLine = 0);
void RTNAME(Trim)(Descriptor &result, const Descriptor &string,
const char *sourceFile = nullptr, int sourceLine = 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127795.437341.patch
Type: text/x-patch
Size: 1620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220615/265018ad/attachment.bin>
More information about the flang-commits
mailing list