Debian Codegraph @

gcc/testsuite/gm2/iso/run/pass/except6.cpp

raw
1 /* Copyright (C) 2008-2025 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 #include <stdio.h>
19 #include <stdlib.h>
20
21 typedef unsigned int INTEGER;
22 INTEGER *ip;
23
24 void fly (void)
25 {
26 if (ip == NULL)
27 throw (INTEGER) 1;
28 if ((4 / (*ip)) == 4)
29 printf("yes it worked\n");
30 }
31
32 /*
33 * a heavily reduced test case, to aid debugging the compiler..
34 */
35
36 void tryFlying (void)
37 {
38 again:
39 try {
40 fly();
41 #if 0
42 goto fin;
43 #endif
44 }
45 catch (...) {
46 #if 1
47 if (ip == NULL) {
48 #endif
49 ip = (unsigned int *)malloc(sizeof(unsigned int));
50 *ip = 1;
51 goto again;
52 #if 1
53 }
54 #endif
55 }
56 fin:;
57 }
58
59 main()
60 {
61 ip = NULL;
62 tryFlying();
63 printf("all done\n");
64 }