Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.base / eh_return.c
blob9db06d701d51fcd82405610926ae7c0cf01d3221
1 /* This testcase is part of GDB, the GNU debugger.
3 It was copied from gcc repo, gcc/testsuite/gcc.target/aarch64/eh_return.c.
5 Copyright 2020-2023 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include <stdlib.h>
21 #include <stdio.h>
23 int val, test, failed;
25 int main (void);
27 void
28 eh0 (void *p)
30 val = (int)(long)p & 7;
31 if (val)
32 abort ();
35 void
36 eh1 (void *p, int x)
38 void *q = __builtin_alloca (x);
39 eh0 (q);
40 __builtin_eh_return (0, p);
43 void
44 eh2a (int a,int b,int c,int d,int e,int f,int g,int h, void *p)
46 val = a + b + c + d + e + f + g + h + (int)(long)p & 7;
49 void
50 eh2 (void *p)
52 eh2a (val, val, val, val, val, val, val, val, p);
53 __builtin_eh_return (0, p);
57 void
58 continuation (void)
60 test++;
61 main ();
64 void
65 fail (void)
67 failed = 1;
68 printf ("failed\n");
69 continuation ();
72 void
73 do_test1 (void)
75 if (!val)
76 eh1 (continuation, 100);
77 fail ();
80 void
81 do_test2 (void)
83 if (!val)
84 eh2 (continuation);
85 fail ();
88 int
89 main (void)
91 if (test == 0)
92 do_test1 ();
93 if (test == 1)
94 do_test2 ();
95 if (failed || test != 2)
96 exit (1);
97 exit (0);