From d09131eea083e80ccad60cc2686c09e9fdae0188 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 12 Oct 2024 19:09:14 +0200 Subject: Unsigned constants for ISO_FORTRAN_ENV and ISO_C_BINDING. gcc/fortran/ChangeLog: * dump-parse-tree.cc (get_c_type_name): Also handle BT_UNSIGNED. * gfortran.h (NAMED_UINTCST): Define before inclusion of iso-c-binding.def and iso-fortran-env.def. (gfc_get_uint_kind_from_width_isofortranenv): Prototype. * gfortran.texi: Mention new constants in iso_c_binding and iso_fortran_env. * iso-c-binding.def: Handle NAMED_UINTCST. Add c_unsigned, c_unsigned_short,c_unsigned_char, c_unsigned_long, c_unsigned_long_long, c_uintmax_t, c_uint8_t, c_uint16_t, c_uint32_t, c_uint64_t, c_uint128_t, c_uint_least8_t, c_uint_least16_t, c_uint_least32_t, c_uint_least64_t, c_uint_least128_t, c_uint_fast8_t, c_uint_fast16_t, c_uint_fast32_t, c_uint_fast64_t and c_uint_fast128_t. * iso-fortran-env.def: Handle NAMED_UINTCST. Add uint8, uint16, uint32 and uint64. * module.cc (parse_integer): Whitespace fix. (write_module): Whitespace fix. (NAMED_UINTCST): Define before inclusion of iso-fortran-evn.def and iso-fortran-env.def. * symbol.cc: Likewise. * trans-types.cc (get_unsigned_kind_from_node): New function. (get_uint_kind_from_name): New function. (gfc_get_uint_kind_from_width_isofortranenv): New function. (get_uint_kind_from_width): New function. (gfc_init_kinds): Initialize gfc_c_uint_kind. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_36.f90: New test. --- gcc/fortran/dump-parse-tree.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gcc/fortran/dump-parse-tree.cc') diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc index 3547d7f..bc8a95a 100644 --- a/gcc/fortran/dump-parse-tree.cc +++ b/gcc/fortran/dump-parse-tree.cc @@ -3867,7 +3867,8 @@ get_c_type_name (gfc_typespec *ts, gfc_array_spec *as, const char **pre, *asterisk = false; *post = ""; *type_name = ""; - if (ts->type == BT_REAL || ts->type == BT_INTEGER || ts->type == BT_COMPLEX) + if (ts->type == BT_REAL || ts->type == BT_INTEGER || ts->type == BT_COMPLEX + || ts->type == BT_UNSIGNED) { if (ts->is_c_interop && ts->interop_kind) ret = T_OK; @@ -3895,7 +3896,16 @@ get_c_type_name (gfc_typespec *ts, gfc_array_spec *as, const char **pre, *type_name = "__GFORTRAN_DOUBLE_COMPLEX"; else if (strcmp (*type_name, "long_double_complex") == 0) *type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX"; - + else if (strcmp (*type_name, "unsigned") == 0) + *type_name = "unsigned int"; + else if (strcmp (*type_name, "unsigned_char") == 0) + *type_name = "unsigned char"; + else if (strcmp (*type_name, "unsigned_short") == 0) + *type_name = "unsigned short int"; + else if (strcmp (*type_name, "unsigned_long") == 0) + *type_name = "unsigned long int"; + else if (strcmp (*type_name, "unsigned_long long") == 0) + *type_name = "unsigned long long int"; break; } } -- cgit v1.1