Debian Codegraph @

gcc/testsuite/gm2/pim/pass/arrayint.mod

raw
1 (* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE arrayint ;
19
20
21 (*
22 sum -
23 *)
24
25 PROCEDURE sum (x: ARRAY OF INTEGER) : INTEGER ;
26 VAR
27 i: CARDINAL ;
28 s: INTEGER ;
29 BEGIN
30 s := 0 ;
31 FOR i := 0 TO HIGH(x) DO
32 INC(s, x[i])
33 END ;
34 RETURN s
35 END sum ;
36
37 VAR
38 a: ARRAY [0..10] OF INTEGER ;
39 c: INTEGER ;
40 BEGIN
41 a[0] := 0 ;
42 a[1] := 1 ;
43 a[2] := 2 ;
44 a[3] := 3 ;
45 a[4] := 4 ;
46 a[5] := 5 ;
47 a[6] := 6 ;
48 a[7] := 7 ;
49 a[8] := 8 ;
50 a[9] := 9 ;
51 a[10] := 10 ;
52 c := sum(a)
53 END arrayint.