Introduce GFC_STD_UNSIGNED.
This patch creates an unsigned "standard" for the gfc_option.allow_std field. One of the main reason why people want UNSIGNED for Fortran is interfacing for C. This is a preparation for further work on the ISO_C_BINDING constants. That, we do via iso-c-binding.def , whose last field is a standard for the constant to be defined for the standard in question, which is then checked. I could try and invent a different method for this, but I'd rather not. gcc/fortran/ChangeLog: * intrinsic.cc (add_functions): Convert uint and selected_unsigned_kind to GFC_STD_UNSIGNED. (gfc_check_intrinsic_standard): Handle GFC_STD_UNSIGNED. * libgfortran.h (GFC_STD_UNSIGNED): Add. * options.cc (gfc_post_options): Set GFC_STD_UNSIGNED if -funsigned is set.
This commit is contained in:
parent
c92477e000
commit
54b3f8e7bc
3 changed files with 16 additions and 10 deletions
|
@ -2264,7 +2264,7 @@ add_functions (void)
|
|||
make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
|
||||
|
||||
add_sym_2 ("uint", GFC_ISYM_UINT, CLASS_ELEMENTAL, ACTUAL_NO, BT_UNSIGNED,
|
||||
di, GFC_STD_GNU, gfc_check_uint, gfc_simplify_uint,
|
||||
di, GFC_STD_UNSIGNED, gfc_check_uint, gfc_simplify_uint,
|
||||
gfc_resolve_uint, a, BT_REAL, dr, REQUIRED, kind, BT_INTEGER, di,
|
||||
OPTIONAL);
|
||||
|
||||
|
@ -2966,17 +2966,13 @@ add_functions (void)
|
|||
|
||||
make_generic ("selected_int_kind", GFC_ISYM_SI_KIND, GFC_STD_F95);
|
||||
|
||||
if (flag_unsigned)
|
||||
{
|
||||
|
||||
add_sym_1 ("selected_unsigned_kind", GFC_ISYM_SU_KIND,
|
||||
CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di,
|
||||
GFC_STD_GNU, gfc_check_selected_int_kind,
|
||||
gfc_simplify_selected_unsigned_kind, NULL, r, BT_INTEGER, di,
|
||||
REQUIRED);
|
||||
add_sym_1 ("selected_unsigned_kind", GFC_ISYM_SU_KIND,
|
||||
CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di,
|
||||
GFC_STD_UNSIGNED, gfc_check_selected_int_kind,
|
||||
gfc_simplify_selected_unsigned_kind, NULL, r, BT_INTEGER, di,
|
||||
REQUIRED);
|
||||
|
||||
make_generic ("selected_unsigned_kind", GFC_ISYM_SU_KIND, GFC_STD_GNU);
|
||||
}
|
||||
|
||||
add_sym_1 ("selected_logical_kind", GFC_ISYM_SL_KIND, CLASS_TRANSFORMATIONAL, ACTUAL_NO, BT_INTEGER, di,
|
||||
GFC_STD_F2023, /* it has the same requirements */ gfc_check_selected_int_kind,
|
||||
|
@ -4945,6 +4941,10 @@ gfc_check_intrinsic_standard (const gfc_intrinsic_sym* isym,
|
|||
symstd_msg = _("for backward compatibility");
|
||||
break;
|
||||
|
||||
case GFC_STD_UNSIGNED:
|
||||
symstd_msg = _("unsigned");
|
||||
break;
|
||||
|
||||
default:
|
||||
gfc_internal_error ("Invalid standard code on intrinsic %qs (%d)",
|
||||
isym->name, isym->standard);
|
||||
|
|
|
@ -23,6 +23,8 @@ along with GCC; see the file COPYING3. If not see
|
|||
Nevertheless, some features available in F2018 are prohibited in F2023.
|
||||
Please remember to keep those definitions in sync with
|
||||
gfortran.texi. */
|
||||
#define GFC_STD_UNSIGNED (1<<14) /* Not really a standard, but
|
||||
better for error handling. */
|
||||
#define GFC_STD_F2023_DEL (1<<13) /* Prohibited in F2023. */
|
||||
#define GFC_STD_F2023 (1<<12) /* New in F2023. */
|
||||
#define GFC_STD_F2018_DEL (1<<11) /* Deleted in F2018. */
|
||||
|
|
|
@ -539,6 +539,10 @@ gfc_post_options (const char **pfilename)
|
|||
else if (gfc_option.allow_std & GFC_STD_F2003)
|
||||
lang_hooks.name = "GNU Fortran2003";
|
||||
|
||||
/* Set the unsigned "standard". */
|
||||
if (flag_unsigned)
|
||||
gfc_option.allow_std |= GFC_STD_UNSIGNED;
|
||||
|
||||
return gfc_cpp_preprocess_only ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue