Skip to content

Commit 7deaeb2

Browse files
committed
Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the fourth batch of tests being updated (there are a significant number of other tests left to be updated).
1 parent 5c9ee35 commit 7deaeb2

File tree

166 files changed

+401
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+401
-401
lines changed

clang/test/Parser/CompoundStmtScope.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

3-
void foo() {
3+
void foo(void) {
44
{
55
typedef float X;
66
}

clang/test/Parser/MicrosoftExtensions.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ int * __sptr * __ptr32 ppsp32;
9494

9595
// Ignored type qualifiers after comma in declarator lists
9696
typedef int ignored_quals_dummy1, const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1; // expected-warning {{qualifiers after comma in declarator list are ignored}}
97-
typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
98-
typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
99-
typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
100-
typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
101-
typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
97+
typedef void(*ignored_quals_dummy2)(void), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
98+
typedef void(*ignored_quals_dummy3)(void), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
99+
typedef void(*ignored_quals_dummy4)(void), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
100+
typedef void(*ignored_quals_dummy5)(void), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
101+
typedef void(*ignored_quals_dummy6)(void), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
102102

103103
__declspec(align(16)) struct align_before_key1 {};
104104
__declspec(align(16)) struct align_before_key2 {} align_before_key2_var;

clang/test/Parser/altivec-non-type-vector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
55
// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
66

7-
int vector();
7+
int vector(void);
88

9-
void test() {
9+
void test(void) {
1010
vector unsigned int v = {0};
1111
}

clang/test/Parser/altivec-typedef-vector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
typedef int vector;
88

9-
void test() {
9+
void test(void) {
1010
vector unsigned int v = {0};
1111
}

clang/test/Parser/altivec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ __vector __bool short vv___bs;
2525
__vector __bool int vv___bi;
2626
__vector __pixel vv_p;
2727
__vector pixel vv__p;
28-
__vector int vf__r();
28+
__vector int vf__r(void);
2929
void vf__a(__vector int a);
3030
void vf__a2(int b, __vector int a);
3131

@@ -50,7 +50,7 @@ vector __bool short v___bs;
5050
vector __bool int v___bi;
5151
vector __pixel v_p;
5252
vector pixel v__p;
53-
vector int f__r();
53+
vector int f__r(void);
5454
void f_a(vector int a);
5555
void f_a2(int b, vector int a);
5656

@@ -146,7 +146,7 @@ struct S {
146146
vector short i32;
147147
};
148148

149-
void f() {
149+
void f(void) {
150150
__vector unsigned int v = {0,0,0,0};
151151
__vector int v__cast = (__vector int)v;
152152
__vector int v_cast = (vector int)v;

clang/test/Parser/asm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
#error Extension 'gnu_asm' should be available by default
55
#endif
66

7-
void f1() {
7+
void f1(void) {
88
// PR7673: Some versions of GCC support an empty clobbers section.
99
asm ("ret" : : :);
1010
}
1111

12-
void f2() {
12+
void f2(void) {
1313
asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
1414
asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
1515
}
1616

17-
void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
18-
void a() {
17+
void a(void) __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
18+
void a(void) {
1919
__asm__(""); // ok
2020
}
2121

clang/test/Parser/atomic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ typedef int (*_Atomic atomic_int_ptr); // ext-warning {{'_Atomic' is a C11 exten
2525
typedef int _Atomic *int_atomic_ptr; // ext-warning {{'_Atomic' is a C11 extension}}
2626
typedef _Atomic(int) *int_atomic_ptr; // ext-warning {{'_Atomic' is a C11 extension}}
2727

28-
typedef int int_fn();
29-
typedef _Atomic int_fn atomic_int_fn; // expected-error {{_Atomic cannot be applied to function type 'int_fn' (aka 'int ()')}} \
28+
typedef int int_fn(void);
29+
typedef _Atomic int_fn atomic_int_fn; // expected-error {{_Atomic cannot be applied to function type 'int_fn' (aka 'int (void)')}} \
3030
// ext-warning {{'_Atomic' is a C11 extension}}
3131
typedef _Atomic int atomic_int_array[3]; // ext-warning {{'_Atomic' is a C11 extension}}
3232
typedef _Atomic atomic_int_array atomic_int_atomic_array; // expected-error {{_Atomic cannot be applied to array type 'atomic_int_array' (aka '_Atomic(int)[3]')}} \
@@ -44,4 +44,4 @@ typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int; // ext-
4444
struct S
4545
_Atomic atomic_s_no_missing_semicolon; // ext-warning {{'_Atomic' is a C11 extension}}
4646

47-
int *const _Atomic atomic_return_type(); // ext-warning {{'_Atomic' is a C11 extension}}
47+
int *const _Atomic atomic_return_type(void); // ext-warning {{'_Atomic' is a C11 extension}}

clang/test/Parser/attr-availability.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
# error 'availability' attribute is not available
55
#endif
66

7-
void f0() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
7+
void f0(void) __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
88

9-
void f1() __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6)));
9+
void f1(void) __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6)));
1010

11-
void f2() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6)));
11+
void f2(void) __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6)));
1212

