Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc warnings #2801

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ template <typename OutputIt> class truncating_iterator_base {
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;
using _Unchecked_type =
truncating_iterator_base; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(truncating_iterator_base);

OutputIt base() const { return out_; }
size_t count() const { return count_; }
Expand Down
9 changes: 8 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@
# endif
#endif

#ifdef _MSC_VER
# define FMT_UNCHECKED_ITERATOR(It) \
using _Unchecked_type = It // Mark iterator as checked.
#else
# define FMT_UNCHECKED_ITERATOR(It) using DummyTypeName = It
#endif

#ifndef FMT_BEGIN_NAMESPACE
# define FMT_BEGIN_NAMESPACE \
namespace fmt { \
Expand Down Expand Up @@ -1498,7 +1505,7 @@ class appender : public std::back_insert_iterator<detail::buffer<char>> {
public:
using std::back_insert_iterator<detail::buffer<char>>::back_insert_iterator;
appender(base it) noexcept : base(it) {}
using _Unchecked_type = appender; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(appender);

auto operator++() noexcept -> appender& { return *this; }

Expand Down
2 changes: 1 addition & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ class counting_iterator {
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;
using _Unchecked_type = counting_iterator; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(counting_iterator);

struct value_type {
template <typename T> void operator=(const T&) {}
Expand Down
2 changes: 1 addition & 1 deletion test/posix-mock-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// For the license information refer to format.h.

// Disable bogus MSVC warnings.
#ifndef _CRT_SECURE_NO_WARNINGS
#if !defined(_CRT_SECURE_NO_WARNINGS) && defined(_MSC_VER)
seanm marked this conversation as resolved.
Show resolved Hide resolved
# define _CRT_SECURE_NO_WARNINGS
#endif

Expand Down
5 changes: 2 additions & 3 deletions test/test-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

#ifdef _MSC_VER
# include <crtdbg.h>
#else
# define _CrtSetReportFile(a, b)
# define _CrtSetReportMode(a, b)
#endif

int main(int argc, char** argv) {
Expand All @@ -28,11 +25,13 @@ int main(int argc, char** argv) {
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
#endif
#ifdef _MSC_VER
// Disable message boxes on assertion failures.
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif
seanm marked this conversation as resolved.
Show resolved Hide resolved
try {
testing::InitGoogleTest(&argc, argv);
testing::FLAGS_gtest_death_test_style = "threadsafe";
Expand Down