fix: eliminate msvc warning

This commit is contained in:
Sergiu Deitsch 2023-10-08 18:56:34 +02:00
parent e19e598302
commit aebdfd6051
No known key found for this signature in database
2 changed files with 14 additions and 15 deletions

View File

@ -1780,11 +1780,11 @@ class GLOG_EXPORT NullStream : public LogMessage::LogStream {
// (they'll never be actually displayed). This will be needed if a // (they'll never be actually displayed). This will be needed if a
// NullStream& is implicitly converted to LogStream&, in which case // NullStream& is implicitly converted to LogStream&, in which case
// the overloaded NullStream::operator<< will not be invoked. // the overloaded NullStream::operator<< will not be invoked.
NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { } NullStream();
NullStream(const char* /*file*/, int /*line*/, NullStream(const char* /*file*/, int /*line*/,
const CheckOpString& /*result*/) : const CheckOpString& /*result*/);
LogMessage::LogStream(message_buffer_, 1, 0) { } NullStream& stream();
NullStream &stream() { return *this; }
private: private:
// A very short buffer for messages (which we discard anyway). This // A very short buffer for messages (which we discard anyway). This
// will be needed if NullStream& converted to LogStream& (e.g. as a // will be needed if NullStream& converted to LogStream& (e.g. as a
@ -1805,17 +1805,8 @@ inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// trace), like LogMessageFatal. // trace), like LogMessageFatal.
class GLOG_EXPORT NullStreamFatal : public NullStream { class GLOG_EXPORT NullStreamFatal : public NullStream {
public: public:
NullStreamFatal() { } using NullStream::NullStream;
NullStreamFatal(const char* file, int line, const CheckOpString& result) : [[noreturn]] ~NullStreamFatal();
NullStream(file, line, result) { }
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4722)
#endif // _MSC_VER
[[noreturn]] ~NullStreamFatal() throw() { _exit(EXIT_FAILURE); }
#if defined(_MSC_VER)
#pragma warning(pop)
#endif // _MSC_VER
}; };
// Install a signal handler that will dump signal information and a stack // Install a signal handler that will dump signal information and a stack

View File

@ -1931,6 +1931,14 @@ void LogMessage::RecordCrashReason(
GLOG_EXPORT logging_fail_func_t g_logging_fail_func = GLOG_EXPORT logging_fail_func_t g_logging_fail_func =
reinterpret_cast<logging_fail_func_t>(&abort); reinterpret_cast<logging_fail_func_t>(&abort);
NullStream::NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) {}
NullStream::NullStream(const char* /*file*/, int /*line*/,
const CheckOpString& /*result*/)
: LogMessage::LogStream(message_buffer_, 1, 0) {}
NullStream& NullStream::stream() { return *this; }
NullStreamFatal::~NullStreamFatal() { _exit(EXIT_FAILURE); }
void InstallFailureFunction(logging_fail_func_t fail_func) { void InstallFailureFunction(logging_fail_func_t fail_func) {
g_logging_fail_func = fail_func; g_logging_fail_func = fail_func;
} }