[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
This commit is contained in:
parent
1f8963c801
commit
32f901bdf9
|
@ -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) {
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in New Issue