Debian Codegraph @

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

raw
1 (* Copyright (C) 2001, 2002, 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 MODULE procindirect ;
18
19
20 FROM libc IMPORT exit ;
21 TYPE
22 sec = PROCEDURE (CARDINAL) : CHAR ;
23
24 PROCEDURE first ;
25 BEGIN
26 END first ;
27
28 PROCEDURE second (c: CARDINAL) : CHAR ;
29 BEGIN
30 RETURN( 'a' )
31 END second ;
32
33 PROCEDURE fetch () : CARDINAL ;
34 BEGIN
35 RETURN( 2 )
36 END fetch ;
37
38 VAR
39 f: PROC ;
40 s: sec ;
41 b: CARDINAL ;
42 array: ARRAY [1..10] OF sec ;
43 i: CARDINAL ;
44 BEGIN
45 f := first ;
46 f ;
47 s := second ;
48 IF s(b)#'a'
49 THEN
50 exit(1)
51 END ;
52 i := fetch() ;
53 array[i] := second ;
54 i := fetch() ;
55 IF array[i](b)#'a'
56 THEN
57 exit(1)
58 END
59 END procindirect.