icf_safe_test.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // icf_safe_test.cc -- a test case for gold
  2. // Copyright (C) 2009-2015 Free Software Foundation, Inc.
  3. // Written by Sriraman Tallam <tmsriram@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. // The goal of this program is to verify if identical code folding
  18. // in safe mode correctly folds only ctors and dtors. kept_func_1 must
  19. // not be folded into kept_func_2 other than for X86 (32 and 64 bit)
  20. // which can use relocation types to determine if function pointers are
  21. // taken. kept_func_3 should never be folded as its pointer is taken.
  22. // The ctor and dtor of class A must be folded.
  23. class A
  24. {
  25. public:
  26. A()
  27. {
  28. }
  29. ~A()
  30. {
  31. }
  32. };
  33. A a;
  34. int kept_func_1()
  35. {
  36. return 1;
  37. }
  38. int kept_func_2()
  39. {
  40. return 1;
  41. }
  42. int kept_func_3()
  43. {
  44. return 1;
  45. }
  46. int main()
  47. {
  48. int (*p)() = kept_func_3;
  49. p();
  50. return 0;
  51. }