diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2024-03-19 14:16:38 +0100 |
---|---|---|
committer | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2024-04-29 16:24:20 +0200 |
commit | 1dba1d860a1e3e32e5d061a1d6dc600c96d2597f (patch) | |
tree | 39332a8e3161341a9d08a320c2f92f1ac199369e /gcc | |
parent | f795049a829a222dc5972735c73f3f467dd29554 (diff) | |
download | gcc-1dba1d860a1e3e32e5d061a1d6dc600c96d2597f.zip gcc-1dba1d860a1e3e32e5d061a1d6dc600c96d2597f.tar.gz gcc-1dba1d860a1e3e32e5d061a1d6dc600c96d2597f.tar.bz2 |
Fortran: add F2023 ISO_FORTRAN_ENV named constants
gcc/fortran/ChangeLog:
* iso-fortran-env.def: Add logical{8,16,32,64} and
real16 named constants.
gcc/testsuite/ChangeLog:
* gfortran.dg/iso_fortran_env_8.f90: New test.
* gfortran.dg/iso_fortran_env_9.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/iso-fortran-env.def | 10 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/iso_fortran_env_8.f90 | 32 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/iso_fortran_env_9.f90 | 29 |
3 files changed, 71 insertions, 0 deletions
diff --git a/gcc/fortran/iso-fortran-env.def b/gcc/fortran/iso-fortran-env.def index ed7946a..069bbc1 100644 --- a/gcc/fortran/iso-fortran-env.def +++ b/gcc/fortran/iso-fortran-env.def @@ -68,10 +68,20 @@ NAMED_INTCST (ISOFORTRANENV_IOSTAT_EOR, "iostat_eor", LIBERROR_EOR, \ NAMED_INTCST (ISOFORTRANENV_IOSTAT_INQUIRE_INTERNAL_UNIT, \ "iostat_inquire_internal_unit", LIBERROR_INQUIRE_INTERNAL_UNIT, \ GFC_STD_F2008) +NAMED_INTCST (ISOFORTRANENV_LOGICAL8, "logical8", \ + gfc_get_int_kind_from_width_isofortranenv (8), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL16, "logical16", \ + gfc_get_int_kind_from_width_isofortranenv (16), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL32, "logical32", \ + gfc_get_int_kind_from_width_isofortranenv (32), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL64, "logical64", \ + gfc_get_int_kind_from_width_isofortranenv (64), GFC_STD_F2023) NAMED_INTCST (ISOFORTRANENV_NUMERIC_STORAGE_SIZE, "numeric_storage_size", \ gfc_numeric_storage_size, GFC_STD_F2003) NAMED_INTCST (ISOFORTRANENV_OUTPUT_UNIT, "output_unit", GFC_STDOUT_UNIT_NUMBER, \ GFC_STD_F2003) +NAMED_INTCST (ISOFORTRANENV_REAL16, "real16", \ + gfc_get_real_kind_from_width_isofortranenv (16), GFC_STD_F2023) NAMED_INTCST (ISOFORTRANENV_REAL32, "real32", \ gfc_get_real_kind_from_width_isofortranenv (32), GFC_STD_F2008) NAMED_INTCST (ISOFORTRANENV_REAL64, "real64", \ diff --git a/gcc/testsuite/gfortran.dg/iso_fortran_env_8.f90 b/gcc/testsuite/gfortran.dg/iso_fortran_env_8.f90 new file mode 100644 index 0000000..d3661b3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/iso_fortran_env_8.f90 @@ -0,0 +1,32 @@ +! { dg-do run } +! +! Check for the new Fortran 2023 ISO_FORTRAN_ENV named constants + +program test + use iso_fortran_env + implicit none + + ! These integer kinds are guaranteed on + integer(int8) :: i8 + integer(int16) :: i16 + integer(int32) :: i32 + integer(int64) :: i64 + + logical(logical8) :: l8 + logical(logical16) :: l16 + logical(logical32) :: l32 + logical(logical64) :: l64 + + ! We do not support REAL16 for now, but check it can + ! still be used in specification expressions + real(kind=max(real16, real32)) :: x + + if (logical8 /= int8) stop 1 + if (logical16 /= int16) stop 2 + if (logical32 /= int32) stop 3 + if (logical64 /= int64) stop 4 + + ! We do not support REAL16 for now + if (real16 /= -2) stop 101 + +end program test diff --git a/gcc/testsuite/gfortran.dg/iso_fortran_env_9.f90 b/gcc/testsuite/gfortran.dg/iso_fortran_env_9.f90 new file mode 100644 index 0000000..ffd70b2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/iso_fortran_env_9.f90 @@ -0,0 +1,29 @@ +! { dg-do compile } +! { dg-options "-std=f2018" } +! +! Check diagnostics for new F2023 named constants +! in ISO_FORTRAN_ENV +! + +subroutine foo + use iso_fortran_env + implicit none + logical(kind=logical8) :: x ! { dg-error "has no IMPLICIT type" } +end subroutine + +subroutine bar + use iso_fortran_env, only : logical8 ! { dg-error "not in the selected standard" } + use iso_fortran_env, only : logical16 ! { dg-error "not in the selected standard" } + use iso_fortran_env, only : logical32 ! { dg-error "not in the selected standard" } + use iso_fortran_env, only : logical64 ! { dg-error "not in the selected standard" } + use iso_fortran_env, only : real16 ! { dg-error "not in the selected standard" } + implicit none +end subroutine + +subroutine gee + use iso_fortran_env, only : int8 + use iso_fortran_env, only : int16 + use iso_fortran_env, only : int32 + use iso_fortran_env, only : int64 + implicit none +end subroutine |