1*56bb7041Schristos // icf_safe_test.cc -- a test case for gold 2*56bb7041Schristos 3*56bb7041Schristos // Copyright (C) 2009-2020 Free Software Foundation, Inc. 4*56bb7041Schristos // Written by Sriraman Tallam <tmsriram@google.com>. 5*56bb7041Schristos 6*56bb7041Schristos // This file is part of gold. 7*56bb7041Schristos 8*56bb7041Schristos // This program is free software; you can redistribute it and/or modify 9*56bb7041Schristos // it under the terms of the GNU General Public License as published by 10*56bb7041Schristos // the Free Software Foundation; either version 3 of the License, or 11*56bb7041Schristos // (at your option) any later version. 12*56bb7041Schristos 13*56bb7041Schristos // This program is distributed in the hope that it will be useful, 14*56bb7041Schristos // but WITHOUT ANY WARRANTY; without even the implied warranty of 15*56bb7041Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*56bb7041Schristos // GNU General Public License for more details. 17*56bb7041Schristos 18*56bb7041Schristos // You should have received a copy of the GNU General Public License 19*56bb7041Schristos // along with this program; if not, write to the Free Software 20*56bb7041Schristos // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21*56bb7041Schristos // MA 02110-1301, USA. 22*56bb7041Schristos 23*56bb7041Schristos // The goal of this program is to verify if identical code folding 24*56bb7041Schristos // in safe mode correctly folds only ctors and dtors. kept_func_1 must 25*56bb7041Schristos // not be folded into kept_func_2 other than for X86 (32 and 64 bit) 26*56bb7041Schristos // which can use relocation types to determine if function pointers are 27*56bb7041Schristos // taken. kept_func_3 should never be folded as its pointer is taken. 28*56bb7041Schristos // The ctor and dtor of class A must be folded. 29*56bb7041Schristos 30*56bb7041Schristos class A 31*56bb7041Schristos { 32*56bb7041Schristos public: A()33*56bb7041Schristos A() 34*56bb7041Schristos { 35*56bb7041Schristos } ~A()36*56bb7041Schristos ~A() 37*56bb7041Schristos { 38*56bb7041Schristos } 39*56bb7041Schristos }; 40*56bb7041Schristos 41*56bb7041Schristos A a; 42*56bb7041Schristos kept_func_1()43*56bb7041Schristosint kept_func_1() 44*56bb7041Schristos { 45*56bb7041Schristos return 1; 46*56bb7041Schristos } 47*56bb7041Schristos kept_func_2()48*56bb7041Schristosint kept_func_2() 49*56bb7041Schristos { 50*56bb7041Schristos return 1; 51*56bb7041Schristos } 52*56bb7041Schristos kept_func_3()53*56bb7041Schristosint kept_func_3() 54*56bb7041Schristos { 55*56bb7041Schristos return 1; 56*56bb7041Schristos } 57*56bb7041Schristos main()58*56bb7041Schristosint main() 59*56bb7041Schristos { 60*56bb7041Schristos int (*p)() = kept_func_3; 61*56bb7041Schristos p(); 62*56bb7041Schristos return 0; 63*56bb7041Schristos } 64