Debian Codegraph @

gcc/testsuite/gm2/iso/run/pass/except5.mod

raw
1 (* Copyright (C) 2008 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 except5 ;
19
20 FROM libc IMPORT printf ;
21 FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
22 FROM SYSTEM IMPORT ADR, WORD, THROW ;
23
24
25 PROCEDURE fly ;
26 VAR
27 r: INTEGER ;
28 BEGIN
29 IF ip=NIL
30 THEN
31 THROW(1)
32 END ;
33 IF 4 DIV ip^ = 4
34 THEN
35 r := printf("yes it worked\n")
36 END ;
37 END fly ;
38
39 (*
40 * a heavily reduced test case, to aid debugging the compiler..
41 *)
42
43 PROCEDURE tryFlying ;
44 VAR
45 r: INTEGER ;
46 BEGIN
47 fly
48 EXCEPT
49 IF ip=NIL
50 THEN
51 r := printf("inside Modula-2 exception handler\n");
52 NEW(ip) ;
53 ip^ := 1 ;
54 RETRY
55 END
56 END tryFlying ;
57
58 VAR
59 r : INTEGER ;
60 ip: POINTER TO INTEGER ;
61 BEGIN
62 ip := NIL ;
63 tryFlying ;
64 r := printf("all done\n")
65 END except5.