• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Area:	ffi_call, unwind info
2    Purpose:	Check if the unwind information is passed correctly.
3    Limitations:	none.
4    PR:		none.
5    Originator:	Andreas Tobler <andreast@gcc.gnu.org> 20061213  */
6 
7 /* { dg-do run } */
8 
9 #include "ffitest.h"
10 
checking(int a __UNUSED__,short b __UNUSED__,signed char c __UNUSED__)11 static int checking(int a __UNUSED__, short b __UNUSED__,
12 		    signed char c __UNUSED__)
13 {
14   throw 9;
15 }
16 
main(void)17 int main (void)
18 {
19   ffi_cif cif;
20   ffi_type *args[MAX_ARGS];
21   void *values[MAX_ARGS];
22   ffi_arg rint;
23 
24   signed int si;
25   signed short ss;
26   signed char sc;
27 
28   args[0] = &ffi_type_sint;
29   values[0] = &si;
30   args[1] = &ffi_type_sshort;
31   values[1] = &ss;
32   args[2] = &ffi_type_schar;
33   values[2] = &sc;
34 
35   /* Initialize the cif */
36   CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
37 		     &ffi_type_sint, args) == FFI_OK);
38 
39   si = -6;
40   ss = -12;
41   sc = -1;
42   {
43     try
44       {
45 	ffi_call(&cif, FFI_FN(checking), &rint, values);
46       } catch (int exception_code)
47       {
48 	CHECK(exception_code == 9);
49       }
50     printf("part one OK\n");
51     /* { dg-output "part one OK" } */
52   }
53   exit(0);
54 }
55