1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

Fix #510 (-Wextra-semi-stmt with clang compiler)

This commit is contained in:
Fabian Zahn
2021-02-27 08:53:53 +01:00
parent 61f4428435
commit 7edf9d9ac5
4 changed files with 23 additions and 20 deletions

View File

@@ -103,6 +103,7 @@ target_compile_options(${PROJECT_NAME}
-Wcast-qual -Wcast-qual
-Wconversion -Wconversion
-Wexit-time-destructors -Wexit-time-destructors
-Wextra-semi-stmt
-Wglobal-constructors -Wglobal-constructors
-Wmissing-noreturn -Wmissing-noreturn
-Wmissing-prototypes -Wmissing-prototypes

View File

@@ -19,9 +19,9 @@ void UNITY_OUTPUT_CHAR(int);
#endif #endif
/* Helpful macros for us to use here in Assert functions */ /* Helpful macros for us to use here in Assert functions */
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } #define UNITY_FAIL_AND_BAIL do { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } #define UNITY_IGNORE_AND_BAIL do { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } while (0)
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT() #define RETURN_IF_FAIL_OR_IGNORE do { if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) { TEST_ABORT(); } } while (0)
struct UNITY_STORAGE_T Unity; struct UNITY_STORAGE_T Unity;
@@ -765,11 +765,12 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
} }
#define UnityPrintPointlessAndBail() \ #define UnityPrintPointlessAndBail() \
{ \ do { \
UnityTestResultsFailBegin(lineNumber); \ UnityTestResultsFailBegin(lineNumber); \
UnityPrint(UnityStrPointless); \ UnityPrint(UnityStrPointless); \
UnityAddMsgIfSpecified(msg); \ UnityAddMsgIfSpecified(msg); \
UNITY_FAIL_AND_BAIL; } UNITY_FAIL_AND_BAIL; \
} while (0)
/*-----------------------------------------------*/ /*-----------------------------------------------*/
void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
@@ -884,11 +885,12 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
#ifndef UNITY_EXCLUDE_FLOAT_PRINT #ifndef UNITY_EXCLUDE_FLOAT_PRINT
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
{ \ do { \
UnityPrint(UnityStrExpected); \ UnityPrint(UnityStrExpected); \
UnityPrintFloat(expected); \ UnityPrintFloat(expected); \
UnityPrint(UnityStrWas); \ UnityPrint(UnityStrWas); \
UnityPrintFloat(actual); } UnityPrintFloat(actual); \
} while (0)
#else #else
#define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \
UnityPrint(UnityStrDelta) UnityPrint(UnityStrDelta)

View File

@@ -111,7 +111,7 @@ void verifyTest(void);
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
#define TEST_PASS() TEST_ABORT() #define TEST_PASS() TEST_ABORT()
#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0) #define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0)
/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out /* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out
* which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */

View File

@@ -273,10 +273,10 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#ifdef UNITY_USE_FLUSH_STDOUT #ifdef UNITY_USE_FLUSH_STDOUT
/* We want to use the stdout flush utility */ /* We want to use the stdout flush utility */
#include <stdio.h> #include <stdio.h>
#define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout)
#else #else
/* We've specified nothing, therefore flush should just be ignored */ /* We've specified nothing, therefore flush should just be ignored */
#define UNITY_OUTPUT_FLUSH() #define UNITY_OUTPUT_FLUSH() (void)0
#endif #endif
#else #else
/* If defined as something else, make sure we declare it here so it's ready for use */ /* If defined as something else, make sure we declare it here so it's ready for use */
@@ -288,11 +288,11 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#ifndef UNITY_OUTPUT_FLUSH #ifndef UNITY_OUTPUT_FLUSH
#define UNITY_FLUSH_CALL() #define UNITY_FLUSH_CALL()
#else #else
#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH()
#endif #endif
#ifndef UNITY_PRINT_EOL #ifndef UNITY_PRINT_EOL
#define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') #define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n')
#endif #endif
#ifndef UNITY_OUTPUT_START #ifndef UNITY_OUTPUT_START
@@ -351,19 +351,19 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#endif #endif
#ifndef UNITY_EXEC_TIME_START #ifndef UNITY_EXEC_TIME_START
#define UNITY_EXEC_TIME_START() do{}while(0) #define UNITY_EXEC_TIME_START() do { /* nothing*/ } while (0)
#endif #endif
#ifndef UNITY_EXEC_TIME_STOP #ifndef UNITY_EXEC_TIME_STOP
#define UNITY_EXEC_TIME_STOP() do{}while(0) #define UNITY_EXEC_TIME_STOP() do { /* nothing*/ } while (0)
#endif #endif
#ifndef UNITY_TIME_TYPE #ifndef UNITY_TIME_TYPE
#define UNITY_TIME_TYPE UNITY_UINT #define UNITY_TIME_TYPE UNITY_UINT
#endif #endif
#ifndef UNITY_PRINT_EXEC_TIME #ifndef UNITY_PRINT_EXEC_TIME
#define UNITY_PRINT_EXEC_TIME() do{}while(0) #define UNITY_PRINT_EXEC_TIME() do { /* nothing*/ } while (0)
#endif #endif
/*------------------------------------------------------- /*-------------------------------------------------------
@@ -502,9 +502,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
#define UNITY_SET_DETAIL(d1) #define UNITY_SET_DETAIL(d1)
#define UNITY_SET_DETAILS(d1,d2) #define UNITY_SET_DETAILS(d1,d2)
#else #else
#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } #define UNITY_CLR_DETAILS() do { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } while (0)
#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } #define UNITY_SET_DETAIL(d1) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } while (0)
#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } #define UNITY_SET_DETAILS(d1,d2) do { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } while (0)
#ifndef UNITY_DETAIL1_NAME #ifndef UNITY_DETAIL1_NAME
#define UNITY_DETAIL1_NAME "Function" #define UNITY_DETAIL1_NAME "Function"
@@ -772,7 +772,7 @@ int UnityTestMatches(void);
* Test Asserts * Test Asserts
*-------------------------------------------------------*/ *-------------------------------------------------------*/
#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0) #define UNITY_TEST_ASSERT(condition, line, message) do { if (condition) { /* nothing*/ } else { UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message)); } } while (0)
#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message))