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
+18 -6
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, CHECK, TEST_...
#include <gsl/gsl_byte> // for to_byte, to_integer, byte, operator&, ope...
@@ -23,7 +29,6 @@ using namespace gsl;
namespace
{
TEST_CASE("construction")
{
{
@@ -31,6 +36,7 @@ TEST_CASE("construction")
CHECK(static_cast<unsigned char>(b) == 4);
}
GSL_SUPPRESS(es.49)
{
const byte b = byte(12);
CHECK(static_cast<unsigned char>(b) == 12);
@@ -46,11 +52,12 @@ TEST_CASE("construction")
CHECK(static_cast<unsigned char>(b) == 12);
}
// waiting for C++17 enum class direct initializer support
//{
// byte b { 14 };
// CHECK(static_cast<unsigned char>(b) == 14);
//}
#if defined(__cplusplus) && (__cplusplus >= 201703L)
{
const byte b { 14 };
CHECK(static_cast<unsigned char>(b) == 14);
}
#endif
}
TEST_CASE("bitwise_operations")
@@ -114,6 +121,7 @@ int modify_both(gsl::byte & b, int& i)
return i;
}
GSL_SUPPRESS(type.1)
TEST_CASE("aliasing")
{
int i{0};
@@ -122,3 +130,7 @@ TEST_CASE("aliasing")
}
}
#ifdef CONFIRM_COMPILATION_ERRORS
copy(src_span_static, dst_span_static);
#endif