Debian Codegraph @

gcc/testsuite/gfortran.dg/random_seed_1.f90

raw
1 ! { dg-do compile }
2
3 ! Emit a diagnostic for too small PUT array at compile time
4 ! See PR fortran/37159
5
6 ! Updated to check for arrays of unexpected size,
7 ! this also works for -fdefault-integer-8.
8 !
9
10 PROGRAM random_seed_1
11 IMPLICIT NONE
12
13 ! Should match sizeof(master_state) in
14 ! libgfortran/intrinsics/random.c
15 INTEGER, PARAMETER :: nbytes = 32
16
17 ! '+1' to avoid out-of-bounds warnings
18 INTEGER, PARAMETER :: n = nbytes / KIND(n) + 1
19 INTEGER, DIMENSION(n) :: seed
20
21 ! Get seed, array too small
22 CALL RANDOM_SEED(GET=seed(1:(n-2))) ! { dg-error "too small" }
23
24 ! Get seed, array bigger than necessary
25 CALL RANDOM_SEED(GET=seed(1:n))
26
27 ! Get seed, proper size
28 CALL RANDOM_SEED(GET=seed(1:(n-1)))
29
30 ! Put too few bytes
31 CALL RANDOM_SEED(PUT=seed(1:(n-2))) ! { dg-error "too small" }
32
33 ! Put too many bytes
34 CALL RANDOM_SEED(PUT=seed(1:n))
35
36 ! Put the right amount of bytes
37 CALL RANDOM_SEED(PUT=seed(1:(n-1)))
38 END PROGRAM random_seed_1