[flang-commits] [flang] [flang] Move internal Fortran::ISO namespace out of user-facing ISO_F… (PR #72909)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Nov 20 11:56:47 PST 2023
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/72909
…ortran_binding.h
... and into the ISO_Fortran_binding_wrapper.h header, through which the compiler and runtime access its contents. This change ensures that user code that #includes ISO_Fortran_binding.h within 'extern "C" {' doesn't encounter mysterious namespace errors.
>From 93f2178b0f39372d55178ae4a2a36ef579469a17 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 20 Nov 2023 11:51:32 -0800
Subject: [PATCH] [flang] Move internal Fortran::ISO namespace out of
user-facing ISO_Fortran_binding.h
... and into the ISO_Fortran_binding_wrapper.h header, through which
the compiler and runtime access its contents. This change ensures that
user code that #includes ISO_Fortran_binding.h within 'extern "C" {'
doesn't encounter mysterious namespace errors.
---
flang/include/flang/ISO_Fortran_binding.h | 6 ++----
flang/include/flang/ISO_Fortran_binding_wrapper.h | 9 +++++++++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index 51d6219427cce5e..9fac2af9e54e2de 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -10,7 +10,9 @@
#ifndef CFI_ISO_FORTRAN_BINDING_H_
#define CFI_ISO_FORTRAN_BINDING_H_
+#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
#include <stddef.h>
+#endif
/* Standard interface to Fortran from C and C++.
* These interfaces are named in subclause 18.5 of the Fortran 2018
@@ -23,8 +25,6 @@
#endif
#ifdef __cplusplus
-namespace Fortran {
-namespace ISO {
inline namespace Fortran_2018 {
#endif
@@ -200,8 +200,6 @@ RT_API_ATTRS int CFI_setpointer(
#ifdef __cplusplus
} // extern "C"
} // inline namespace Fortran_2018
-} // namespace ISO
-} // namespace Fortran
#endif
#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
diff --git a/flang/include/flang/ISO_Fortran_binding_wrapper.h b/flang/include/flang/ISO_Fortran_binding_wrapper.h
index c810ebccdbcadd5..196ebaca5ec2ccf 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/flang/include/flang/ISO_Fortran_binding_wrapper.h
@@ -22,8 +22,17 @@
*/
/* clang-format off */
+#include <stddef.h>
#include "Runtime/api-attrs.h"
+#ifdef __cplusplus
+namespace Fortran {
+namespace 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_ */
More information about the flang-commits
mailing list