aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2024-03-19 14:16:38 +0100
committerFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2024-04-29 16:24:20 +0200
commit1dba1d860a1e3e32e5d061a1d6dc600c96d2597f (patch)
tree39332a8e3161341a9d08a320c2f92f1ac199369e /gcc/testsuite/gfortran.dg
parentf795049a829a222dc5972735c73f3f467dd29554 (diff)
downloadgcc-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/testsuite/gfortran.dg')
-rw-r--r--gcc/testsuite/gfortran.dg/iso_fortran_env_8.f9032
-rw-r--r--gcc/testsuite/gfortran.dg/iso_fortran_env_9.f9029
2 files changed, 61 insertions, 0 deletions
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