mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Clang cl (#762)
* Added c++17 test configurations for clang5.0 and clang6.0 * Fix #739 correct cppcorecheck warnings for clang-cl * Add clang-cl configurations * Corrections Appveyor; Temporarily disable msvc compilation for faster testing (#741) * Add path to clang-cl.exe (#741) * Escape backslash in path (#741) * Update vcpkg (#741) * Check vcpkg version; try without building vcpkg; use latest clang-cl from path (#741) * Fix blocks in ps script (#741) * Try accessing APPVEYOR_BUILD_FOLDER variable (#471) * Update span size() bug confirmation test for GCC 6.5 (#741) * MSVC flags to Clang-cl; disable c++98-compat and undefined macro warnings (#741) * Suppress clang warning on tests (missing-prototypes) (#741) * Fix clang warning -Wnewline-eof (#741) * Fix clang warning -Wdouble-promotion (#741) * Set linker explicitly * Clean condition statement * For Clang, fallback to the AppVeyor installed version of CMake * Fix clang warning -Wmissing-variable-declarations * Fallback to the MSVC linker until vcpkg has been updated * Revert "Fallback to the MSVC linker until vcpkg has been updated" This reverts commit7263f3289e
. * Fix clang warning -Wunused-member-function * Fix clang warning -Wmissing-noreturn * Fix clang warning -Winvalid-noreturn on Windows * Add macro block end comment on large #if blocks * Workaround: fallback to mscv link.exe * Workaround: get msvc paths into PowerShell through intermediate file * Workaround: fix, remove "PATH=" from text * Workaround: try with full-path; and return user PATH * Workaround: fix, escape backslashes * Revert all since "Workaround: fallback to mscv link.exe" did not work on AppVeyor This reverts the commits:bda3d6a428
97062933ac
0f4fb04bac
1b0c19afd1
a5739ea5f0
* Suppress output of git pull; remove vcpkg from cache * Re-enable AppVeyor builds for all platforms * Correct typo Co-Authored-By: Farwaykorse <Farwaykorse@users.noreply.github.com> * Add Clang-cl 7.0.0 to the supported platforms * Revert "Fix clang warning -Wunused-member-function" This reverts commit6fe1a42035
. * Fix or locally suppress clang warning -Wunused-member-function * format touched code and correct comment * git pull --quiet * fix logic error in workaround * fix missing bracket * Suppress output of mkdir * Replace MSBuild with Ninja * Suppress output of 7z * Add architecture flags for Clang * Drop workaround for lld-link * 7-zip Overwrite and Alternative output suppression without suppressing errors Replaces3c1c0794dd
* AppVeyor setup and CMake before build * reorder compiler configuration * remove unnecessary * remove -fno-strict-aliasing * remove -Wsign-conversion, since before v4.0 part of -Wconversion * -Wctor-dtor-privacy is GCC only * remove -Woverloaded-virtual part of -Wmost, part of -Wall * add -Wmissing-noreturn * remove the pragmas for -Wunused-member-function * Re-add MSBuild generator on AppVeyor * Print CMake commands * Add MSBuild toolset selection * Separate Architecture setting * clang-cl: add -Weverything * clang-cl -Wno-c++98-compat * clang-cl -Wno-c++98-compat-pedantic * clang-cl -Wno-missing-prototypes * clang-cl C++14 -Wno-unused-member-function * clang-cl -Wundef __GNUC__ * clang++: add -Weverything * clang++ -Wno-c++98-compat * clang++ -Wno-c++98-compat-pedantic * clang++ -Wno-missing-prototypes * clang++ -Wno-weak-vtables * clang++ C++14 -Wno-unused-member-function * clang++ fix -Wundef _MSC_VER * clang++ -Wno-padded * clang++ solve -Wdeprecated * Add AppleClang compiler target Since CMake v3.0 use of Clang for both is deprecated * clang++ v5.0 C++17 -Wno-undefined-func-template * Add VS2015 + LLVM/clang-cl to AppVeyor * Do not disable constexpr when compiling with clang-cl on Windows * Clean-up clang-only warnings (now under -Weverything) * Revert "Fix clang warning -Winvalid-noreturn on Windows" This reverts commit2238c4760e
. * Suppress -Winvalid-noreturn for the MS STL noexception workaround * CMake: put preprocessor definition in target_compile_definitions * Solve compiler warning C4668: __GNUC__ not defined
This commit is contained in:
parent
6eeed739f1
commit
6418b5f4de
@ -27,6 +27,7 @@ The test suite that exercises GSL has been built and passes successfully on the
|
||||
* Windows using Visual Studio 2015
|
||||
* Windows using Visual Studio 2017
|
||||
* Windows using Clang/LLVM 3.6
|
||||
* Windows using Clang/LLVM 7.0.0
|
||||
* Windows using GCC 5.1
|
||||
* Windows using Intel C++ Compiler 18.0
|
||||
* GNU/Linux using Clang/LLVM 3.6
|
||||
|
88
appveyor.yml
88
appveyor.yml
@ -13,44 +13,108 @@ image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
NINJA_TAG: v1.8.2
|
||||
NINJA_SHA512: 9B9CE248240665FCD6404B989F3B3C27ED9682838225E6DC9B67B551774F251E4FF8A207504F941E7C811E7A8BE1945E7BCB94472A335EF15E23A0200A32E6D5
|
||||
NINJA_PATH: C:\Tools\ninja\ninja-%NINJA_TAG%
|
||||
VCVAR2015: 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat'
|
||||
VCVAR2017: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat'
|
||||
matrix:
|
||||
- GSL_CXX_STANDARD: 14
|
||||
USE_TOOLSET: MSVC
|
||||
USE_GENERATOR: MSBuild
|
||||
- GSL_CXX_STANDARD: 17
|
||||
USE_TOOLSET: MSVC
|
||||
USE_GENERATOR: MSBuild
|
||||
- GSL_CXX_STANDARD: 14
|
||||
USE_TOOLSET: LLVM
|
||||
USE_GENERATOR: Ninja
|
||||
- GSL_CXX_STANDARD: 17
|
||||
USE_TOOLSET: LLVM
|
||||
USE_GENERATOR: Ninja
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- image: Visual Studio 2015
|
||||
GSL_CXX_STANDARD: 17
|
||||
- image: Visual Studio 2015
|
||||
USE_TOOLSET: LLVM
|
||||
USE_GENERATOR: MSBuild
|
||||
|
||||
cache:
|
||||
- C:\cmake-3.8.0-win32-x86
|
||||
- C:\Tools\ninja
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
if (![IO.File]::Exists("$env:NINJA_PATH\ninja.exe")) {
|
||||
Start-FileDownload `
|
||||
"https://github.com/ninja-build/ninja/releases/download/$env:NINJA_TAG/ninja-win.zip"
|
||||
$hash = (Get-FileHash ninja-win.zip -Algorithm SHA512).Hash
|
||||
if ($env:NINJA_SHA512 -eq $hash) {
|
||||
7z e -y -bso0 ninja-win.zip -o"$env:NINJA_PATH"
|
||||
} else { Write-Warning "Ninja download hash changed!"; Write-Output "$hash" }
|
||||
}
|
||||
if ([IO.File]::Exists("$env:NINJA_PATH\ninja.exe")) {
|
||||
$env:PATH = "$env:NINJA_PATH;$env:PATH"
|
||||
} else { Write-Warning "Failed to find ninja.exe in expected location." }
|
||||
if ($env:USE_TOOLSET -ne "LLVM") {
|
||||
if (![IO.File]::Exists("C:\cmake-3.8.0-win32-x86\bin\cmake.exe")) {
|
||||
Start-FileDownload 'https://cmake.org/files/v3.8/cmake-3.8.0-win32-x86.zip'
|
||||
7z x -y cmake-3.8.0-win32-x86.zip -oC:\
|
||||
7z x -y -bso0 cmake-3.8.0-win32-x86.zip -oC:\
|
||||
}
|
||||
$env:PATH="C:\cmake-3.8.0-win32-x86\bin;$env:PATH"
|
||||
}
|
||||
|
||||
before_build:
|
||||
- ps: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if ("$env:APPVEYOR_JOB_NAME" -match "Image: Visual Studio 2015") {
|
||||
$env:generator="Visual Studio 14 2015"
|
||||
if ("$env:USE_GENERATOR" -eq "Ninja") {
|
||||
$GeneratorFlags = '-k 10'
|
||||
$Architecture = $env:PLATFORM
|
||||
if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2015") {
|
||||
$env:VCVARSALL = "`"$env:VCVAR2015`" $Architecture"
|
||||
} else {
|
||||
$env:generator="Visual Studio 15 2017"
|
||||
$env:VCVARSALL = "`"$env:VCVAR2017`" $Architecture"
|
||||
}
|
||||
if ($env:PLATFORM -eq "x64") {
|
||||
$env:generator="$env:generator Win64"
|
||||
$env:CMakeGenFlags = "-G Ninja -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD"
|
||||
} else {
|
||||
$GeneratorFlags = '/m /v:minimal'
|
||||
if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2015") {
|
||||
$Generator = 'Visual Studio 14 2015'
|
||||
} else {
|
||||
$Generator = 'Visual Studio 15 2017'
|
||||
}
|
||||
echo generator="$env:generator"
|
||||
cmake .. -G "$env:generator" -DGSL_CXX_STANDARD="$env:GSL_CXX_STANDARD"
|
||||
if ("$env:PLATFORM" -eq "x86") {
|
||||
$Architecture = "Win32"
|
||||
} else {
|
||||
$Architecture = "x64"
|
||||
}
|
||||
if ("$env:USE_TOOLSET" -eq "LLVM") {
|
||||
$env:CMakeGenFlags = "-G `"$Generator`" -A $Architecture -T llvm -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD"
|
||||
} else {
|
||||
$env:CMakeGenFlags = "-G `"$Generator`" -A $Architecture -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD"
|
||||
}
|
||||
}
|
||||
if ("$env:USE_TOOLSET" -eq "LLVM") {
|
||||
$env:CC = "clang-cl"
|
||||
$env:CXX = "clang-cl"
|
||||
if ("$env:PLATFORM" -eq "x86") {
|
||||
$env:CFLAGS = "-m32";
|
||||
$env:CXXFLAGS = "-m32";
|
||||
} else {
|
||||
$env:CFLAGS = "-m64";
|
||||
$env:CXXFLAGS = "-m64";
|
||||
}
|
||||
}
|
||||
$env:CMakeBuildFlags = "--config $env:CONFIGURATION -- $GeneratorFlags"
|
||||
- mkdir build
|
||||
- cd build
|
||||
- if %USE_GENERATOR%==Ninja (call %VCVARSALL%)
|
||||
- echo %CMakeGenFlags%
|
||||
- cmake .. %CMakeGenFlags%
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION% -- /m /v:minimal
|
||||
- echo %CMakeBuildFlags%
|
||||
- cmake --build . %CMakeBuildFlags%
|
||||
|
||||
test_script:
|
||||
- ctest -j2
|
||||
|
@ -22,17 +22,17 @@
|
||||
|
||||
//
|
||||
// make suppress attributes parse for some compilers
|
||||
// Hopefully temporary until suppresion standardization occurs
|
||||
// Hopefully temporary until suppression standardization occurs
|
||||
//
|
||||
#if defined (_MSC_VER)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
|
||||
#else
|
||||
#if defined(__clang__)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
|
||||
#else
|
||||
#if defined(_MSC_VER)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
|
||||
#else
|
||||
#define GSL_SUPPRESS(x)
|
||||
#endif // __clang__
|
||||
#endif // _MSC_VER
|
||||
#endif // __clang__
|
||||
|
||||
//
|
||||
// Temporary until MSVC STL supports no-exceptions mode.
|
||||
@ -42,6 +42,12 @@
|
||||
#define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND
|
||||
#include <intrin.h>
|
||||
#define RANGE_CHECKS_FAILURE 0
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winvalid-noreturn"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -138,7 +144,7 @@ namespace details
|
||||
throw std::forward<Exception>(exception);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // GSL_TERMINATE_ON_CONTRACT_VIOLATION
|
||||
|
||||
} // namespace details
|
||||
} // namespace gsl
|
||||
@ -159,9 +165,13 @@ namespace details
|
||||
|
||||
#define GSL_CONTRACT_CHECK(type, cond) GSL_ASSUME(cond)
|
||||
|
||||
#endif
|
||||
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||
|
||||
#define Expects(cond) GSL_CONTRACT_CHECK("Precondition", cond)
|
||||
#define Ensures(cond) GSL_CONTRACT_CHECK("Postcondition", cond)
|
||||
|
||||
#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) && defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // GSL_CONTRACTS_H
|
||||
|
@ -19,17 +19,17 @@
|
||||
|
||||
//
|
||||
// make suppress attributes work for some compilers
|
||||
// Hopefully temporary until suppresion standardization occurs
|
||||
// Hopefully temporary until suppression standardization occurs
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
|
||||
#else
|
||||
#if defined(__clang__)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
|
||||
#else
|
||||
#if defined(_MSC_VER)
|
||||
#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
|
||||
#else
|
||||
#define GSL_SUPPRESS(x)
|
||||
#endif // __clang__
|
||||
#endif // _MSC_VER
|
||||
#endif // __clang__
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
#endif // _MSC_VER
|
||||
|
||||
// Use __may_alias__ attribute on gcc and clang
|
||||
#if defined __clang__ || (__GNUC__ > 5)
|
||||
#if defined __clang__ || (defined(__GNUC__) && __GNUC__ > 5)
|
||||
#define byte_may_alias __attribute__((__may_alias__))
|
||||
#else // defined __clang__ || defined __GNUC__
|
||||
#define byte_may_alias
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <type_traits> // for is_signed, integral_constant
|
||||
#include <utility> // for forward
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127) // conditional expression is constant
|
||||
@ -161,7 +161,7 @@ constexpr T at(const std::initializer_list<T> cont, const index i)
|
||||
|
||||
} // namespace gsl
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#if _MSC_VER < 1910
|
||||
#undef constexpr
|
||||
#pragma pop_macro("constexpr")
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <type_traits> // for enable_if_t, remove_cv_t, is_same, is_co...
|
||||
#include <utility>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
// turn off some warnings that are noisy about our Expects statements
|
||||
#pragma warning(push)
|
||||
@ -62,7 +62,7 @@
|
||||
// compiletime, so the compiler wouldn't have to warn indiscriminently, but
|
||||
// could check if the source value actually doesn't fit into the target type
|
||||
// and only warn in those cases.
|
||||
#if __GNUC__ > 6
|
||||
#if defined(__GNUC__) && __GNUC__ > 6
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
@ -596,7 +596,6 @@ public:
|
||||
using sliced_type = static_bounds<RestRanges...>;
|
||||
using mapping_type = contiguous_mapping_tag;
|
||||
|
||||
constexpr static_bounds(const static_bounds&) noexcept = default;
|
||||
constexpr static_bounds() /*noexcept*/ = default;
|
||||
|
||||
template <typename SourceType, typename TargetType, std::size_t Rank>
|
||||
@ -1887,6 +1886,8 @@ public:
|
||||
auto d = narrow_cast<size_type>(sizeof(OtherValueType) / sizeof(value_type));
|
||||
|
||||
const size_type size = this->bounds().total_size() / d;
|
||||
|
||||
GSL_SUPPRESS(type.3) // NO-FORMAT: attribute
|
||||
return {const_cast<OtherValueType*>(reinterpret_cast<const OtherValueType*>(this->data())),
|
||||
size,
|
||||
bounds_type{resize_extent(this->bounds().index_bounds(), d),
|
||||
@ -2274,7 +2275,7 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
|
||||
|
||||
} // namespace gsl
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#if _MSC_VER < 1910
|
||||
|
||||
#undef constexpr
|
||||
@ -2285,7 +2286,7 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#if __GNUC__ > 6
|
||||
#if defined(__GNUC__) && __GNUC__ > 6
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__ > 6
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <system_error> // for hash
|
||||
#include <type_traits> // for enable_if_t, is_convertible, is_assignable
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
|
||||
#pragma push_macro("constexpr")
|
||||
#define constexpr /*constexpr*/
|
||||
|
||||
@ -283,10 +283,12 @@ struct hash<gsl::strict_not_null<T>>
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
|
||||
|
||||
#undef constexpr
|
||||
#pragma pop_macro("constexpr")
|
||||
|
||||
#endif // defined(_MSC_VER) && _MSC_VER < 1910
|
||||
#endif // defined(_MSC_VER) && _MSC_VER < 1910 && !defined(__clang__)
|
||||
|
||||
#endif // GSL_POINTERS_H
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <utility>
|
||||
#include <memory> // for std::addressof
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma warning(push)
|
||||
|
||||
// turn off some warnings that are noisy about our Expects statements
|
||||
@ -61,7 +61,7 @@
|
||||
// compiletime, so the compiler wouldn't have to warn indiscriminently, but
|
||||
// could check if the source value actually doesn't fit into the target type
|
||||
// and only warn in those cases.
|
||||
#if __GNUC__ > 6
|
||||
#if defined(__GNUC__) && __GNUC__ > 6
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
@ -776,7 +776,7 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i)
|
||||
|
||||
} // namespace gsl
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#if _MSC_VER < 1910
|
||||
#undef constexpr
|
||||
#pragma pop_macro("constexpr")
|
||||
@ -786,7 +786,7 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i)
|
||||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
#if __GNUC__ > 6
|
||||
#if defined(__GNUC__) && __GNUC__ > 6
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__ > 6
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <string> // for basic_string, allocator, char_traits
|
||||
#include <type_traits> // for declval, is_convertible, enable_if_t, add_...
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma warning(push)
|
||||
|
||||
// Turn MSVC /analyze rules that generate too much noise. TODO: fix in the tool.
|
||||
@ -706,7 +706,7 @@ bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other)
|
||||
#endif
|
||||
} // namespace gsl
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma warning(pop)
|
||||
|
||||
#if _MSC_VER < 1910
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
|
||||
project(GSLTests CXX)
|
||||
|
||||
@ -33,14 +33,24 @@ endif()
|
||||
# this interface adds compile options to how the tests are run
|
||||
# please try to keep entries ordered =)
|
||||
add_library(gsl_tests_config INTERFACE)
|
||||
if(MSVC) # MSVC or simulating MSVC
|
||||
target_compile_options(gsl_tests_config INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
/EHsc
|
||||
/W4
|
||||
/WX
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-missing-braces
|
||||
-Wno-missing-prototypes
|
||||
-Wno-unknown-attributes
|
||||
$<$<EQUAL:${GSL_CXX_STANDARD},14>:-Wno-unused-member-function>
|
||||
>
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||
)
|
||||
else()
|
||||
target_compile_options(gsl_tests_config INTERFACE
|
||||
-fno-strict-aliasing
|
||||
-Wall
|
||||
-Wcast-align
|
||||
@ -48,16 +58,25 @@ target_compile_options(gsl_tests_config INTERFACE
|
||||
-Wctor-dtor-privacy
|
||||
-Werror
|
||||
-Wextra
|
||||
-Wno-missing-braces
|
||||
-Wno-unknown-attributes
|
||||
-Wnon-virtual-dtor
|
||||
-Wold-style-cast
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wsign-conversion
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-missing-braces
|
||||
-Wno-missing-prototypes
|
||||
-Wno-padded
|
||||
-Wno-unknown-attributes
|
||||
$<$<EQUAL:${GSL_CXX_STANDARD},14>:-Wno-unused-member-function>
|
||||
-Wno-weak-vtables
|
||||
>
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
$<$<CXX_COMPILER_VERSION:5.0.2>:-Wno-undefined-func-template>
|
||||
>
|
||||
)
|
||||
endif(MSVC)
|
||||
|
||||
# for tests to find the catch header
|
||||
target_include_directories(gsl_tests_config INTERFACE
|
||||
@ -121,34 +140,49 @@ endforeach(flag_var)
|
||||
# this interface adds compile options to how the tests are run
|
||||
# please try to keep entries ordered =)
|
||||
add_library(gsl_tests_config_noexcept INTERFACE)
|
||||
if(MSVC) # MSVC or simulating MSVC
|
||||
target_compile_definitions(gsl_tests_config_noexcept INTERFACE
|
||||
_HAS_EXCEPTIONS=0
|
||||
)
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/D_HAS_EXCEPTIONS=0
|
||||
/wd4702
|
||||
/wd4577
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
/W4
|
||||
/WX
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/wd4577
|
||||
/wd4702
|
||||
>
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||
-fno-strict-aliasing
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-missing-prototypes
|
||||
-Wno-unknown-attributes
|
||||
>
|
||||
)
|
||||
else()
|
||||
target_compile_options(gsl_tests_config_noexcept INTERFACE
|
||||
-fno-exceptions
|
||||
-fno-strict-aliasing
|
||||
-Wall
|
||||
-Wcast-align
|
||||
-Wconversion
|
||||
-Wctor-dtor-privacy
|
||||
-Werror
|
||||
-Wextra
|
||||
-Wno-missing-braces
|
||||
-Wno-unknown-attributes
|
||||
-Wnon-virtual-dtor
|
||||
-Wold-style-cast
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wsign-conversion
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-missing-prototypes
|
||||
-Wno-unknown-attributes
|
||||
-Wno-weak-vtables
|
||||
>
|
||||
)
|
||||
endif(MSVC)
|
||||
|
||||
# set definitions for tests
|
||||
target_compile_definitions(gsl_tests_config_noexcept INTERFACE
|
||||
|
@ -24,11 +24,7 @@ int operator_subscript_no_throw() noexcept
|
||||
return sp[11];
|
||||
}
|
||||
|
||||
|
||||
void test_terminate()
|
||||
{
|
||||
std::exit(0);
|
||||
}
|
||||
[[noreturn]] void test_terminate() { std::exit(0); }
|
||||
|
||||
void setup_termination_handler() noexcept
|
||||
{
|
||||
@ -44,7 +40,6 @@ void setup_termination_handler() noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main() noexcept
|
||||
{
|
||||
setup_termination_handler();
|
||||
|
@ -15,8 +15,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstdlib> // for std::exit
|
||||
#include <gsl/gsl_util> // for narrow
|
||||
#include <gsl/gsl_assert> // for get_terminate
|
||||
#include <gsl/gsl_util> // for narrow
|
||||
|
||||
int narrow_no_throw()
|
||||
{
|
||||
@ -24,10 +24,7 @@ int narrow_no_throw()
|
||||
return gsl::narrow<int>(bigNumber);
|
||||
}
|
||||
|
||||
void test_terminate()
|
||||
{
|
||||
std::exit(0);
|
||||
}
|
||||
[[noreturn]] void test_terminate() { std::exit(0); }
|
||||
|
||||
void setup_termination_handler() noexcept
|
||||
{
|
||||
@ -43,7 +40,6 @@ void setup_termination_handler() noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
setup_termination_handler();
|
||||
|
@ -251,7 +251,7 @@ TEST_CASE("TestNotNullostream")
|
||||
{
|
||||
ostream_helper<int>(17);
|
||||
ostream_helper<float>(21.5f);
|
||||
ostream_helper<double>(3.4566e-7f);
|
||||
ostream_helper<double>(3.4566e-7);
|
||||
ostream_helper<char>('c');
|
||||
ostream_helper<uint16_t>(0x0123u);
|
||||
ostream_helper<const char*>("cstring");
|
||||
|
@ -37,7 +37,8 @@
|
||||
#include <type_traits> // for integral_constant<>::value, is_default_co...
|
||||
#include <vector> // for vector
|
||||
|
||||
namespace gsl {
|
||||
namespace gsl
|
||||
{
|
||||
struct fail_fast;
|
||||
} // namespace gsl
|
||||
|
||||
@ -54,9 +55,12 @@ struct DerivedClass : BaseClass
|
||||
};
|
||||
struct AddressOverloaded
|
||||
{
|
||||
#if (__cplusplus > 201402L)
|
||||
[[maybe_unused]]
|
||||
#endif
|
||||
AddressOverloaded operator&() const { return {}; }
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
GSL_SUPPRESS(con.4) // NO-FORMAT: attribute
|
||||
TEST_CASE("default_constructor")
|
||||
@ -513,8 +517,8 @@ TEST_CASE("from_std_array_constructor")
|
||||
static span<int> s2;
|
||||
s2 = s1;
|
||||
|
||||
#if __GNUC__ == 6 && (__GNUC_MINOR__ == 4 || __GNUC_MINOR__ == 5) && __GNUC_PATCHLEVEL__ == 0 && \
|
||||
defined(__OPTIMIZE__)
|
||||
#if defined(__GNUC__) && __GNUC__ == 6 && (__GNUC_MINOR__ == 4 || __GNUC_MINOR__ == 5) && \
|
||||
__GNUC_PATCHLEVEL__ == 0 && defined(__OPTIMIZE__)
|
||||
// Known to be broken in gcc 6.4 and 6.5 with optimizations
|
||||
// Issue in gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83116
|
||||
CHECK(s1.size() == 4);
|
||||
|
@ -117,7 +117,7 @@ TEST_CASE("strided_span_constructors")
|
||||
CHECK(sav.bounds().strides() == multi_span_index<1>{1});
|
||||
CHECK(sav[1] == 2);
|
||||
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
// strided_span<const int, 1> sav_c{ {src}, {2, 1} };
|
||||
strided_span<const int, 1> sav_c{multi_span<const int>{src},
|
||||
strided_bounds<1>{2, 1}};
|
||||
@ -129,7 +129,7 @@ TEST_CASE("strided_span_constructors")
|
||||
CHECK(sav_c.bounds().strides() == multi_span_index<1>{1});
|
||||
CHECK(sav_c[1] == 2);
|
||||
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
strided_span<volatile int, 1> sav_v{src, {2, 1}};
|
||||
#else
|
||||
strided_span<volatile int, 1> sav_v{multi_span<volatile int>{src},
|
||||
@ -139,7 +139,7 @@ TEST_CASE("strided_span_constructors")
|
||||
CHECK(sav_v.bounds().strides() == multi_span_index<1>{1});
|
||||
CHECK(sav_v[1] == 2);
|
||||
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
strided_span<const volatile int, 1> sav_cv{src, {2, 1}};
|
||||
#else
|
||||
strided_span<const volatile int, 1> sav_cv{multi_span<const volatile int>{src},
|
||||
@ -159,7 +159,7 @@ TEST_CASE("strided_span_constructors")
|
||||
CHECK(sav_c.bounds().strides() == multi_span_index<1>{1});
|
||||
CHECK(sav_c[1] == 2);
|
||||
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
strided_span<const volatile int, 1> sav_cv{src, {2, 1}};
|
||||
#else
|
||||
strided_span<const volatile int, 1> sav_cv{multi_span<const volatile int>{src},
|
||||
@ -180,7 +180,7 @@ TEST_CASE("strided_span_constructors")
|
||||
CHECK(sav_v.bounds().strides() == multi_span_index<1>{1});
|
||||
CHECK(sav_v[1] == 2);
|
||||
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
strided_span<const volatile int, 1> sav_cv{src, {2, 1}};
|
||||
#else
|
||||
strided_span<const volatile int, 1> sav_cv{multi_span<const volatile int>{src},
|
||||
@ -598,7 +598,7 @@ void iterate_every_other_element(multi_span<int, dynamic_range> av)
|
||||
// pick every other element
|
||||
|
||||
auto length = av.size() / 2;
|
||||
#if _MSC_VER > 1800
|
||||
#if defined(_MSC_VER) && _MSC_VER > 1800
|
||||
auto bounds = strided_bounds<1>({length}, {2});
|
||||
#else
|
||||
auto bounds = strided_bounds<1>(multi_span_index<1>{length}, multi_span_index<1>{2});
|
||||
|
@ -80,7 +80,7 @@ TEST_CASE("finally_function_with_bind")
|
||||
CHECK(i == 1);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
static int j = 0;
|
||||
void g() { j += 1; }
|
||||
TEST_CASE("finally_function_ptr")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user