From 442a060acd1e3cae383093fbee182345f7e644ae Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:12:45 -0400 Subject: [PATCH 1/7] Fix clang errors in makefile --- test/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Makefile b/test/Makefile index 82b61af9..532cc400 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,6 +12,8 @@ ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn +CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier +CFLAGS += -Wno-extra-semi-stmt endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros From 1638627cb5ac3c24c9840ea837c9115119158a02 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:12:40 -0400 Subject: [PATCH 2/7] Fix -Wextra-semi-stmt error with proper macro hygiene "empty expression statement has no effect; remove unnecessary ';'" These macros were not properly wrapped --- test/Makefile | 1 - test/tests/self_assessment_utils.h | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 532cc400..2275e3b8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -13,7 +13,6 @@ E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier -CFLAGS += -Wno-extra-semi-stmt endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index 6051bda8..f764ca95 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -133,19 +133,19 @@ void flushSpy(void) if (flushSpyEnabled){ flushSpyCalls++; } } -#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) -#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) -#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \ +#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) do { \ startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ - } + } while (0) #endif From 8bac36463ddb0c112979e6724091eabe1746defb Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:27:10 -0400 Subject: [PATCH 3/7] Fix reserved-identifier errors These are reserved by the standard --- test/Makefile | 2 +- test/tests/test_unity_core.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index 2275e3b8..3c3c7510 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,7 +12,7 @@ ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn -CFLAGS += -Wno-unsafe-buffer-usage -Wno-reserved-identifier +CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 866f2ab1..921f535d 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -61,7 +61,7 @@ void testUnitySizeInitializationReminder(void) #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif - } _Expected_Unity; + } Expected_Unity; #else struct { const char* TestFile; @@ -81,7 +81,7 @@ void testUnitySizeInitializationReminder(void) #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif - } _Expected_Unity; + } Expected_Unity; #endif /* Compare our fake structure's size to the actual structure's size. They @@ -89,7 +89,7 @@ void testUnitySizeInitializationReminder(void) * * This accounts for alignment, padding, and packing issues that might come * up between different architectures. */ - TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); + TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message); } void testPassShouldEndImmediatelyWithPass(void) From faaaaa4fca1dec9cf959c8180682fc9794650ec1 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:34:02 -0400 Subject: [PATCH 4/7] Fix Wmissing-noreturn errors --- test/Makefile | 2 +- test/tests/test_unity_core.c | 8 ++++---- test/tests/test_unity_floats.c | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index 3c3c7510..fac16ee9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,7 @@ endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes -CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn +CFLAGS += -Wno-unused-macros -Wno-padded CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror diff --git a/test/tests/test_unity_core.c b/test/tests/test_unity_core.c index 921f535d..1f5a9a76 100644 --- a/test/tests/test_unity_core.c +++ b/test/tests/test_unity_core.c @@ -92,19 +92,19 @@ void testUnitySizeInitializationReminder(void) TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message); } -void testPassShouldEndImmediatelyWithPass(void) +UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPass(void) { TEST_PASS(); TEST_FAIL_MESSAGE("We should have passed already and finished this test"); } -void testPassShouldEndImmediatelyWithPassAndMessage(void) +UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPassAndMessage(void) { TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!"); TEST_FAIL_MESSAGE("We should have passed already and finished this test"); } -void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) +UNITY_FUNCTION_ATTR(noreturn) void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void) { TEST_MESSAGE("This is just a message"); TEST_MESSAGE("This is another message"); @@ -282,7 +282,7 @@ void testProtection(void) TEST_ASSERT_EQUAL(3, mask); } -void testIgnoredAndThenFailInTearDown(void) +UNITY_FUNCTION_ATTR(noreturn) void testIgnoredAndThenFailInTearDown(void) { SetToOneToFailInTearDown = 1; TEST_IGNORE(); diff --git a/test/tests/test_unity_floats.c b/test/tests/test_unity_floats.c index 006c76ab..9744c134 100644 --- a/test/tests/test_unity_floats.c +++ b/test/tests/test_unity_floats.c @@ -1208,6 +1208,9 @@ void testNotEqualFloatEachEqualLengthZero(void) #endif } +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrinting(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) @@ -1257,6 +1260,9 @@ void testFloatPrinting(void) #endif } +#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrintingRoundTiesToEven(void) { #if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY) @@ -1368,6 +1374,9 @@ static void printFloatValue(float f) #endif #endif +#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) +UNITY_FUNCTION_ATTR(noreturn) +#endif void testFloatPrintingRandomSamples(void) { #if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY) From 6decd7aa29f3c6d996e7a5c1cd9207fe633f96e5 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:38:12 -0400 Subject: [PATCH 5/7] Wno-unused-macros and Wno-padded don't emit anything --- test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index fac16ee9..c5a26abf 100644 --- a/test/Makefile +++ b/test/Makefile @@ -11,7 +11,6 @@ endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes -CFLAGS += -Wno-unused-macros -Wno-padded CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror From 4a59f29362bedf0bc1ca7636a1cd086c205074be Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 21:43:20 -0400 Subject: [PATCH 6/7] Fix -Wmissing-prototypes errors This one was a bit tough, but I think this works fine. --- test/Makefile | 2 +- test/tests/self_assessment_utils.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index c5a26abf..b0b96995 100644 --- a/test/Makefile +++ b/test/Makefile @@ -10,7 +10,7 @@ CC = clang endif ifeq ($(findstring clang, $(CC)), clang) E = -Weverything -CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes +CFLAGS += $E -Wno-unknown-warning-option CFLAGS += -Wno-unsafe-buffer-usage endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror diff --git a/test/tests/self_assessment_utils.h b/test/tests/self_assessment_utils.h index f764ca95..24b755f1 100644 --- a/test/tests/self_assessment_utils.h +++ b/test/tests/self_assessment_utils.h @@ -72,6 +72,11 @@ static char putcharSpyBuffer[SPY_BUFFER_MAX]; static UNITY_COUNTER_TYPE indexSpyBuffer; static UNITY_COUNTER_TYPE putcharSpyEnabled; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif + void startPutcharSpy(void) { indexSpyBuffer = 0; @@ -133,6 +138,10 @@ void flushSpy(void) if (flushSpyEnabled){ flushSpyCalls++; } } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \ startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \ @@ -149,3 +158,10 @@ void flushSpy(void) } while (0) #endif + +// The reason this isn't folded into the above diagnostic is to semi-isolate +// the header contents from the user content it is included into. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif From 12705bf83fd02a05e11c57288a11b8ccd15794f0 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:27:44 -0400 Subject: [PATCH 7/7] Remove warning without emits --- test/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index b0b96995..35c2822b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,7 +16,6 @@ endif CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror #CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros CFLAGS += -Wno-switch-enum -Wno-double-promotion -CFLAGS += -Wno-poison-system-directories CFLAGS += -Wno-covered-switch-default CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ -Wstrict-prototypes -Wswitch-default -Wundef