Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions flang/include/flang/ISO_Fortran_binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
#ifndef CFI_ISO_FORTRAN_BINDING_H_
#define CFI_ISO_FORTRAN_BINDING_H_

/* When this header is included into the compiler and runtime implementations,
* it does so by means of a wrapper header that establishes namespaces and
* a macro for extra function attributes (RT_API_ATTRS).
*/
#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
#include <stddef.h>
#define FORTRAN_ISO_NAMESPACE_
#endif

/* Standard interface to Fortran from C and C++.
* These interfaces are named in subclause 18.5 of the Fortran 2018
Expand All @@ -22,12 +29,6 @@
#define RT_API_ATTRS
#endif

#ifdef __cplusplus
namespace Fortran {
namespace ISO {
inline namespace Fortran_2018 {
#endif

/* 18.5.4 */
#define CFI_VERSION 20180515

Expand Down Expand Up @@ -169,7 +170,8 @@ template <int r> struct CdescStorage : public CFI_cdesc_t {
template <> struct CdescStorage<1> : public CFI_cdesc_t {};
template <> struct CdescStorage<0> : public CFI_cdesc_t {};
} // namespace cfi_internal
#define CFI_CDESC_T(rank) ::Fortran::ISO::cfi_internal::CdescStorage<rank>
#define CFI_CDESC_T(rank) \
FORTRAN_ISO_NAMESPACE_::cfi_internal::CdescStorage<rank>
#else
#define CFI_CDESC_T(_RANK) \
struct { \
Expand Down Expand Up @@ -199,9 +201,6 @@ RT_API_ATTRS int CFI_setpointer(
CFI_cdesc_t *, const CFI_cdesc_t *source, const CFI_index_t lower_bounds[]);
#ifdef __cplusplus
} // extern "C"
} // inline namespace Fortran_2018
} // namespace ISO
} // namespace Fortran
#endif

#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
10 changes: 10 additions & 0 deletions flang/include/flang/ISO_Fortran_binding_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@
*/

/* clang-format off */
#include <stddef.h>
#include "Runtime/api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
#define FORTRAN_ISO_NAMESPACE_ ::Fortran::ISO
#endif /* __cplusplus */
#include "ISO_Fortran_binding.h"
#ifdef __cplusplus
} // namespace ISO
} // namespace Fortran
#endif /* __cplusplus */
/* clang-format on */

#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/CodeGen/DescriptorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ getModel<Fortran::ISO::cfi_internal::FlexibleArray<Fortran::ISO::CFI_dim_t>>() {
/// Get the type model of the field number `Field` in an ISO CFI descriptor.
template <int Field>
static constexpr TypeBuilderFunc getDescFieldTypeModel() {
Fortran::ISO::Fortran_2018::CFI_cdesc_t dummyDesc{};
Fortran::ISO::CFI_cdesc_t dummyDesc{};
// check that the descriptor is exactly 8 fields as specified in CFI_cdesc_t
// in flang/include/flang/ISO_Fortran_binding.h.
auto [a, b, c, d, e, f, g, h] = dummyDesc;
Expand Down