aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2024-10-11 22:58:51 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-10-11 23:03:11 +0200
commit54b3f8e7bc0b572c1966aece20a0ac942aa4af97 (patch)
treefae1d5bec00efcf7b4bb568ae642e7de9c5bc228 /gcc
parentc92477e00068811be31c18428904e0d585fa5236 (diff)
downloadgcc-54b3f8e7bc0b572c1966aece20a0ac942aa4af97.zip
gcc-54b3f8e7bc0b572c1966aece20a0ac942aa4af97.tar.gz
gcc-54b3f8e7bc0b572c1966aece20a0ac942aa4af97.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/intrinsic.cc20
-rw-r--r--gcc/fortran/libgfortran.h2
-rw-r--r--gcc/fortran/options.cc4
3 files changed, 16 insertions, 10 deletions
diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index 0a6be21..c6fb0a6 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -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);
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index 895629d..773f2a0 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -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. */
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index 6f2579a..d998d0e 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -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 ();
}