[flang] address comments

Original-commit: flang-compiler/f18@7b1fc24265
This commit is contained in:
Jean Perier 2019-03-11 11:33:54 -07:00
parent bfb6ba3ca2
commit 74ca600dc0
1 changed files with 9 additions and 7 deletions

View File

@ -108,16 +108,18 @@ typedef struct CFI_dim_t {
} CFI_dim_t;
#ifdef __cplusplus
namespace cfi_internal {
// C++ does not support flexible array.
// The below structure emulate a flexible array. This structure does not take
// The below structure emulates a flexible array. This structure does not take
// care of getting the memory storage. Note that it already contains one element
// because a struct cannot be empty.
struct CFI_dim_t_cpp_flexible_array : CFI_dim_t {
CFI_dim_t &operator[](int index) { return *(this + index); }
const CFI_dim_t &operator[](int index) const { return *(this + index); }
operator CFI_dim_t *() { return this; }
operator const CFI_dim_t *() const { return this; }
template<typename T> struct FlexibleArray : T {
T &operator[](int index) { return *(this + index); }
const T &operator[](int index) const { return *(this + index); }
operator T *() { return this; }
operator const T *() const { return this; }
};
}
#endif
/* 18.5.3 generic data descriptor */
@ -131,7 +133,7 @@ typedef struct CFI_cdesc_t {
CFI_attribute_t attribute;
unsigned char f18Addendum;
#ifdef __cplusplus
CFI_dim_t_cpp_flexible_array dim;
cfi_internal::FlexibleArray<CFI_dim_t> dim;
#else
CFI_dim_t dim[]; /* must appear last */
#endif