From aa65154f8cf7618f8b681e573219ca50c0bd3875 Mon Sep 17 00:00:00 2001 From: Dylan Burr Date: Thu, 21 Mar 2024 15:05:52 -0400 Subject: [PATCH 1/2] Fix -Werror=free-nonheap-object warning as error When building the perftest, schematest.cpp was yielding an error in relation to freeing a stack object. This change fixes that by explicitly passing in nullptr to CrtAllocator::Free if we don't own the memory. Change-Id: Ide53cc324af1ae3fef3d9096684e3aac0c1427ff --- include/rapidjson/allocators.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h index 275417bd8..ad959e81c 100644 --- a/include/rapidjson/allocators.h +++ b/include/rapidjson/allocators.h @@ -267,9 +267,7 @@ class MemoryPoolAllocator { } Clear(); BaseAllocator *a = shared_->ownBaseAllocator; - if (shared_->ownBuffer) { - baseAllocator_->Free(shared_); - } + baseAllocator_->Free(shared_->ownBuffer ? shared_ : nullptr); RAPIDJSON_DELETE(a); } From 1151989040ed95d87da61ed62cd698f7c04b10c2 Mon Sep 17 00:00:00 2001 From: Dylan Burr Date: Wed, 29 May 2024 10:45:58 -0400 Subject: [PATCH 2/2] Support RVCT 4.1 ARM compiler This change adds the necessary preprocessor checks to support the RVCT 4.1 ARM compiler. Change-Id: I9b516af326aef08aaafda00a5f89b125d39b1f04 --- include/rapidjson/prettywriter.h | 4 ++++ include/rapidjson/rapidjson.h | 16 ++++++++++++++++ include/rapidjson/schema.h | 3 +++ include/rapidjson/writer.h | 2 ++ 4 files changed, 25 insertions(+) diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index fe45df1d1..946270536 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -27,6 +27,10 @@ RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(c++98-compat) #endif +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000) +RAPIDJSON_DIAG_OFF(550) // variable was set but never used +#endif + RAPIDJSON_NAMESPACE_BEGIN //! Combination of PrettyWriter format flags. diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index 247b8e68d..990292a97 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -276,6 +276,13 @@ # define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN # elif defined(RAPIDJSON_DOXYGEN_RUNNING) # define RAPIDJSON_ENDIAN +// Detect with armcc macros +# elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000) +# if defined(__BIG_ENDIAN) +# define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN +# else +# define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN +# endif # else # error Unknown machine endianness detected. User needs to define RAPIDJSON_ENDIAN. # endif @@ -561,6 +568,15 @@ RAPIDJSON_NAMESPACE_END #define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) #define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000) + +#define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x)) +#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(diag_##x) + +#define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(suppress x) +#define RAPIDJSON_DIAG_PUSH /* ignored */ +#define RAPIDJSON_DIAG_POP /* ignored */ + #else #define RAPIDJSON_DIAG_OFF(x) /* ignored */ diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index 02a6d0f9e..d465de8b4 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -59,6 +59,9 @@ RAPIDJSON_DIAG_OFF(c++98-compat-pedantic) RAPIDJSON_DIAG_OFF(variadic-macros) #elif defined(_MSC_VER) RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000) +RAPIDJSON_DIAG_OFF(1300) // inherits implicit virtual +RAPIDJSON_DIAG_OFF(2815) // empty dependent statement in while-statement #endif RAPIDJSON_NAMESPACE_BEGIN diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 632e02ce7..4f6436e25 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -45,6 +45,8 @@ RAPIDJSON_DIAG_OFF(c++98-compat) #elif defined(_MSC_VER) RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6000000) +RAPIDJSON_DIAG_OFF(111) // statement is unreachable #endif RAPIDJSON_NAMESPACE_BEGIN