13-
void f3() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}}
13+
void f3(void) __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}}
1414

15-
void f4() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable)));
15+
void f4(void) __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable)));
1616

17-
void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
17+
void f5(void) __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
1818

19-
void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
19+
void f6(void) __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
2020

21-
void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
21+
void f7(void) __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
2222

23-
void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
23+
void f8(void) __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
2424

25-
void f9() __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
25+
void f9(void) __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
2626

27-
void f10() __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
27+
void f10(void) __attribute__((availability(macosx,message="a" u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
2828

29-
void f11() __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
29+
void f11(void) __attribute__((availability(macosx,message=u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
3030

31-
void f12() __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
31+
void f12(void) __attribute__((availability(macosx,message="a" u"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
3232

3333
// rdar://10095131
3434
enum E{
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

3-
void function() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
3+
void function(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
44

55
__attribute__((external_source_symbol(language="Swift", defined_in="module")))
66
@interface I
@@ -14,71 +14,71 @@ CaseA __attribute__((external_source_symbol(generated_declaration))),
1414
CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
1515
} __attribute__((external_source_symbol(language = "Swift")));
1616

17-
void f2()
17+
void f2(void)
1818
__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
19-
void f3()
19+
void f3(void)
2020
__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
21-
void f4()
21+
void f4(void)
2222
__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
23-
void f5()
23+
void f5(void)
2424
__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
25-
void f6()
25+
void f6(void)
2626
__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
2727

28-
void f7()
28+
void f7(void)
2929
__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
30-
void f8()
30+
void f8(void)
3131
__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
32-
void f9()
32+
void f9(void)
3333
__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
3434

35-
void f10()
35+
void f10(void)
3636
__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
3737

38-
void f11()
38+
void f11(void)
3939
__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
4040

41-
void f12()
41+
void f12(void)
4242
__attribute__((external_source_symbol(language="C Sharp", defined_in="file:////Hello world with spaces. cs")));
4343

44-
void f13()
44+
void f13(void)
4545
__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
4646

47-
void f14()
47+
void f14(void)
4848
__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
4949

50-
void f15()
50+
void f15(void)
5151
__attribute__((external_source_symbol(="Swift"))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
5252

53-
void f16()
53+
void f16(void)
5454
__attribute__((external_source_symbol("Swift", "module", generated_declaration))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
5555

56-
void f17()
56+
void f17(void)
5757
__attribute__((external_source_symbol(language="Swift", "generated_declaration"))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
5858

59-
void f18()
59+
void f18(void)
6060
__attribute__((external_source_symbol(language= =))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
6161

62-
void f19()
62+
void f19(void)
6363
__attribute__((external_source_symbol(defined_in="module" language="swift"))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
6464

65-
void f20()
65+
void f20(void)
6666
__attribute__((external_source_symbol(defined_in="module" language="swift" generated_declaration))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
6767

68-
void f21()
68+
void f21(void)
6969
__attribute__((external_source_symbol(defined_in= language="swift"))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
7070

71-
void f22()
71+
void f22(void)
7272
__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
7373

74-
void f23()
74+
void f23(void)
7575
__attribute__((external_source_symbol(defined_in=, language="swift" generated_declaration))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}} expected-error{{expected ')'}} expected-note{{to match this '('}}
7676

77-
void f24()
77+
void f24(void)
7878
__attribute__((external_source_symbol(language = generated_declaration))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
7979

80-
void f25()
80+
void f25(void)
8181
__attribute__((external_source_symbol(defined_in=123, defined_in="module"))); // expected-error {{expected string literal for source container name in 'external_source_symbol'}} expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
8282

83-
void f26()
83+
void f26(void)
8484
__attribute__((external_source_symbol(language=Swift, language="Swift", error))); // expected-error {{expected string literal for language name in 'external_source_symbol'}} expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}} expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}

clang/test/Parser/attributes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
5555

5656

5757
// PR6287
58-
void __attribute__((returns_twice)) returns_twice_test();
58+
void __attribute__((returns_twice)) returns_twice_test(void);
5959

6060
int aligned(int);
6161
int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}}
@@ -70,7 +70,7 @@ int testFundef1(int *a) __attribute__((nonnull(1))) { // \
7070
}
7171

7272
// noreturn is lifted to type qualifier
73-
void testFundef2() __attribute__((noreturn)) { // \
73+
void testFundef2(void) __attribute__((noreturn)) { // \
7474
// expected-warning {{GCC does not allow 'noreturn' attribute in this position on a function definition}}
7575
testFundef2();
7676
}
@@ -90,7 +90,7 @@ int testFundef4(int *a) __attribute__((nonnull(1))) // \
9090
}
9191

9292
// GCC allows these
93-
void testFundef5() __attribute__(()) { }
93+
void testFundef5(void) __attribute__(()) { }
9494

9595
__attribute__((pure)) int testFundef6(int a) { return a; }
9696

clang/test/Parser/bad-control.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* RUN: %clang_cc1 -fsyntax-only -verify %s
22
*/
3-
void foo() {
3+
void foo(void) {
44
break; /* expected-error {{'break' statement not in loop or switch statement}} */
55
}
66

7-
void foo2() {
7+
void foo2(void) {
88
continue; /* expected-error {{'continue' statement not in loop statement}} */
99
}
1010

@@ -15,10 +15,10 @@ int pr8880_9 (int first) {
1515
}
1616
}
1717

18-
void pr8880_24() {
18+
void pr8880_24(void) {
1919
for (({break;});;); // expected-error {{'break' statement not in loop or switch statement}}
2020
}
2121

22-
void pr8880_25() {
22+
void pr8880_25(void) {
2323
for (({continue;});;); // expected-error {{'continue' statement not in loop statement}}
2424
}

clang/test/Parser/block-block-storageclass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int printf(const char *, ...);
44
void _Block_byref_release(void*src){}
55

6-
int main() {
6+
int main(void) {
77
__block int X = 1234;
88
__block const char * message = "HELLO";
99

clang/test/Parser/brackets.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: %clang_cc1 -fsyntax-only %t -x c -DFIXIT
55
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -strict-whitespace
66

7-
void test1() {
7+
void test1(void) {
88
int a[] = {0,1,1,2,3};
99
int []b = {0,1,4,9,16};
1010
// expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
@@ -32,7 +32,7 @@ struct S {
3232
} s;
3333

3434
#ifndef FIXIT
35-
void test2() {
35+
void test2(void) {
3636
int [][][];
3737
// expected-error@-1{{expected identifier or '('}}
3838
// CHECK: {{^}} int [][][];
@@ -47,7 +47,7 @@ void test2() {
4747
};
4848
}
4949

50-
void test3() {
50+
void test3(void) {
5151
int [5] *;
5252
// expected-error@-1{{expected identifier or '('}}
5353
// CHECK: {{^}} int [5] *;

clang/test/Parser/builtin_classify_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
struct foo { int a; };
44

5-
int main() {
5+
int main(void) {
66
int a;
77
float b;
88
double d;

clang/test/Parser/builtin_source_location.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

3-
int main() {
3+
int main(void) {
44
int line = __builtin_LINE();
55
__builtin_LINE(42); // expected-error {{expected ')'}}
66
__builtin_LINE(double); // expected-error {{expected ')'}}

clang/test/Parser/builtin_types_compatible.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern double funcDouble(double);
1818
__builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), float), funcFloat(expr), \
1919
__builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), double), funcDouble(expr), (void)0)))
2020

21-
static void test()
21+
static void test(void)
2222
{
2323
int a;
2424
float b;
@@ -44,7 +44,7 @@ static void test()
4444
enum E1 { E1Foo };
4545
enum E2 { E2Foo };
4646

47-
static void testGccCompatibility() {
47+
static void testGccCompatibility(void) {
4848
_Static_assert(__builtin_types_compatible_p(const volatile int, int), "");
4949
_Static_assert(__builtin_types_compatible_p(int[5], int[]), "");
5050
_Static_assert(!__builtin_types_compatible_p(int[5], int[4]), "");

clang/test/Parser/c-namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only %s
2-
void bla1() {
2+
void bla1(void) {
33
struct XXX;
44
int XXX;
55
}

0 commit comments

Comments
 (0)