Skip to content

Commit 71b57a3

Browse files
committed
added regression test to detect ODR violations
1 parent 0388589 commit 71b57a3

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

tests/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,11 @@ foreach executable : test_executables
188188
)
189189
endforeach
190190
endforeach
191+
192+
193+
# add the ODR-test build project
194+
executable(
195+
'odr_test',
196+
[ 'odr_test_1.cpp', 'odr_test_2.cpp' ],
197+
include_directories: include_dirs
198+
)

tests/odr_test_1.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#define TOML_ENABLE_UNRELEASED_FEATURES 1
2+
#define TOML_HEADER_ONLY 1
3+
#include "../toml.hpp"
4+
5+
int main()
6+
{
7+
return 0;
8+
}

tests/odr_test_2.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#define TOML_ENABLE_UNRELEASED_FEATURES 1
2+
#define TOML_HEADER_ONLY 1
3+
#include "../toml.hpp"

tests/vs/odr_test.vcxproj

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<VCProjectVersion>16.0</VCProjectVersion>
15+
<ProjectGuid>{723FC4CA-0E24-4956-8FDC-E537EA3847AA}</ProjectGuid>
16+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
17+
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
18+
</PropertyGroup>
19+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
20+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
21+
<ConfigurationType>Application</ConfigurationType>
22+
<UseDebugLibraries>true</UseDebugLibraries>
23+
<PlatformToolset>v143</PlatformToolset>
24+
<CharacterSet>MultiByte</CharacterSet>
25+
</PropertyGroup>
26+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
27+
<ConfigurationType>Application</ConfigurationType>
28+
<UseDebugLibraries>false</UseDebugLibraries>
29+
<PlatformToolset>v143</PlatformToolset>
30+
<WholeProgramOptimization>true</WholeProgramOptimization>
31+
<CharacterSet>MultiByte</CharacterSet>
32+
</PropertyGroup>
33+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
34+
<ImportGroup Label="PropertySheets">
35+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
36+
</ImportGroup>
37+
<Import Project="../../toml++.props" />
38+
<ItemDefinitionGroup>
39+
<ClCompile>
40+
<AdditionalIncludeDirectories>..\tests;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
41+
<ExceptionHandling>Sync</ExceptionHandling>
42+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
43+
<LanguageStandard>stdcpp17</LanguageStandard>
44+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
45+
<WarningLevel>EnableAllWarnings</WarningLevel>
46+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4127</DisableSpecificWarnings> <!-- conditional expr is constant -->
47+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4324</DisableSpecificWarnings> <!-- structure was padded due to alignment specifier -->
48+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4464</DisableSpecificWarnings> <!-- relative include path contains '..' -->
49+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4505</DisableSpecificWarnings> <!-- unreferenced local function removed -->
50+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4514</DisableSpecificWarnings> <!-- unreferenced inline function has been removed -->
51+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4577</DisableSpecificWarnings> <!-- 'noexcept' used with no exception handling mode specified -->
52+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4582</DisableSpecificWarnings> <!-- constructor is not implicitly called -->
53+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4623</DisableSpecificWarnings> <!-- default constructor was implicitly defined as deleted -->
54+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4625</DisableSpecificWarnings> <!-- copy constructor was implicitly defined as deleted -->
55+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4626</DisableSpecificWarnings> <!-- assignment operator was implicitly defined as deleted -->
56+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4710</DisableSpecificWarnings> <!-- function not inlined -->
57+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4711</DisableSpecificWarnings> <!-- function selected for automatic expansion -->
58+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4738</DisableSpecificWarnings> <!-- storing 32-bit float result in memory -->
59+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4820</DisableSpecificWarnings> <!-- N bytes padding added -->
60+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4866</DisableSpecificWarnings> <!-- compiler may not enforce ltr eval in operator[] -->
61+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4868</DisableSpecificWarnings> <!-- compiler may not enforce ltr eval in initializer list -->
62+
<DisableSpecificWarnings>%(DisableSpecificWarnings);4946</DisableSpecificWarnings> <!-- reinterpret_cast used between related classes -->
63+
<DisableSpecificWarnings>%(DisableSpecificWarnings);5026</DisableSpecificWarnings> <!-- move constructor was implicitly defined as deleted -->
64+
<DisableSpecificWarnings>%(DisableSpecificWarnings);5027</DisableSpecificWarnings> <!-- move assignment operator was implicitly defined as deleted -->
65+
<DisableSpecificWarnings>%(DisableSpecificWarnings);5039</DisableSpecificWarnings> <!-- potentially throwing function passed to 'extern "C"' -->
66+
<DisableSpecificWarnings>%(DisableSpecificWarnings);5045</DisableSpecificWarnings> <!-- Compiler will insert Spectre mitigation -->
67+
</ClCompile>
68+
</ItemDefinitionGroup>
69+
<PropertyGroup>
70+
<LocalDebuggerWorkingDirectory>$(ProjectDir)..\</LocalDebuggerWorkingDirectory>
71+
</PropertyGroup>
72+
<ItemGroup>
73+
<ClCompile Include="..\odr_test_1.cpp" />
74+
<ClCompile Include="..\odr_test_2.cpp" />
75+
</ItemGroup>
76+
<ItemGroup>
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="..\meson.build" />
80+
</ItemGroup>
81+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
82+
</Project>

