unwindtest_ffi_call.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. /* { dg-do run } */
  7. #include "ffitestcxx.h"
  8. static int checking(int a __UNUSED__, short b __UNUSED__,
  9. signed char c __UNUSED__)
  10. {
  11. throw 9;
  12. }
  13. int main (void)
  14. {
  15. ffi_cif cif;
  16. ffi_type *args[MAX_ARGS];
  17. void *values[MAX_ARGS];
  18. ffi_arg rint;
  19. signed int si;
  20. signed short ss;
  21. signed char sc;
  22. args[0] = &ffi_type_sint;
  23. values[0] = &si;
  24. args[1] = &ffi_type_sshort;
  25. values[1] = &ss;
  26. args[2] = &ffi_type_schar;
  27. values[2] = &sc;
  28. /* Initialize the cif */
  29. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
  30. &ffi_type_sint, args) == FFI_OK);
  31. si = -6;
  32. ss = -12;
  33. sc = -1;
  34. {
  35. try
  36. {
  37. ffi_call(&cif, FFI_FN(checking), &rint, values);
  38. } catch (int exception_code)
  39. {
  40. CHECK(exception_code == 9);
  41. }
  42. printf("part one OK\n");
  43. /* { dg-output "part one OK" } */
  44. }
  45. exit(0);
  46. }