fix cppcorecheck warnings (#703)

* Added c++17 test configurations for clang5.0 and clang6.0

* Fixed CppCoreCheck warnings in GSL and tests

- Added CMakeSettings.json for VS Open Folder configuration
	- So we can easily run CppCoreCheck in VS
- Fixed CppCorecheck warnings where it made sense
- Suppressed the rest
	- Some suppression does not work due to compiler/tool bugs,
          so replaced by #pragma disable
	- CppCoreCheck has noise, suppressed those with comments
	- Catch produces many warnings, blanket-supressed them all
- Had to fix clang formatting to keep attributes in place
	- clang-format does not support attributes, so I am using
        - "CommentPragmas: '^ NO-FORMAT:'" to skip formatiting on them
- Removed GSL_NOEXCEPT macro, removed incorred noexcepts

* Ignore unknown attributes

* ignore unknown attributes in noexception mode tests

* fixed C26472 in at()

* created GSL_SUPPRESS macro to allow all compilers to parse suppression attributes

* try to fix gcc compilation problems with attributes

* ignore gsl::suppress for gcc

* move suppression to function level on return statements

clang5.0 and up does not allow attributes on return statemets in constexpr functions

* move suppression to function level on return statements

* use GSL_SUPPRESS in algorithm_tests

* Addressed PR comments
This commit is contained in:
Anna Gringauze
2018-08-12 21:44:17 -07:00
committed by Neil MacIntosh
parent 6a75903c79
commit cea0d0ac2b
25 changed files with 940 additions and 503 deletions
+16
View File
@@ -14,6 +14,12 @@
//
///////////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
// blanket turn off warnings from CppCoreCheck from catch
// so people aren't annoyed by them when running the tool.
#pragma warning(disable : 26440 26426) // from catch
#endif
#include <catch/catch.hpp> // for AssertionHandler, StringRef, TEST_CASE
#include <gsl/multi_span> // for static_bounds, static_bounds_dynamic_range_t
@@ -32,6 +38,7 @@ namespace
void use(std::ptrdiff_t&) {}
}
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
TEST_CASE("basic_bounds")
{
for (auto point : static_bounds<dynamic_range, 3, 4>{2}) {
@@ -44,6 +51,8 @@ TEST_CASE("basic_bounds")
}
}
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
GSL_SUPPRESS(con.4) // NO-FORMAT: attribute
TEST_CASE("bounds_basic")
{
static_bounds<3, 4, 5> b;
@@ -53,6 +62,8 @@ TEST_CASE("bounds_basic")
x.slice().slice();
}
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
GSL_SUPPRESS(con.4) // NO-FORMAT: attribute
TEST_CASE("arrayview_iterator")
{
static_bounds<4, dynamic_range, 2> bounds{3};
@@ -71,6 +82,7 @@ TEST_CASE("arrayview_iterator")
#endif
}
GSL_SUPPRESS(con.4) // NO-FORMAT: attribute
TEST_CASE("bounds_convertible")
{
static_bounds<7, 4, 2> b1;
@@ -97,3 +109,7 @@ TEST_CASE("bounds_convertible")
CHECK(b5 == b6);
CHECK(b5.size() == b6.size());
}
#ifdef CONFIRM_COMPILATION_ERRORS
copy(src_span_static, dst_span_static);
#endif