aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/138 compute int/meson.build3
-rw-r--r--test cases/fortran/19 fortran_std/legacy.f7
-rw-r--r--test cases/fortran/19 fortran_std/meson.build27
-rw-r--r--test cases/fortran/19 fortran_std/std2003.f9036
-rw-r--r--test cases/fortran/19 fortran_std/std2008.f9032
-rw-r--r--test cases/fortran/19 fortran_std/std2018.f9034
-rw-r--r--test cases/fortran/19 fortran_std/std95.f9013
7 files changed, 152 insertions, 0 deletions
diff --git a/test cases/common/138 compute int/meson.build b/test cases/common/138 compute int/meson.build
index 22bd266..89f4746 100644
--- a/test cases/common/138 compute int/meson.build
+++ b/test cases/common/138 compute int/meson.build
@@ -10,6 +10,9 @@ foobar = cc.compute_int('FOOBAR_IN_FOOBAR_H', prefix : '#include "foobar.h"', in
maxint = cc.compute_int('INT_MAX', prefix: '#include <limits.h>')
minint = cc.compute_int('INT_MIN', prefix: '#include <limits.h>')
+# Regression test for the special case -1 that used to fail when cross compiling
+assert(cc.compute_int('-1') == -1, 'compute_int(-1) failed')
+
cd = configuration_data()
cd.set('INTSIZE', intsize)
cd.set('FOOBAR', foobar)
diff --git a/test cases/fortran/19 fortran_std/legacy.f b/test cases/fortran/19 fortran_std/legacy.f
new file mode 100644
index 0000000..339064d
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/legacy.f
@@ -0,0 +1,7 @@
+ ! non-integer loop indices are deleted in Fortran 95 standard
+ real a
+
+ do 10 a=0,0.5,0.1
+10 continue
+
+ end program \ No newline at end of file
diff --git a/test cases/fortran/19 fortran_std/meson.build b/test cases/fortran/19 fortran_std/meson.build
new file mode 100644
index 0000000..f46f8ff
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/meson.build
@@ -0,0 +1,27 @@
+project('FortranStd', 'fortran',
+ default_options: ['warning_level=0'])
+# As with C and C++, each Fortran compiler + version has a subset of supported Fortran standards
+# Additionally, a necessary option for non-standard Fortran projects is the "legacy"
+# option, which allows non-standard syntax and behavior quirks.
+# Thus "legacy" is a necessity for some old but important Fortran projects.
+# By default, popular Fortran compilers disallow these quirks without "legacy" option.
+
+fc = meson.get_compiler('fortran')
+
+executable('stdnone', 'std95.f90')
+
+executable('std_legacy', 'legacy.f', override_options : ['fortran_std=legacy'])
+
+executable('std_95', 'std95.f90', override_options : ['fortran_std=f95'])
+
+executable('std_f2003', 'std2003.f90', override_options : ['fortran_std=f2003'])
+
+executable('std_f2008', 'std2008.f90', override_options : ['fortran_std=f2008'])
+
+if fc.get_id() == 'gcc'
+ if fc.version().version_compare('>=8.0')
+ executable('std_f2018', 'std2018.f90', override_options : ['fortran_std=f2018'])
+ endif
+else
+ executable('std_f2018', 'std2018.f90', override_options : ['fortran_std=f2018'])
+endif \ No newline at end of file
diff --git a/test cases/fortran/19 fortran_std/std2003.f90 b/test cases/fortran/19 fortran_std/std2003.f90
new file mode 100644
index 0000000..08d2f50
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/std2003.f90
@@ -0,0 +1,36 @@
+use, intrinsic :: iso_fortran_env, only : error_unit
+implicit none
+
+! http://fortranwiki.org/fortran/show/Real+precision
+integer, parameter :: sp = selected_real_kind(6, 37)
+integer, parameter :: dp = selected_real_kind(15, 307)
+
+real(sp) :: a32
+real(dp) :: a64
+
+real(sp), parameter :: pi32 = 4*atan(1._sp)
+real(dp), parameter :: pi64 = 4*atan(1._dp)
+
+if (pi32 == pi64) stop 1
+
+call timestwo(a32)
+call timestwo(a64)
+
+contains
+
+elemental subroutine timestwo(a)
+
+class(*), intent(inout) :: a
+
+select type (a)
+ type is (real(sp))
+ a = 2*a
+ type is (real(dp))
+ a = 2*a
+ type is (integer)
+ a = 2*a
+end select
+
+end subroutine timestwo
+
+end program \ No newline at end of file
diff --git a/test cases/fortran/19 fortran_std/std2008.f90 b/test cases/fortran/19 fortran_std/std2008.f90
new file mode 100644
index 0000000..e7887ae
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/std2008.f90
@@ -0,0 +1,32 @@
+use, intrinsic :: iso_fortran_env, only : error_unit, sp=>real32, dp=>real64
+implicit none
+
+real(sp) :: a32
+real(dp) :: a64
+
+real(sp), parameter :: pi32 = 4*atan(1._sp)
+real(dp), parameter :: pi64 = 4*atan(1._dp)
+
+if (pi32 == pi64) error stop 'real32 values generally do not exactly equal real64 values'
+
+call timestwo(a32)
+call timestwo(a64)
+
+contains
+
+elemental subroutine timestwo(a)
+
+class(*), intent(inout) :: a
+
+select type (a)
+ type is (real(sp))
+ a = 2*a
+ type is (real(dp))
+ a = 2*a
+ type is (integer)
+ a = 2*a
+end select
+
+end subroutine timestwo
+
+end program \ No newline at end of file
diff --git a/test cases/fortran/19 fortran_std/std2018.f90 b/test cases/fortran/19 fortran_std/std2018.f90
new file mode 100644
index 0000000..9a326b1
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/std2018.f90
@@ -0,0 +1,34 @@
+use, intrinsic :: iso_fortran_env, only : error_unit, sp=>real32, dp=>real64
+implicit none
+
+real(sp) :: a32
+real(dp) :: a64
+
+real(sp), parameter :: pi32 = 4*atan(1._sp)
+real(dp), parameter :: pi64 = 4*atan(1._dp)
+
+if (pi32 == pi64) error stop 'real32 values generally do not exactly equal real64 values'
+
+call timestwo(a32)
+call timestwo(a64)
+
+contains
+
+elemental subroutine timestwo(a)
+
+class(*), intent(inout) :: a
+
+select type (a)
+ type is (real(sp))
+ a = 2*a
+ type is (real(dp))
+ a = 2*a
+ type is (integer)
+ a = 2*a
+ class default
+ error stop 'requires real32, real64 or integer'
+end select
+
+end subroutine timestwo
+
+end program \ No newline at end of file
diff --git a/test cases/fortran/19 fortran_std/std95.f90 b/test cases/fortran/19 fortran_std/std95.f90
new file mode 100644
index 0000000..8518df1
--- /dev/null
+++ b/test cases/fortran/19 fortran_std/std95.f90
@@ -0,0 +1,13 @@
+implicit none
+
+integer :: i, j
+integer, parameter :: N=3
+real :: A(N,N)
+
+A = 0
+
+forall (i=1:N, j=1:N)
+ A(i,j) = 1
+end forall
+
+end program \ No newline at end of file