This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Interoperability with C int128_t type?
> I was thinking of a more straightforward way: if we compile with -
> std=gnu (the default), we make C_INT128_T defined, otherwise (when -
> std=f2003 or -std=f2008 is specified) we simply do not define it (and
> the user will have the current message, which is probably something
> like "C_INT128_T is not defined").
Is this patch OK for this extension?
Index: gcc/gcc/fortran/iso-c-binding.def
===================================================================
--- gcc.orig/gcc/fortran/iso-c-binding.def
+++ gcc/gcc/fortran/iso-c-binding.def
@@ -65,6 +65,8 @@ NAMED_INTCST (ISOCBINDING_INT8_T, "c_int
NAMED_INTCST (ISOCBINDING_INT16_T, "c_int16_t", get_int_kind_from_width
(16))
NAMED_INTCST (ISOCBINDING_INT32_T, "c_int32_t", get_int_kind_from_width
(32))
NAMED_INTCST (ISOCBINDING_INT64_T, "c_int64_t", get_int_kind_from_width
(64))
+/* GNU Extension. */
+NAMED_INTCST (ISOCBINDING_INT128_T, "c_int128_t", get_int_kind_from_width
(128))
NAMED_INTCST (ISOCBINDING_INT_LEAST8_T, "c_int_least8_t", \
get_int_kind_from_minimal_width (8))
@@ -74,12 +76,17 @@ NAMED_INTCST (ISOCBINDING_INT_LEAST32_T,
get_int_kind_from_minimal_width (32))
NAMED_INTCST (ISOCBINDING_INT_LEAST64_T, "c_int_least64_t", \
get_int_kind_from_minimal_width (64))
+/* GNU Extension. */
+NAMED_INTCST (ISOCBINDING_INT_LEAST128_T, "c_int_least128_t", \
+ get_int_kind_from_minimal_width (128))
/* TODO: Implement c_int_fast*_t. Depends on PR 448. */
NAMED_INTCST (ISOCBINDING_INT_FAST8_T, "c_int_fast8_t", -2)
NAMED_INTCST (ISOCBINDING_INT_FAST16_T, "c_int_fast16_t", -2)
NAMED_INTCST (ISOCBINDING_INT_FAST32_T, "c_int_fast32_t", -2)
NAMED_INTCST (ISOCBINDING_INT_FAST64_T, "c_int_fast64_t", -2)
+/* GNU Extension. */
+NAMED_INTCST (ISOCBINDING_INT_FAST128_T, "c_int_fast128_t", -2)
NAMED_REALCST (ISOCBINDING_FLOAT, "c_float", \
get_real_kind_from_node (float_type_node))
Index: gcc/gcc/fortran/symbol.c
===================================================================
--- gcc.orig/gcc/fortran/symbol.c
+++ gcc/gcc/fortran/symbol.c
@@ -3836,6 +3836,12 @@ generate_isocbinding_symbol (const char
#define NAMED_CHARKNDCST(a,b,c) case a :
#include "iso-c-binding.def"
+ /* c_int128_t, c_int_least128_t and c_int_fast128_t are gnu
extensions. */
+ if (gfc_notification_std (GFC_STD_GNU) == FAILURE
+ && (s == ISOCBINDING_INT128_T || s ==
ISOCBINDING_INT_LEAST128_T
+ || s == ISOCBINDING_INT_FAST128_T))
+ break;
+
tmp_sym->value = gfc_int_expr (c_interop_kinds_table[s].value);
/* Initialize an integer constant expression node. */
Thanks!
Sa