exception_test_1.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // exception_test_1.cc -- test exception handling for gold, file 1 of 2
  2. // Copyright (C) 2006-2015 Free Software Foundation, Inc.
  3. // Written by Ian Lance Taylor <iant@google.com>.
  4. // This file is part of gold.
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. // MA 02110-1301, USA.
  17. // This tests throwing an exception across various boundaries. This
  18. // is a general test of the exception frame handling, and the
  19. // interaction with the compiler support libraries. This is file 1,
  20. // which catches the exception. We test in several different ways:
  21. // Files 1 and 2 linked together in executable.
  22. // File 1 in executable, file 2 in shared library.
  23. // File 1 in shared library, file 2 in executable.
  24. // Files 1 and 2 linked together in shared library.
  25. // Files 1 and 2 in different shared libraries.
  26. #include "exception_test.h"
  27. bool
  28. t1()
  29. {
  30. int i;
  31. try
  32. {
  33. i = 0;
  34. f1();
  35. i = 1;
  36. }
  37. catch (...)
  38. {
  39. return i == 0;
  40. }
  41. return false;
  42. }