From 27d39e4da0b45a93a16f932be66a3607cba1d116 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 25 Feb 2022 09:07:32 -0500 Subject: [PATCH] Use function prototypes when appropriate; NFC This prepares the clang-tools-extra project for -Wstrict-prototypes being enabled by default. --- .../PlainCStructFieldsOrder.c | 2 +- ...rison-in-temp-failure-retry-custom-macro.c | 6 +-- ...android-comparison-in-temp-failure-retry.c | 10 ++--- .../checkers/bugprone-assert-side-effect.m | 4 +- .../bugprone-branch-clone-macro-crash.c | 2 +- ...-easily-swappable-parameters-relatedness.c | 2 +- .../bugprone-easily-swappable-parameters.c | 2 +- ...null-terminated-result-memcpy-safe-other.c | 10 ++--- .../checkers/bugprone-reserved-identifier-c.c | 10 ++--- .../bugprone-signal-handler-minimal.c | 2 +- .../checkers/bugprone-signal-handler-posix.c | 2 +- .../checkers/bugprone-signal-handler.c | 40 +++++++++---------- .../bugprone-spuriously-wake-up-functions.c | 2 +- .../bugprone-suspicious-memory-comparison.c | 40 +++++++++---------- .../bugprone-suspicious-memset-usage.c | 2 +- .../bugprone-suspicious-string-compare.c | 6 +-- .../test/clang-tidy/checkers/cert-err33-c.c | 6 +-- .../checkers/cert-limited-randomness.c | 4 +- .../test/clang-tidy/checkers/cert-msc32-c.c | 4 +- .../clang-tidy/checkers/google-runtime-int.c | 4 +- .../checkers/linuxkernel-must-check-errs.c | 8 ++-- .../clang-tidy/checkers/misc-static-assert.c | 2 +- .../checkers/misc-unused-parameters.c | 2 +- .../checkers/modernize-redundant-void-arg.c | 4 +- .../clang-tidy/checkers/objc-assert-equals.m | 4 +- .../objc-nsinvocation-argument-lifetime.m | 6 +-- .../checkers/openmp-use-default-none.cpp | 24 +++++------ .../readability-isolate-declaration.c | 2 +- .../readability-redundant-declaration.c | 12 +++--- 29 files changed, 112 insertions(+), 112 deletions(-) diff --git a/clang-tools-extra/test/clang-reorder-fields/PlainCStructFieldsOrder.c b/clang-tools-extra/test/clang-reorder-fields/PlainCStructFieldsOrder.c index 5b4fe9e654e4..32ce569df943 100644 --- a/clang-tools-extra/test/clang-reorder-fields/PlainCStructFieldsOrder.c +++ b/clang-tools-extra/test/clang-reorder-fields/PlainCStructFieldsOrder.c @@ -7,7 +7,7 @@ struct Foo { int w; // CHECK-NEXT: {{^ const int\* x}} }; -int main() { +int main(void) { const int x = 13; struct Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^ struct Foo foo = { 1.29, 17, 0, &x };}} return 0; diff --git a/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry-custom-macro.c b/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry-custom-macro.c index dde03ddabbcb..5acfcafcead3 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry-custom-macro.c +++ b/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry-custom-macro.c @@ -18,10 +18,10 @@ __z; \ }) -int foo(); +int foo(void); int bar(int a); -void with_custom_macro() { +void with_custom_macro(void) { MY_TEMP_FAILURE_RETRY(foo()); MY_TEMP_FAILURE_RETRY(foo() == 1); // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in MY_TEMP_FAILURE_RETRY @@ -33,7 +33,7 @@ void with_custom_macro() { // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: top-level comparison in MY_TEMP_FAILURE_RETRY } -void with_other_custom_macro() { +void with_other_custom_macro(void) { MY_OTHER_TEMP_FAILURE_RETRY(foo()); MY_OTHER_TEMP_FAILURE_RETRY(foo() == 1); // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: top-level comparison in MY_OTHER_TEMP_FAILURE_RETRY diff --git a/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c b/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c index 3be3eecce1cb..461fb4ad5254 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c +++ b/clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c @@ -9,10 +9,10 @@ __z; \ }) -int foo(); +int foo(void); int bar(int a); -void test() { +void test(void) { int i; TEMP_FAILURE_RETRY((i = foo())); TEMP_FAILURE_RETRY(foo()); @@ -86,7 +86,7 @@ void test() { } // Be sure that it works inside of things like loops, if statements, etc. -void control_flow() { +void control_flow(void) { do { if (TEMP_FAILURE_RETRY(foo())) { } @@ -105,7 +105,7 @@ void control_flow() { // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: top-level comparison in TEMP_FAILURE_RETRY } -void with_nondependent_variable_type() { +void with_nondependent_variable_type(void) { #undef TEMP_FAILURE_RETRY #define TEMP_FAILURE_RETRY(x) \ ({ \ @@ -126,7 +126,7 @@ void with_nondependent_variable_type() { // I can't find a case where TEMP_FAILURE_RETRY is implemented like this, but if // we can cheaply support it, I don't see why not. -void obscured_temp_failure_retry() { +void obscured_temp_failure_retry(void) { #undef TEMP_FAILURE_RETRY #define IMPL(x) \ ({ \ diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.m b/clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.m index bca79565cea0..680252adfee3 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.m +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.m @@ -1,6 +1,6 @@ // RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -int abort(); +int abort(void); @interface NSObject @end @@ -46,7 +46,7 @@ int abort(); } @end -void foo() { +void foo(void) { int x = 0; NSCAssert((++x) == 1, @"Ugh."); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in NSCAssert() condition discarded in release builds [bugprone-assert-side-effect] diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-macro-crash.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-macro-crash.c index ce0c0137d0a3..a51069828b3e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-macro-crash.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-branch-clone-macro-crash.c @@ -8,7 +8,7 @@ int y = 1; else if (c) \ d = b; -f() { +void f(void) { // CHECK-MESSAGES: warning: repeated branch in conditional chain [bugprone-branch-clone] a(x, y) } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c index a6f2a736fcfb..62818b932d34 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-relatedness.c @@ -7,7 +7,7 @@ // RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \ // RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1}, \ // RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \ -// RUN: ]}' -- -x c +// RUN: ]}' -- -Wno-strict-prototypes -x c int myprint(); int add(int X, int Y); diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c index 9a945dab08cd..462a5130d95f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters.c @@ -7,7 +7,7 @@ // RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \ // RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0}, \ // RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \ -// RUN: ]}' -- -x c +// RUN: ]}' -- -Wno-strict-prototypes -x c #define bool _Bool #define true 1 diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-other.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-other.c index 0a4a45994fdb..76972bc562ff 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-other.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-safe-other.c @@ -13,7 +13,7 @@ // False positive suppression. //===----------------------------------------------------------------------===// -void good_memcpy_known_src() { +void good_memcpy_known_src(void) { char dest[13]; char src[] = "foobar"; memcpy(dest, src, sizeof(src)); @@ -69,7 +69,7 @@ void good_memcpy_variable_array(int dest_length) { strcpy(dst02, "foobarbazqux"); } -void bad_memcpy_equal_src_length_and_length() { +void bad_memcpy_equal_src_length_and_length(void) { char dest03[13]; const char *src = "foobarbazqux"; memcpy(dest03, src, 12); @@ -77,7 +77,7 @@ void bad_memcpy_equal_src_length_and_length() { // CHECK-FIXES: strcpy(dest03, src); } -void good_memcpy_equal_src_length_and_length() { +void good_memcpy_equal_src_length_and_length(void) { char dst03[13]; const char *src = "foobarbazqux"; strcpy(dst03, src); @@ -98,7 +98,7 @@ void good_memcpy_dest_size_overflows(const char *src) { strcpy(dst04, src); } -void bad_memcpy_macro() { +void bad_memcpy_macro(void) { char dest05[SRC_LENGTH]; memcpy(dest05, SRC, SRC_LENGTH); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result] @@ -106,7 +106,7 @@ void bad_memcpy_macro() { // CHECK-FIXES-NEXT: strcpy(dest05, SRC); } -void good_memcpy_macro() { +void good_memcpy_macro(void) { char dst05[SRC_LENGTH + 1]; strcpy(dst05, SRC); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-c.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-c.c index 53c1bdc34dcd..9d075433ab9e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-c.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-c.c @@ -2,9 +2,9 @@ // in C, double underscores are fine except at the beginning -void foo__(); -void f__o__o(); -void f_________oo(); -void __foo(); +void foo__(void); +void f__o__o(void); +void f_________oo(void); +void __foo(void); // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '__foo', which is a reserved identifier [bugprone-reserved-identifier] -// CHECK-FIXES: {{^}}void foo();{{$}} +// CHECK-FIXES: {{^}}void foo(void);{{$}} diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c index 718f47bf2287..846079a388df 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c @@ -25,7 +25,7 @@ void handler_good(int) { signal(0, SIG_DFL); } -void test() { +void test(void) { signal(SIGINT, handler_bad1); signal(SIGINT, handler_bad2); signal(SIGINT, handler_good); diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c index fba7ed88e150..28a69259bd8d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c @@ -23,7 +23,7 @@ void handler_good(int) { memcpy((void*)10, (const void*)20, 1); } -void test() { +void test(void) { signal(SIGINT, handler_good); signal(SIGINT, handler_bad); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c index 16ceacc3519d..10ee3e815adc 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c @@ -13,7 +13,7 @@ int printf(const char *, ...); typedef void (*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler); -void f_extern(); +void f_extern(void); void handler_printf(int) { printf("1234"); @@ -22,7 +22,7 @@ void handler_printf(int) { // CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_printf' registered here as signal handler } -void test_printf() { +void test_printf(void) { signal(SIGINT, handler_printf); } @@ -33,11 +33,11 @@ void handler_extern(int) { // CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_extern' registered here as signal handler } -void test_extern() { +void test_extern(void) { signal(SIGINT, handler_extern); } -void f_ok() { +void f_ok(void) { abort(); } @@ -45,11 +45,11 @@ void handler_ok(int) { f_ok(); } -void test_ok() { +void test_ok(void) { signal(SIGINT, handler_ok); } -void f_bad() { +void f_bad(void) { printf("1234"); // CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler] // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_bad' @@ -61,11 +61,11 @@ void handler_bad(int) { f_bad(); } -void test_bad() { +void test_bad(void) { signal(SIGINT, handler_bad); } -void f_bad1() { +void f_bad1(void) { printf("1234"); // CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler] // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_bad1' @@ -74,7 +74,7 @@ void f_bad1() { // CHECK-NOTES: :[[@LINE+13]]:18: note: function 'handler_bad1' registered here as signal handler } -void f_bad2() { +void f_bad2(void) { f_bad1(); } @@ -83,7 +83,7 @@ void handler_bad1(int) { f_bad1(); } -void test_bad1() { +void test_bad1(void) { signal(SIGINT, handler_bad1); } @@ -104,7 +104,7 @@ void handler_false_condition(int) { // CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_false_condition' registered here as signal handler } -void test_false_condition() { +void test_false_condition(void) { signal(SIGINT, handler_false_condition); } @@ -121,11 +121,11 @@ void handler_multiple_calls(int) { // first 'f_extern' call found only } -void test_multiple_calls() { +void test_multiple_calls(void) { signal(SIGINT, handler_multiple_calls); } -void f_recursive(); +void f_recursive(void); void handler_recursive(int) { f_recursive(); @@ -133,7 +133,7 @@ void handler_recursive(int) { // first 'printf' call (in other function) found only } -void f_recursive() { +void f_recursive(void) { f_extern(); // CHECK-NOTES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler] // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'f_extern' called here from 'f_recursive' @@ -147,11 +147,11 @@ void f_recursive() { handler_recursive(2); } -void test_recursive() { +void test_recursive(void) { signal(SIGINT, handler_recursive); } -void f_multiple_paths() { +void f_multiple_paths(void) { printf(""); // CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler] // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_multiple_paths' @@ -164,21 +164,21 @@ void handler_multiple_paths(int) { f_multiple_paths(); } -void test_multiple_paths() { +void test_multiple_paths(void) { signal(SIGINT, handler_multiple_paths); } void handler_function_pointer(int) { - void (*fp)() = f_extern; + void (*fp)(void) = f_extern; // Call with function pointer is not evalauted by the check. (*fp)(); } -void test_function_pointer() { +void test_function_pointer(void) { signal(SIGINT, handler_function_pointer); } -void test_other() { +void test_other(void) { signal(SIGINT, handler_abort); signal(SIGINT, handler_signal); diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c index fd3b94081c20..8b84474d3f2d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-spuriously-wake-up-functions.c @@ -161,4 +161,4 @@ void consume_list_element(void) { for (;; list_c.next == NULL) cnd_timedwait(&condition_c, &lock, &ts); } -int main() { return 0; } +int main(void) { return 0; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c index 1f8fc7cbb07f..e0abba013d65 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c @@ -64,13 +64,13 @@ int flp37_c_compliant(const struct S2 *s1, const struct S2 *s2) { // no-warning } -void Test_Float() { +void Test_Float(void) { float a, b; memcmp(&a, &b, sizeof(float)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'float' which does not have a unique object representation; consider comparing the values manually } -void TestArray_Float() { +void TestArray_Float(void) { float a[3], b[3]; memcmp(a, b, sizeof(a)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'float' which does not have a unique object representation; consider comparing the values manually @@ -88,12 +88,12 @@ struct NoPadding { int y; }; -void Test_NoPadding() { +void Test_NoPadding(void) { struct NoPadding a, b; memcmp(&a, &b, sizeof(struct NoPadding)); } -void TestArray_NoPadding() { +void TestArray_NoPadding(void) { struct NoPadding a[3], b[3]; memcmp(a, b, 3 * sizeof(struct NoPadding)); } @@ -103,7 +103,7 @@ struct TrailingPadding { char c; }; -void Test_TrailingPadding() { +void Test_TrailingPadding(void) { struct TrailingPadding a, b; memcmp(&a, &b, sizeof(struct TrailingPadding)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct TrailingPadding' which does not have a unique object representation; consider comparing the members of the object manually @@ -117,7 +117,7 @@ struct TrailingPadding2 { char c; }; -void Test_TrailingPadding2() { +void Test_TrailingPadding2(void) { struct TrailingPadding2 a, b; memcmp(&a, &b, 2 * sizeof(int)); // no-warning: not comparing entire object memcmp(&a, &b, sizeof(struct TrailingPadding2)); @@ -129,13 +129,13 @@ void Test_UnknownCount(size_t count) { memcmp(&a, &b, count); // no-warning: unknown count value } -void Test_ExplicitVoidCast() { +void Test_ExplicitVoidCast(void) { struct TrailingPadding a, b; memcmp((void *)&a, (void *)&b, sizeof(struct TrailingPadding)); // no-warning: explicit cast } -void TestArray_TrailingPadding() { +void TestArray_TrailingPadding(void) { struct TrailingPadding a[3], b[3]; memcmp(a, b, 3 * sizeof(struct TrailingPadding)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct TrailingPadding' which does not have a unique object representation; consider comparing the members of the object manually @@ -146,7 +146,7 @@ struct InnerPadding { int i; }; -void Test_InnerPadding() { +void Test_InnerPadding(void) { struct InnerPadding a, b; memcmp(&a, &b, sizeof(struct InnerPadding)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct InnerPadding' which does not have a unique object representation; consider comparing the members of the object manually @@ -157,7 +157,7 @@ struct Bitfield_TrailingPaddingBytes { int y : 6; }; -void Test_Bitfield_TrailingPaddingBytes() { +void Test_Bitfield_TrailingPaddingBytes(void) { struct Bitfield_TrailingPaddingBytes a, b; memcmp(&a, &b, sizeof(struct S)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_TrailingPaddingBytes' which does not have a unique object representation; consider comparing the members of the object manually @@ -168,7 +168,7 @@ struct Bitfield_TrailingPaddingBits { int y : 20; }; -void Test_Bitfield_TrailingPaddingBits() { +void Test_Bitfield_TrailingPaddingBits(void) { struct Bitfield_TrailingPaddingBits a, b; memcmp(&a, &b, sizeof(struct Bitfield_TrailingPaddingBits)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_TrailingPaddingBits' which does not have a unique object representation; consider comparing the members of the object manually @@ -180,7 +180,7 @@ struct Bitfield_InnerPaddingBits { char y : 8; }; -void Test_Bitfield_InnerPaddingBits() { +void Test_Bitfield_InnerPaddingBits(void) { struct Bitfield_InnerPaddingBits a, b; memcmp(&a, &b, sizeof(struct Bitfield_InnerPaddingBits)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_InnerPaddingBits' which does not have a unique object representation; consider comparing the members of the object manually @@ -195,7 +195,7 @@ struct Bitfield_NoPadding { _Static_assert(sizeof(struct Bitfield_NoPadding) == sizeof(int), "Bit-fields should line up perfectly"); -void Test_Bitfield_NoPadding() { +void Test_Bitfield_NoPadding(void) { struct Bitfield_NoPadding a, b; memcmp(&a, &b, sizeof(struct Bitfield_NoPadding)); // no-warning } @@ -205,7 +205,7 @@ struct Bitfield_TrailingUnnamed { int : 0; }; -void Bitfield_TrailingUnnamed() { +void Bitfield_TrailingUnnamed(void) { struct Bitfield_TrailingUnnamed a, b; memcmp(&a, &b, 2 * sizeof(int)); // no-warning memcmp(&a, &b, sizeof(struct Bitfield_TrailingUnnamed)); // no-warning @@ -220,7 +220,7 @@ struct PaddingAfterUnion { int y; }; -void Test_PaddingAfterUnion() { +void Test_PaddingAfterUnion(void) { struct PaddingAfterUnion a, b; memcmp(&a, &b, sizeof(struct PaddingAfterUnion)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingAfterUnion' which does not have a unique object representation; consider comparing the members of the object manually @@ -235,7 +235,7 @@ struct Union_NoPadding { int y; }; -void Test_Union_NoPadding() { +void Test_Union_NoPadding(void) { struct Union_NoPadding a, b; memcmp(&a, &b, 2 * sizeof(int)); memcmp(&a, &b, sizeof(struct Union_NoPadding)); @@ -250,7 +250,7 @@ union UnionWithPaddingInNestedStruct { } x; }; -void Test_UnionWithPaddingInNestedStruct() { +void Test_UnionWithPaddingInNestedStruct(void) { union UnionWithPaddingInNestedStruct a, b; memcmp(&a, &b, sizeof(union UnionWithPaddingInNestedStruct)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'union UnionWithPaddingInNestedStruct' which does not have a unique object representation; consider comparing the members of the object manually @@ -261,7 +261,7 @@ struct PaddingInNested { char y; }; -void Test_PaddingInNested() { +void Test_PaddingInNested(void) { struct PaddingInNested a, b; memcmp(&a, &b, sizeof(struct PaddingInNested)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingInNested' which does not have a unique object representation; consider comparing the members of the object manually @@ -275,7 +275,7 @@ struct PaddingAfterNested { int y; }; -void Test_PaddingAfterNested() { +void Test_PaddingAfterNested(void) { struct PaddingAfterNested a, b; memcmp(&a, &b, sizeof(struct PaddingAfterNested)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingAfterNested' which does not have a unique object representation; consider comparing the members of the object manually @@ -285,7 +285,7 @@ struct AtomicMember { _Atomic(int) x; }; -void Test_AtomicMember() { +void Test_AtomicMember(void) { // FIXME: this is a false positive as the list of objects with unique object // representations is incomplete. struct AtomicMember a, b; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.c index 61e7de50953e..ab0c2518edd5 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.c @@ -4,7 +4,7 @@ void *memset(void *, int, __SIZE_TYPE__); void *memset(void *); // CHECK-MESSAGES: :[[@LINE-1]]:7: error: conflicting types for 'memset' -void test() { +void test(void) { // no crash memset(undefine); // CHECK-MESSAGES: :[[@LINE-1]]:10: error: use of undeclared identifier diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c index ef2eaafb2df0..d4c36aa5d62f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c @@ -8,7 +8,7 @@ static const char A[] = "abc"; int strcmp(const char *, const char *); -int test_warning_patterns() { +int test_warning_patterns(void) { if (strcmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [bugprone-suspicious-string-compare] @@ -42,7 +42,7 @@ int test_warning_patterns() { // CHECK-FIXES: if (strcmp(A, "a") == 0) } -void test_structure_patterns() { +void test_structure_patterns(void) { if (strcmp(A, "a")) {} // CHECK-MESSAGES: [[@LINE-1]]:7: warning: function 'strcmp' is called without explicitly comparing result // CHECK-FIXES: if (strcmp(A, "a") != 0) {} @@ -56,7 +56,7 @@ void test_structure_patterns() { // CHECK-FIXES: for (;strcmp(A, "a") != 0;) {} } -int test_valid_patterns() { +int test_valid_patterns(void) { // The following cases are valid. if (strcmp(A, "a") < 0) return 0; if (strcmp(A, "a") == 0) return 0; diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert-err33-c.c b/clang-tools-extra/test/clang-tidy/checkers/cert-err33-c.c index b28b54366b5e..520ff17bd890 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert-err33-c.c +++ b/clang-tools-extra/test/clang-tidy/checkers/cert-err33-c.c @@ -2,14 +2,14 @@ typedef __SIZE_TYPE__ size_t; void *aligned_alloc(size_t alignment, size_t size); -void test_aligned_alloc() { +void test_aligned_alloc(void) { aligned_alloc(2, 10); // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning } long strtol(const char *restrict nptr, char **restrict endptr, int base); -void test_strtol() { +void test_strtol(void) { strtol("123", 0, 10); // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning @@ -17,7 +17,7 @@ void test_strtol() { typedef char wchar_t; int wscanf_s(const wchar_t *restrict format, ...); -void test_wscanf_s() { +void test_wscanf_s(void) { int Val; wscanf_s("%i", &Val); // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert-limited-randomness.c b/clang-tools-extra/test/clang-tidy/checkers/cert-limited-randomness.c index c8009b55ba82..32e4a07b4091 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert-limited-randomness.c +++ b/clang-tools-extra/test/clang-tidy/checkers/cert-limited-randomness.c @@ -1,9 +1,9 @@ // RUN: %check_clang_tidy %s cert-msc30-c %t extern int rand(void); -int nonrand(); +int nonrand(void); -int cTest() { +int cTest(void) { int i = rand(); // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness [cert-msc30-c] diff --git a/clang-tools-extra/test/clang-tidy/checkers/cert-msc32-c.c b/clang-tools-extra/test/clang-tidy/checkers/cert-msc32-c.c index 6cc40fa2ba66..755326e7e793 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cert-msc32-c.c +++ b/clang-tools-extra/test/clang-tidy/checkers/cert-msc32-c.c @@ -4,7 +4,7 @@ void srand(int seed); typedef int time_t; time_t time(time_t *t); -void f() { +void f(void) { srand(1); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c] @@ -17,7 +17,7 @@ void f() { // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc32-c] } -void g() { +void g(void) { typedef int user_t; user_t a = 1; srand(a); diff --git a/clang-tools-extra/test/clang-tidy/checkers/google-runtime-int.c b/clang-tools-extra/test/clang-tidy/checkers/google-runtime-int.c index 8657e2dd212a..feb9d9aef25a 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/google-runtime-int.c +++ b/clang-tools-extra/test/clang-tidy/checkers/google-runtime-int.c @@ -1,6 +1,6 @@ // RUN: clang-tidy -checks=-*,google-runtime-int %s -- -x c 2>&1 | not grep 'warning:\|error:' -long a(); +long a(void); long b(long x); @@ -22,6 +22,6 @@ short bar(const short q, unsigned short w) { return q; } -void qux() { +void qux(void) { short port; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/linuxkernel-must-check-errs.c b/clang-tools-extra/test/clang-tidy/checkers/linuxkernel-must-check-errs.c index a025516f2717..99b48c19857c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/linuxkernel-must-check-errs.c +++ b/clang-tools-extra/test/clang-tidy/checkers/linuxkernel-must-check-errs.c @@ -10,7 +10,7 @@ int __must_check IS_ERR_OR_NULL(const void *ptr); void * __must_check ERR_CAST(const void *ptr); int __must_check PTR_ERR_OR_ZERO(const void *ptr); -void f() { +void f(void) { ERR_PTR(0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'ERR_PTR' is unused PTR_ERR((void *)0); @@ -24,18 +24,18 @@ out: // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'PTR_ERR_OR_ZERO' is unused } -void *f1() { +void *f1(void) { return ERR_PTR(0); } -long f2() { +long f2(void) { if (IS_ERR((void *)0)) { return PTR_ERR((void *)0); } return -1; } -void f3() { +void f3(void) { f1(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'f1' is unused but represents an error value f2(); diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.c b/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.c index e3e8304977c6..a3edf8398e38 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.c +++ b/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.c @@ -1,7 +1,7 @@ // RUN: %check_clang_tidy %s misc-static-assert %t -- -- -std=c11 // RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0 -void abort() {} +void abort(void) {} #ifdef NDEBUG #define assert(x) 1 #else diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.c b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.c index 67e9a3be9692..bde93ea219a5 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.c +++ b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.c @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -xc +// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -Wno-strict-prototypes -xc // Basic removal // ============= diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.c b/clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.c index fdaf37570691..bbbf73f9c676 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.c +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.c @@ -1,4 +1,4 @@ -// RUN: clang-tidy -checks=-*,modernize-redundant-void-arg %s -- -x c | count 0 +// RUN: clang-tidy -checks=-*,modernize-redundant-void-arg %s -- -Wno-strict-prototypes -x c | count 0 #define NULL 0 @@ -38,7 +38,7 @@ void (*(*returns_fn_returns_fn_void_void(void))(void))(void) { return NULL; } -void bar() { +void bar(void) { int i; int *pi = NULL; void *pv = (void *) pi; diff --git a/clang-tools-extra/test/clang-tidy/checkers/objc-assert-equals.m b/clang-tools-extra/test/clang-tidy/checkers/objc-assert-equals.m index e79d08345ef1..2620bb86c3a6 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/objc-assert-equals.m +++ b/clang-tools-extra/test/clang-tidy/checkers/objc-assert-equals.m @@ -1,10 +1,10 @@ // RUN: %check_clang_tidy %s objc-assert-equals %t -- -- -I %S/Inputs/objc-assert #include "XCTestAssertions.h" // Can't reference NSString directly so we use this getStr() instead. -__typeof(@"abc") getStr() { +__typeof(@"abc") getStr(void) { return @"abc"; } -void foo() { +void foo(void) { XCTAssertEqual(getStr(), @"abc"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use XCTAssertEqualObjects for comparing objects // CHECK-FIXES: XCTAssertEqualObjects(getStr(), @"abc"); diff --git a/clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m b/clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m index 48396e47e94b..3583a3ee76a5 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m +++ b/clang-tools-extra/test/clang-tidy/checkers/objc-nsinvocation-argument-lifetime.m @@ -29,9 +29,9 @@ void foo(NSInvocation *Invocation) { // CHECK-FIXES: __unsafe_unretained id Arg5; id ReturnValue; // CHECK-FIXES: __unsafe_unretained id ReturnValue; - void (^BlockArg1)(); - // CHECK-FIXES: __unsafe_unretained void (^BlockArg1)(); - __unsafe_unretained void (^BlockArg2)(); + void (^BlockArg1)(void); + // CHECK-FIXES: __unsafe_unretained void (^BlockArg1)(void); + __unsafe_unretained void (^BlockArg2)(void); int IntVar; struct Foo Bar; diff --git a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp index d1d3b0e441f3..c9a7ef6503ba 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp @@ -20,7 +20,7 @@ void n0(const int a) { // 'parallel' directive can have 'default' clause, but said clause is not // specified, diagnosed. -void p0_0() { +void p0_0(void) { #pragma omp parallel ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does not specify 'default' clause, consider specifying 'default(none)' clause @@ -28,14 +28,14 @@ void p0_0() { // 'parallel' directive can have 'default' clause, and said clause specified, // with 'none' kind, all good. -void p0_1() { +void p0_1(void) { #pragma omp parallel default(none) ; } // 'parallel' directive can have 'default' clause, and said clause specified, // but with 'shared' kind, which is not 'none', diagnose. -void p0_2() { +void p0_2(void) { #pragma omp parallel default(shared) ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(shared)' clause, consider using 'default(none)' clause instead @@ -44,7 +44,7 @@ void p0_2() { // 'parallel' directive can have 'default' clause, and said clause specified, // but with 'firstprivate' kind, which is not 'none', diagnose. -void p0_3() { +void p0_3(void) { #pragma omp parallel default(firstprivate) ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead @@ -55,7 +55,7 @@ void p0_3() { // 'task' directive can have 'default' clause, but said clause is not // specified, diagnosed. -void p1_0() { +void p1_0(void) { #pragma omp task ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not specify 'default' clause, consider specifying 'default(none)' clause @@ -63,14 +63,14 @@ void p1_0() { // 'task' directive can have 'default' clause, and said clause specified, // with 'none' kind, all good. -void p1_1() { +void p1_1(void) { #pragma omp task default(none) ; } // 'task' directive can have 'default' clause, and said clause specified, // but with 'shared' kind, which is not 'none', diagnose. -void p1_2() { +void p1_2(void) { #pragma omp task default(shared) ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(shared)' clause, consider using 'default(none)' clause instead @@ -79,7 +79,7 @@ void p1_2() { // 'task' directive can have 'default' clause, and said clause specified, // but with 'firstprivate' kind, which is not 'none', diagnose. -void p1_3() { +void p1_3(void) { #pragma omp task default(firstprivate) ; // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead @@ -90,7 +90,7 @@ void p1_3() { // 'teams' directive can have 'default' clause, but said clause is not // specified, diagnosed. -void p2_0() { +void p2_0(void) { #pragma omp target #pragma omp teams ; @@ -99,7 +99,7 @@ void p2_0() { // 'teams' directive can have 'default' clause, and said clause specified, // with 'none' kind, all good. -void p2_1() { +void p2_1(void) { #pragma omp target #pragma omp teams default(none) ; @@ -107,7 +107,7 @@ void p2_1() { // 'teams' directive can have 'default' clause, and said clause specified, // but with 'shared' kind, which is not 'none', diagnose. -void p2_2() { +void p2_2(void) { #pragma omp target #pragma omp teams default(shared) ; @@ -117,7 +117,7 @@ void p2_2() { // 'teams' directive can have 'default' clause, and said clause specified, // but with 'firstprivate' kind, which is not 'none', diagnose. -void p2_3() { +void p2_3(void) { #pragma omp target #pragma omp teams default(firstprivate) ; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-isolate-declaration.c b/clang-tools-extra/test/clang-tidy/checkers/readability-isolate-declaration.c index e09a581fa9fc..e1960a15b8d8 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability-isolate-declaration.c +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-isolate-declaration.c @@ -1,6 +1,6 @@ // RUN: %check_clang_tidy %s readability-isolate-declaration %t -void c_specific() { +void c_specific(void) { void (*signal(int sig, void (*func)(int)))(int); int i = sizeof(struct S { int i; }); int j = sizeof(struct T { int i; }), k; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.c b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.c index 21172637268e..c2e8bf68b4ad 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.c +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.c @@ -16,16 +16,16 @@ extern int Buf[10]; // Buf[10] // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Buf' declaration // CHECK-FIXES: {{^}}// Buf[10]{{$}} -static int f(); -static int f(); // f +static int f(void); +static int f(void); // f // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'f' declaration // CHECK-FIXES: {{^}}// f{{$}} -static int f() {} +static int f(void) {} -inline void g() {} +inline void g(void) {} -inline void g(); +inline void g(void); // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant 'g' declaration // OK: Needed to emit an external definition. -extern inline void g(); +extern inline void g(void);