]>
Commit | Line | Data |
---|---|---|
f569c1c5 TV |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | It was copied from gcc repo, gcc/testsuite/gcc.target/aarch64/eh_return.c. | |
4 | ||
1d506c26 | 5 | Copyright 2020-2024 Free Software Foundation, Inc. |
f569c1c5 TV |
6 | |
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. | |
11 | ||
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. | |
16 | ||
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/>. */ | |
19 | ||
20 | #include <stdlib.h> | |
21 | #include <stdio.h> | |
22 | ||
23 | int val, test, failed; | |
24 | ||
25 | int main (void); | |
26 | ||
27 | void | |
28 | eh0 (void *p) | |
29 | { | |
30 | val = (int)(long)p & 7; | |
31 | if (val) | |
32 | abort (); | |
33 | } | |
34 | ||
35 | void | |
36 | eh1 (void *p, int x) | |
37 | { | |
38 | void *q = __builtin_alloca (x); | |
39 | eh0 (q); | |
40 | __builtin_eh_return (0, p); | |
41 | } | |
42 | ||
43 | void | |
44 | eh2a (int a,int b,int c,int d,int e,int f,int g,int h, void *p) | |
45 | { | |
46 | val = a + b + c + d + e + f + g + h + (int)(long)p & 7; | |
47 | } | |
48 | ||
49 | void | |
50 | eh2 (void *p) | |
51 | { | |
52 | eh2a (val, val, val, val, val, val, val, val, p); | |
53 | __builtin_eh_return (0, p); | |
54 | } | |
55 | ||
56 | ||
57 | void | |
58 | continuation (void) | |
59 | { | |
60 | test++; | |
61 | main (); | |
62 | } | |
63 | ||
64 | void | |
65 | fail (void) | |
66 | { | |
67 | failed = 1; | |
68 | printf ("failed\n"); | |
69 | continuation (); | |
70 | } | |
71 | ||
72 | void | |
73 | do_test1 (void) | |
74 | { | |
75 | if (!val) | |
76 | eh1 (continuation, 100); | |
77 | fail (); | |
78 | } | |
79 | ||
80 | void | |
81 | do_test2 (void) | |
82 | { | |
83 | if (!val) | |
84 | eh2 (continuation); | |
85 | fail (); | |
86 | } | |
87 | ||
88 | int | |
89 | main (void) | |
90 | { | |
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); | |
98 | } |