Warning, file /sdk/elf-dissector/tests/targets/virtual-methods.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 Copyright (C) 2015 Volker Krause <vkrause@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 struct Base { 0019 virtual void pure() = 0; 0020 virtual void baseOnly() {}; 0021 virtual void overridden() {}; 0022 }; 0023 0024 struct Derived : public Base { 0025 void pure() override {}; 0026 void overridden() override {}; 0027 }; 0028 0029 struct BaseWithoutVirtuals { 0030 void *m_b; 0031 }; 0032 0033 struct DerivedFromBaseWithoutVTable : BaseWithoutVirtuals { 0034 virtual void function() {}; 0035 void *m_d; 0036 }; 0037 0038 int main (int, char**) 0039 { 0040 // make sure the structures aren't optimized away by the compiler 0041 unsigned long long dummy = 0; 0042 #define USED(StructType) { StructType s; dummy += (unsigned long long)&s; } 0043 0044 USED(Derived); 0045 USED(DerivedFromBaseWithoutVTable); 0046 0047 return dummy; 0048 }