[flang-commits] [flang] 32f901b - [flang] Use CFI_TYPE_LAST instead of CFI_type_struct
Diana Picus via flang-commits
flang-commits at lists.llvm.org
Mon May 3 01:17:31 PDT 2021
Author: Diana Picus
Date: 2021-05-03T08:08:07Z
New Revision: 32f901bdf9b59a1cf43946ac7bb6c9382bc69600
URL: https://github.com/llvm/llvm-project/commit/32f901bdf9b59a1cf43946ac7bb6c9382bc69600
DIFF: https://github.com/llvm/llvm-project/commit/32f901bdf9b59a1cf43946ac7bb6c9382bc69600.diff
LOG: [flang] Use CFI_TYPE_LAST instead of CFI_type_struct
It looks like CFI_type_struct was once used as the last valid CFI_type
value, but in the meantime CFI_type_char16_t and CFI_type_char32_t were
added, making that assumption no longer true. Luckily, in the meantime
we also got a define for CFI_TYPE_LAST, which we can now use to allow
CFI_establish and CFI_allocate to work with descriptors of
CFI_type_char16_t, CFI_type_char32_t and any other future types.
Differential Revision: https://reviews.llvm.org/D101658
Added:
Modified:
flang/runtime/ISO_Fortran_binding.cpp
flang/unittests/Evaluate/ISO-Fortran-binding.cpp
Removed:
################################################################################
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index 7c2fb65ba88bc..8180c22f01a7d 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang/runtime/ISO_Fortran_binding.cpp
@@ -56,7 +56,7 @@ int CFI_allocate(CFI_cdesc_t *descriptor, const CFI_index_t lower_bounds[],
return CFI_INVALID_RANK;
}
if (descriptor->type < CFI_type_signed_char ||
- descriptor->type > CFI_type_struct) {
+ descriptor->type > CFI_TYPE_LAST) {
return CFI_INVALID_TYPE;
}
if (!IsCharacterType(descriptor->type)) {
@@ -228,7 +228,7 @@ int CFI_establish(CFI_cdesc_t *descriptor, void *base_addr,
if (rank > 0 && base_addr && !extents) {
return CFI_INVALID_EXTENT;
}
- if (type < CFI_type_signed_char || type > CFI_type_struct) {
+ if (type < CFI_type_signed_char || type > CFI_TYPE_LAST) {
return CFI_INVALID_TYPE;
}
if (!descriptor) {
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
index da9ea3521388e..e97024eb8de17 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -130,7 +130,7 @@ static void check_CFI_establish(CFI_cdesc_t *dv, void *base_addr,
++numErr;
expectedRetCode = CFI_INVALID_RANK;
}
- if (type < 0 || type > CFI_type_struct) {
+ if (type < 0 || type > CFI_TYPE_LAST) {
++numErr;
expectedRetCode = CFI_INVALID_TYPE;
}
@@ -166,7 +166,7 @@ static void run_CFI_establish_tests() {
CFI_attribute_t attrCases[]{
CFI_attribute_pointer, CFI_attribute_allocatable, CFI_attribute_other};
CFI_type_t typeCases[]{CFI_type_int, CFI_type_struct, CFI_type_double,
- CFI_type_char, CFI_type_other, CFI_type_struct + 1};
+ CFI_type_char, CFI_type_other, CFI_TYPE_LAST + 1};
CFI_index_t *extentCases[]{extents, nullptr};
void *baseAddrCases[]{dummyAddr, nullptr};
CFI_rank_t rankCases[]{0, 1, CFI_MAX_RANK, CFI_MAX_RANK + 1};
@@ -330,7 +330,7 @@ static void check_CFI_allocate(CFI_cdesc_t *dv,
++numErr;
expectedRetCode = CFI_INVALID_RANK;
}
- if (type < 0 || type > CFI_type_struct) {
+ if (type < 0 || type > CFI_TYPE_LAST) {
++numErr;
expectedRetCode = CFI_INVALID_TYPE;
}
@@ -375,7 +375,7 @@ static void run_CFI_allocate_tests() {
CFI_attribute_t attrCases[]{
CFI_attribute_pointer, CFI_attribute_allocatable, CFI_attribute_other};
CFI_type_t typeCases[]{CFI_type_int, CFI_type_struct, CFI_type_double,
- CFI_type_char, CFI_type_other, CFI_type_struct + 1};
+ CFI_type_char, CFI_type_other, CFI_TYPE_LAST + 1};
void *baseAddrCases[]{dummyAddr, nullptr};
CFI_rank_t rankCases[]{0, 1, CFI_MAX_RANK, CFI_MAX_RANK + 1};
std::size_t lenCases[]{0, 42};
More information about the flang-commits
mailing list