From 1131551d0a2c91dc6e337c277fd6a563921ebcb8 Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Thu, 29 Nov 2018 13:17:53 -0800 Subject: [PATCH] [flang] Removed unnecessary reinterpret_cast. Original-commit: flang-compiler/f18@dd08a7fd3c899aacf51c85fff57692cf16ce92a3 Reviewed-on: https://github.com/flang-compiler/f18/pull/227 --- flang/runtime/ISO_Fortran_binding.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flang/runtime/ISO_Fortran_binding.cc b/flang/runtime/ISO_Fortran_binding.cc index ab98a6ea..c443017 100644 --- a/flang/runtime/ISO_Fortran_binding.cc +++ b/flang/runtime/ISO_Fortran_binding.cc @@ -15,6 +15,7 @@ // Implements the required interoperability API from ISO_Fortran_binding.h // as specified in section 18.5.5 of Fortran 2018. +#include "../include/flang/ISO_Fortran_binding.h" #include "descriptor.h" namespace Fortran::ISO { @@ -29,13 +30,13 @@ static inline constexpr bool IsAssumedSize(const CFI_cdesc_t *dv) { void *CFI_address( const CFI_cdesc_t *descriptor, const CFI_index_t subscripts[]) { - auto p = reinterpret_cast(descriptor->base_addr); - std::size_t rank{descriptor->rank}; + char *p{static_cast(descriptor->base_addr)}; + const CFI_rank_t rank{descriptor->rank}; const CFI_dim_t *dim{descriptor->dim}; - for (std::size_t j{0}; j < rank; ++j, ++dim) { + for (CFI_rank_t j{0}; j < rank; ++j, ++dim) { p += (subscripts[j] - dim->lower_bound) * dim->sm; } - return reinterpret_cast(p); + return p; } int CFI_allocate(CFI_cdesc_t *descriptor, const CFI_index_t lower_bounds[], @@ -187,7 +188,7 @@ int CFI_establish(CFI_cdesc_t *descriptor, void *base_addr, descriptor->attribute = attribute; descriptor->f18Addendum = 0; std::size_t byteSize{elem_len}; - const std::size_t lower_bound{0}; + constexpr std::size_t lower_bound{0}; if (base_addr != nullptr) { for (std::size_t j{0}; j < rank; ++j) { descriptor->dim[j].lower_bound = lower_bound; @@ -307,8 +308,7 @@ int CFI_select_part(CFI_cdesc_t *result, const CFI_cdesc_t *source, return CFI_INVALID_ELEM_LEN; } - result->base_addr = reinterpret_cast( - displacement + reinterpret_cast(source->base_addr)); + result->base_addr = displacement + static_cast(source->base_addr); result->elem_len = elem_len; for (int j{0}; j < source->rank; ++j) { result->dim[j].lower_bound = 0; -- 2.7.4