toml++.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tt_decoder", "toml-test\tt_
8989
EndProject
9090
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tt_encoder", "toml-test\tt_encoder.vcxproj", "{8F673261-5DFE-4B67-937A-61FC3F0082A2}"
9191
EndProject
92+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odr_test", "tests\vs\odr_test.vcxproj", "{723FC4CA-0E24-4956-8FDC-E537EA3847AA}"
93+
EndProject
9294
Global
9395
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9496
Debug|x64 = Debug|x64
@@ -253,6 +255,10 @@ Global
253255
{8F673261-5DFE-4B67-937A-61FC3F0082A2}.Debug|x64.Build.0 = Debug|x64
254256
{8F673261-5DFE-4B67-937A-61FC3F0082A2}.Release|x64.ActiveCfg = Release|x64
255257
{8F673261-5DFE-4B67-937A-61FC3F0082A2}.Release|x64.Build.0 = Release|x64
258+
{723FC4CA-0E24-4956-8FDC-E537EA3847AA}.Debug|x64.ActiveCfg = Debug|x64
259+
{723FC4CA-0E24-4956-8FDC-E537EA3847AA}.Debug|x64.Build.0 = Debug|x64
260+
{723FC4CA-0E24-4956-8FDC-E537EA3847AA}.Release|x64.ActiveCfg = Release|x64
261+
{723FC4CA-0E24-4956-8FDC-E537EA3847AA}.Release|x64.Build.0 = Release|x64
256262
EndGlobalSection
257263
GlobalSection(SolutionProperties) = preSolution
258264
HideSolutionNode = FALSE
@@ -297,6 +303,7 @@ Global
297303
{407FCAA8-FC2C-424D-B44B-C6A1AFAD757A} = {412816A5-9D22-4A30-BCDF-ABFB54BB3735}
298304
{8D19DE49-9687-4305-B59E-21F398415F5A} = {5DE43BF4-4EDD-4A7A-A422-764415BB3224}
299305
{8F673261-5DFE-4B67-937A-61FC3F0082A2} = {5DE43BF4-4EDD-4A7A-A422-764415BB3224}
306+
{723FC4CA-0E24-4956-8FDC-E537EA3847AA} = {4E25CF88-D7D8-4A9C-A52E-0D78281E82EC}
300307
EndGlobalSection
301308
GlobalSection(ExtensibilityGlobals) = postSolution
302309
SolutionGuid = {0926DDCC-88CD-4839-A82D-D9B99E02A0B1}

0 commit comments

Comments
 (0)