2 ! Tests the fix for PR25072, in which mask expressions
3 ! that start with an internal or intrinsic function
4 ! reference would give a syntax error.
6 ! The fix for PR28119 is tested as well; here, the forall
7 ! statement could not be followed by another statement on
10 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
13 integer, parameter :: n = 4
15 pure logical function foot (i)
16 integer, intent(in) :: i
17 foot = (i == 2) .or. (i == 3)
24 s = (/(foot (i), i=1, n)/)
26 ! Check that non-mask case is still OK and the fix for PR28119
28 forall (i=1:n) a(i) = i ; if (any (a .ne. (/1,2,3,4/))) call abort ()
30 ! Now a mask using a function with an explicit interface
31 ! via use association.
33 forall (i=1:n, foot (i)) a(i) = i
34 if (any (a .ne. (/0,2,3,0/))) call abort ()
36 ! Now an array variable mask
38 forall (i=1:n, .not. s(i)) a(i) = i
39 if (any (a .ne. (/1,0,0,4/))) call abort ()
41 ! This was the PR - an internal function mask
43 forall (i=1:n, t (i)) a(i) = i
44 if (any (a .ne. (/0,2,0,4/))) call abort ()
46 ! Check that an expression is OK - this also gave a syntax
49 forall (i=1:n, mod (i, 2) == 0) a(i) = i
50 if (any (a .ne. (/0,2,0,4/))) call abort ()
52 ! And that an expression that used to work is OK
54 forall (i=1:n, s (i) .or. t(i)) a(i) = w (i)
55 if (any (a .ne. (/0,3,2,1/))) call abort ()
58 pure logical function t(i)
59 integer, intent(in) :: i
62 pure integer function w(i)
63 integer, intent(in) :: i
67 ! { dg-final { cleanup-modules "foo" } }