diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/random_seed_1.f90 | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/random_seed_1.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/random_seed_1.f90 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/random_seed_1.f90 b/gcc/testsuite/gfortran.dg/random_seed_1.f90 new file mode 100644 index 000000000..ccbcf00cf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/random_seed_1.f90 @@ -0,0 +1,49 @@ +! { dg-do compile } + +! Emit a diagnostic for too small PUT array at compile time +! See PR fortran/37159 + +! Possible improvement: +! Provide a separate testcase for systems that support REAL(16), +! to test the minimum size of 12 (instead of 8). +! +! Updated to check for arrays of unexpected size, +! this also works for -fdefault-integer-8. +! + +PROGRAM random_seed_1 + IMPLICIT NONE + + ! Find out what the's largest kind size + INTEGER, PARAMETER :: k1 = kind (0.d0) + INTEGER, PARAMETER :: & + k2 = max (k1, selected_real_kind (precision (0._k1) + 1)) + INTEGER, PARAMETER :: & + k3 = max (k2, selected_real_kind (precision (0._k2) + 1)) + INTEGER, PARAMETER :: & + k4 = max (k3, selected_real_kind (precision (0._k3) + 1)) + + INTEGER, PARAMETER :: nbytes = MERGE(48, 32, k4 == 16) + + ! '+1' to avoid out-of-bounds warnings + INTEGER, PARAMETER :: n = nbytes / KIND(n) + 1 + INTEGER, DIMENSION(n) :: seed + + ! Get seed, array too small + CALL RANDOM_SEED(GET=seed(1:(n-2))) ! { dg-error "too small" } + + ! Get seed, array bigger than necessary + CALL RANDOM_SEED(GET=seed(1:n)) + + ! Get seed, proper size + CALL RANDOM_SEED(GET=seed(1:(n-1))) + + ! Put too few bytes + CALL RANDOM_SEED(PUT=seed(1:(n-2))) ! { dg-error "too small" } + + ! Put too many bytes + CALL RANDOM_SEED(PUT=seed(1:n)) + + ! Put the right amount of bytes + CALL RANDOM_SEED(PUT=seed(1:(n-1))) +END PROGRAM random_seed_1 |