1! { dg-do compile }
2! { dg-options "-fall-intrinsics -std=f95" }
3program save_2
4  implicit none
5  integer i
6  integer foo1, foo2, foo3, foo4
7  do i=1,10
8     if (foo1().ne.i) then
9        call abort
10     end if
11     if (foo2().ne.i) then
12        call abort
13     end if
14     if (foo3().ne.i) then
15        call abort
16     end if
17     if (foo4().ne.i) then
18        call abort
19     end if
20  end do
21end program save_2
22
23integer function foo1 ()
24  integer j
25  save
26  save ! { dg-error "Blanket SAVE" }
27  data j /0/
28  j = j + 1
29  foo1 = j
30end function foo1
31
32integer function foo2 ()
33  integer j
34  save j
35  save j ! { dg-error "Duplicate SAVE" }
36  data j /0/
37  j = j + 1
38  foo2 = j
39end function foo2
40
41integer function foo3 ()
42  integer j
43  save
44  save j ! { dg-error "SAVE statement" }
45  data j /0/
46  j = j + 1
47  foo3 = j
48end function foo3
49
50integer function foo4 ()
51  integer j ! { dg-error "Duplicate SAVE" }
52  save j
53  save
54  data j /0/
55  j = j + 1
56  foo4 = j
57end function foo4
58