-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable some clang conversion warnings in
cpp2util.h
and cppfront i…
…tself (#1212) * Disable clang conversion warnings when compiling with -Wconversion cppfront and cpp2util.h use signed integer types for indices and container sizes so disable signed-to-unsigned conversion warnings. cppfront also uses implicit conversions from string literal to bool for: `assert(!"message")` so disable those warnings too. * Update regression tests caused by line number changes in `cpp2util.h` * Removed dependency on `!"string literal"` * Address `.size()` narrowing warnings Using the answer we recommend for everyone else, so model the right behavior here --------- Co-authored-by: Herb Sutter <herb.sutter@gmail.com>
- Loading branch information
1 parent
c618ed5
commit 658d307
Showing
25 changed files
with
89 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-check.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(964) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] | ||
../../../include/cpp2util.h(970) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] |
2 changes: 1 addition & 1 deletion
2
...ion-tests/test-results/apple-clang-15-c++2b/mixed-bounds-safety-with-assert.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(776) : Bounds safety violation | ||
../../../include/cpp2util.h(782) : Bounds safety violation |
2 changes: 1 addition & 1 deletion
2
...sults/apple-clang-15-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(776) : Contract violation: fill: value must contain at least count elements | ||
../../../include/cpp2util.h(782) : Contract violation: fill: value must contain at least count elements |
2 changes: 1 addition & 1 deletion
2
.../test-results/apple-clang-15-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
sending error to my framework... [dynamic null dereference attempt detected] | ||
from source location: ../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] | ||
from source location: ../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] |
2 changes: 1 addition & 1 deletion
2
...sion-tests/test-results/apple-clang-15-c++2b/pure2-assert-expected-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected<int, bool>]: Null safety violation: std::expected has an unexpected value | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected<int, bool>]: Null safety violation: std::expected has an unexpected value |
2 changes: 1 addition & 1 deletion
2
...sion-tests/test-results/apple-clang-15-c++2b/pure2-assert-optional-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value |
2 changes: 1 addition & 1 deletion
2
...on-tests/test-results/apple-clang-15-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty |
2 changes: 1 addition & 1 deletion
2
...on-tests/test-results/apple-clang-15-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/clang-15-c++20/mixed-bounds-check.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(964) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] | ||
../../../include/cpp2util.h(970) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/clang-15-c++20/mixed-bounds-safety-with-assert.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(776) : Bounds safety violation | ||
../../../include/cpp2util.h(782) : Bounds safety violation |
2 changes: 1 addition & 1 deletion
2
...est-results/clang-15-c++20/mixed-initialization-safety-3-contract-violation.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(776) : Contract violation: fill: value must contain at least count elements | ||
../../../include/cpp2util.h(782) : Contract violation: fill: value must contain at least count elements |
2 changes: 1 addition & 1 deletion
2
...-tests/test-results/clang-15-c++20/mixed-lifetime-safety-and-null-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
sending error to my framework... [dynamic null dereference attempt detected] | ||
from source location: ../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] | ||
from source location: ../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/clang-15-c++20/pure2-assert-optional-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/clang-15-c++20/pure2-assert-shared-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty |
2 changes: 1 addition & 1 deletion
2
regression-tests/test-results/clang-15-c++20/pure2-assert-unique-ptr-not-null.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../../include/cpp2util.h(855) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty | ||
../../../include/cpp2util.h(861) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty |
20 changes: 10 additions & 10 deletions
20
regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid |
20 changes: 10 additions & 10 deletions
20
regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid | ||
../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type | ||
2100 | constexpr auto is( X const& x ) -> bool | ||
2100 | requires (std::is_same_v<X,std::any> && !std::is_same_v<T,std::any> && !std::is_same_v<T,empty>) | ||
| ^ | ||
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ | ||
2137 | | ||
2137 | { return std::any_cast<T>( x ); } | ||
| ^ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ | ||
mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.