diff options
author | Anna Gringauze <annagrin@microsoft.com> | 2018-08-12 21:44:17 -0700 |
---|---|---|
committer | Neil MacIntosh <neilmac@fb.com> | 2018-08-12 21:44:17 -0700 |
commit | cea0d0ac2bd775f0fb4c7e357a089979370ae3cd (patch) | |
tree | faa0e678f606971b55ef795d507d613d40e93de2 /tests/utils_tests.cpp | |
parent | 6a75903c79ff7109c24d281372005b622a9d9177 (diff) | |
download | Microsoft-GSL-cea0d0ac2bd775f0fb4c7e357a089979370ae3cd.tar.gz |
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
Diffstat (limited to 'tests/utils_tests.cpp')
-rw-r--r-- | tests/utils_tests.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 587b0a1..05f8d0f 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -14,6 +14,13 @@ // /////////////////////////////////////////////////////////////////////////////// +#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_util> // for narrow, finally, narrow_cast, narrowing_e... @@ -85,6 +92,7 @@ TEST_CASE("finally_function_ptr") CHECK(j == 1); } +GSL_SUPPRESS(con.4) // NO-FORMAT: attribute TEST_CASE("narrow_cast") { int n = 120; @@ -96,6 +104,7 @@ TEST_CASE("narrow_cast") CHECK(uc == 44); } +GSL_SUPPRESS(con.5) // NO-FORMAT: attribute TEST_CASE("narrow") { int n = 120; |