Commit 9ce381b8 authored by Milo Yip's avatar Milo Yip

Try to fix clang and gcc warnings problems again

parent 17f2ca69
...@@ -17,6 +17,11 @@ RAPIDJSON_DIAG_PUSH ...@@ -17,6 +17,11 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++) RAPIDJSON_DIAG_OFF(effc++)
#endif #endif
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(switch-enum)
#endif
struct MessageHandler struct MessageHandler
: public BaseReaderHandler<UTF8<>, MessageHandler> { : public BaseReaderHandler<UTF8<>, MessageHandler> {
MessageHandler() : messages_(), state_(kExpectObjectStart), name_() {} MessageHandler() : messages_(), state_(kExpectObjectStart), name_() {}
...@@ -26,16 +31,13 @@ struct MessageHandler ...@@ -26,16 +31,13 @@ struct MessageHandler
case kExpectObjectStart: case kExpectObjectStart:
state_ = kExpectNameOrObjectEnd; state_ = kExpectNameOrObjectEnd;
return true; return true;
case kExpectNameOrObjectEnd: default:
case kExpectValue:
return false; return false;
} }
} }
bool String(const char* str, SizeType length, bool) { bool String(const char* str, SizeType length, bool) {
switch (state_) { switch (state_) {
case kExpectObjectStart:
return false;
case kExpectNameOrObjectEnd: case kExpectNameOrObjectEnd:
name_ = string(str, length); name_ = string(str, length);
state_ = kExpectValue; state_ = kExpectValue;
...@@ -44,6 +46,8 @@ struct MessageHandler ...@@ -44,6 +46,8 @@ struct MessageHandler
messages_.insert(MessageMap::value_type(name_, string(str, length))); messages_.insert(MessageMap::value_type(name_, string(str, length)));
state_ = kExpectNameOrObjectEnd; state_ = kExpectNameOrObjectEnd;
return true; return true;
default:
return false;
} }
} }
...@@ -64,6 +68,10 @@ struct MessageHandler ...@@ -64,6 +68,10 @@ struct MessageHandler
RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_POP
#endif #endif
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
static void ParseMessages(const char* json, MessageMap& messages) { static void ParseMessages(const char* json, MessageMap& messages) {
Reader reader; Reader reader;
MessageHandler handler; MessageHandler handler;
......
...@@ -1557,7 +1557,8 @@ public: ...@@ -1557,7 +1557,8 @@ public:
case kStringType: case kStringType:
return handler.String(GetString(), GetStringLength(), (flags_ & kCopyFlag) != 0); return handler.String(GetString(), GetStringLength(), (flags_ & kCopyFlag) != 0);
case kNumberType: default:
RAPIDJSON_ASSERT(GetType() == kNumberType);
if (IsInt()) return handler.Int(data_.n.i.i); if (IsInt()) return handler.Int(data_.n.i.i);
else if (IsUint()) return handler.Uint(data_.n.u.u); else if (IsUint()) return handler.Uint(data_.n.u.u);
else if (IsInt64()) return handler.Int64(data_.n.i64); else if (IsInt64()) return handler.Int64(data_.n.i64);
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
#include "error.h" #include "error.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(switch-enum)
RAPIDJSON_DIAG_OFF(covered-switch-default)
#endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
//! Maps error code of parsing into error message. //! Maps error code of parsing into error message.
...@@ -54,10 +60,15 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro ...@@ -54,10 +60,15 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErro
case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error."); case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error.");
case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error."); case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error.");
default: return RAPIDJSON_ERROR_STRING("Unknown error.");
} }
return RAPIDJSON_ERROR_STRING("Unknown error.");
} }
RAPIDJSON_NAMESPACE_END RAPIDJSON_NAMESPACE_END
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_ERROR_EN_H_ #endif // RAPIDJSON_ERROR_EN_H_
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#ifdef __clang__ #ifdef __clang__
RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(padded) RAPIDJSON_DIAG_OFF(padded)
RAPIDJSON_DIAG_OFF(unreachable-code)
#endif #endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
#include "rapidjson.h" #include "rapidjson.h"
#include <cstdio> #include <cstdio>
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(unreachable-code)
#endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
//! Wrapper of C file stream for input using fread(). //! Wrapper of C file stream for input using fread().
...@@ -92,4 +97,8 @@ inline void PutN(FileWriteStream& stream, char c, size_t n) { ...@@ -92,4 +97,8 @@ inline void PutN(FileWriteStream& stream, char c, size_t n) {
RAPIDJSON_NAMESPACE_END RAPIDJSON_NAMESPACE_END
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
#endif // RAPIDJSON_FILESTREAM_H_ #endif // RAPIDJSON_FILESTREAM_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment