PR middle-end/77674
[official-gcc.git] / gcc / testsuite / gfortran.dg / initialization_14.f90
blob4d5b6856cf015b306fe24be28dd7297bbc5206a3
1 ! { dg-do compile }
2 ! PR 20851
3 ! Dummy arguments are disallowed in initialization expressions in
4 ! elemental functions except as arguments to the intrinsic functions
5 ! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed
6 ! in 13.11.8
7 MODULE TT
8 INTEGER M
9 CONTAINS
10 ELEMENTAL REAL FUNCTION two(N)
11 INTEGER, INTENT(IN) :: N
12 INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
13 END FUNCTION
15 ELEMENTAL REAL FUNCTION twopointfive(N)
16 INTEGER, INTENT(IN) :: N
17 INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" }
18 end FUNCTION twopointfive
20 REAL FUNCTION three(N)
21 INTEGER, INTENT(IN) :: N
22 INTEGER, DIMENSION(N) :: scr ! this time it's valid
23 END FUNCTION
25 ELEMENTAL REAL FUNCTION four(N)
26 INTEGER, INTENT(IN) :: N
27 INTEGER, DIMENSION(bit_size(N)) :: scr ! another valid variant
28 END FUNCTION
30 ELEMENTAL REAL FUNCTION gofourit(N)
31 INTEGER, INTENT(IN) :: N
32 INTEGER, DIMENSION(MIN(HUGE(N),1)) :: scr ! another valid variant
33 END FUNCTION
35 ELEMENTAL REAL FUNCTION fourplusone(N)
36 INTEGER, INTENT(IN) :: N
37 INTEGER, DIMENSION(M) :: scr ! another valid variant
38 END FUNCTION
40 ELEMENTAL REAL FUNCTION five(X)
41 real, intent(in) :: x
42 CHARACTER(LEN=PRECISION(X)) :: C ! valid again
43 END FUNCTION
44 END MODULE
45 END