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 5 Copyright 2020 Free Software Foundation, Inc. 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 23int val, test, failed; 24 25int main (void); 26 27void 28eh0 (void *p) 29{ 30 val = (int)(long)p & 7; 31 if (val) 32 abort (); 33} 34 35void 36eh1 (void *p, int x) 37{ 38 void *q = __builtin_alloca (x); 39 eh0 (q); 40 __builtin_eh_return (0, p); 41} 42 43void 44eh2a (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 49void 50eh2 (void *p) 51{ 52 eh2a (val, val, val, val, val, val, val, val, p); 53 __builtin_eh_return (0, p); 54} 55 56 57void 58continuation (void) 59{ 60 test++; 61 main (); 62} 63 64void 65fail (void) 66{ 67 failed = 1; 68 printf ("failed\n"); 69 continuation (); 70} 71 72void 73do_test1 (void) 74{ 75 if (!val) 76 eh1 (continuation, 100); 77 fail (); 78} 79 80void 81do_test2 (void) 82{ 83 if (!val) 84 eh2 (continuation); 85 fail (); 86} 87 88int 89main (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} 99