Skip to content

Commit e765e0b

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 first batch of tests being updated (there are a significant number of other tests left to be updated).
1 parent 4db89e2 commit e765e0b

File tree

111 files changed

+477
-476
lines changed

Some content is hidden

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

111 files changed

+477
-476
lines changed

clang/test/Sema/2010-05-31-palignr.c

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

66
extern int i;
77

8-
int main ()
8+
int main (void)
99
{
1010
typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
1111

clang/test/Sema/Float16.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _Float16 f;
1111

1212
#ifdef HAVE
1313
_Complex _Float16 a;
14-
void builtin_complex() {
14+
void builtin_complex(void) {
1515
_Float16 a = 0;
1616
(void)__builtin_complex(a, a); // expected-error {{'_Complex _Float16' is invalid}}
1717
}

clang/test/Sema/MicrosoftExtensions.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct test {
6868
NESTED6; // expected-warning {{anonymous unions are a Microsoft extension}}
6969
};
7070

71-
void foo()
71+
void foo(void)
7272
{
7373
struct test var;
7474
var.a;
@@ -148,14 +148,14 @@ void ptr_func2(int * __sptr __ptr32 i) {} // expected-note {{previous definitio
148148
void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
149149

150150
// Check for warning when return types have the type attribute.
151-
void *__ptr32 ptr_func3() { return 0; } // expected-note {{previous definition is here}}
152-
void *__ptr64 ptr_func3() { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
151+
void *__ptr32 ptr_func3(void) { return 0; } // expected-note {{previous definition is here}}
152+
void *__ptr64 ptr_func3(void) { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
153153

154154
// Test that __ptr32/__ptr64 can be passed as arguments with other address
155155
// spaces.
156156
void ptr_func4(int *i);
157157
void ptr_func5(int *__ptr32 i);
158-
void test_ptr_arguments() {
158+
void test_ptr_arguments(void) {
159159
int *__ptr64 i64;
160160
ptr_func4(i64);
161161
ptr_func5(i64);
@@ -191,7 +191,7 @@ void myprintf(const char *f, ...) {
191191
}
192192

193193
// __unaligned handling
194-
void test_unaligned() {
194+
void test_unaligned(void) {
195195
__unaligned int *p1 = 0;
196196
int *p2 = p1; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}
197197
__unaligned int *p3 = p2;

clang/test/Sema/PR28181.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ struct spinlock_t {
44
int lock;
55
} audit_skb_queue;
66

7-
void fn1() {
7+
void fn1(void) {
88
audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
99
} // expected-error@-1 {{assigning to 'struct spinlock_t' from incompatible type '<overloaded function type>'}}
1010

11-
void fn2() {
11+
void fn2(void) {
1212
audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
1313
} // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}

clang/test/Sema/__try.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ typedef int DWORD;
1111

1212
struct EXCEPTION_INFO{};
1313

14-
unsigned long __exception_code();
14+
unsigned long __exception_code(void);
1515
#ifdef BORLAND
16-
struct EXCEPTION_INFO* __exception_info();
16+
struct EXCEPTION_INFO* __exception_info(void);
1717
#endif
18-
int __abnormal_termination();
18+
int __abnormal_termination(void);
1919

2020
#define GetExceptionCode __exception_code
2121
#define GetExceptionInformation __exception_info
@@ -26,9 +26,9 @@ int __abnormal_termination();
2626
DWORD FilterExpression(int); // expected-note{{declared here}}
2727
DWORD FilterExceptionInformation(struct EXCEPTION_INFO*);
2828

29-
const char * NotFilterExpression();
29+
const char * NotFilterExpression(void);
3030

31-
void TEST() {
31+
void TEST(void) {
3232
__try {
3333
__try {
3434
__try {
@@ -43,32 +43,32 @@ void TEST() {
4343
}
4444
}
4545

46-
void TEST() {
46+
void TEST(void) {
4747
__try {
4848

4949
}
5050
} // expected-error{{expected '__except' or '__finally' block}}
5151

52-
void TEST() {
52+
void TEST(void) {
5353
__except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
5454
// expected-error{{too few arguments to function call, expected 1, have 0}} \
5555
// expected-error{{expected ';' after expression}}
5656
}
5757
}
5858

59-
void TEST() {
59+
void TEST(void) {
6060
__finally { } // expected-error{{}}
6161
}
6262

63-
void TEST() {
63+
void TEST(void) {
6464
__try{
6565
int try_scope = 0;
6666
} // TODO: expected expression is an extra error
6767
__except( try_scope ? 1 : -1 ) // expected-error{{undeclared identifier 'try_scope'}} expected-error{{expected expression}}
6868
{}
6969
}
7070

71-
void TEST() {
71+
void TEST(void) {
7272
__try {
7373

7474
}
@@ -77,7 +77,7 @@ void TEST() {
7777
}
7878
}
7979

80-
void TEST() {
80+
void TEST(void) {
8181
__try {
8282

8383
}
@@ -107,7 +107,7 @@ void TEST() {
107107
}
108108
}
109109

110-
void TEST() {
110+
void TEST(void) {
111111
__try {
112112

113113
}
@@ -116,7 +116,7 @@ void TEST() {
116116
}
117117
}
118118

119-
void TEST() {
119+
void TEST(void) {
120120
int function_scope = 0;
121121
__try {
122122
int try_scope = 0;
@@ -127,7 +127,7 @@ void TEST() {
127127
}
128128
}
129129

130-
void TEST() {
130+
void TEST(void) {
131131
int function_scope = 0;
132132
__try {
133133
int try_scope = 0;
@@ -138,7 +138,7 @@ void TEST() {
138138
}
139139
}
140140

141-
void TEST() {
141+
void TEST(void) {
142142
int function_scope = 0;
143143
__try {
144144

@@ -147,7 +147,7 @@ void TEST() {
147147
}
148148

149149
#ifdef BORLAND
150-
void TEST() {
150+
void TEST(void) {
151151
(void)__abnormal_termination(); // expected-error{{only allowed in __finally block}}
152152
(void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
153153

@@ -169,28 +169,28 @@ void TEST() {
169169
}
170170
#endif
171171

172-
void TEST() {
172+
void TEST(void) {
173173
(void)__exception_info(); // expected-error{{only allowed in __except filter expression}}
174174
(void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
175175
}
176176

177-
void TEST() {
177+
void TEST(void) {
178178
#ifndef BORLAND
179179
(void)__exception_code; // expected-error{{builtin functions must be directly called}}
180180
#endif
181181
(void)__exception_code(); // expected-error{{only allowed in __except block or filter expression}}
182182
(void)GetExceptionCode(); // expected-error{{only allowed in __except block or filter expression}}
183183
}
184184

185-
void TEST() {
185+
void TEST(void) {
186186
__try {
187187
} __except(1) {
188188
GetExceptionCode(); // valid
189189
GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
190190
}
191191
}
192192

193-
void test_seh_leave_stmt() {
193+
void test_seh_leave_stmt(void) {
194194
__leave; // expected-error{{'__leave' statement not in __try block}}
195195

196196
__try {
@@ -208,7 +208,7 @@ void test_seh_leave_stmt() {
208208
__leave; // expected-error{{'__leave' statement not in __try block}}
209209
}
210210

211-
void test_jump_out_of___finally() {
211+
void test_jump_out_of___finally(void) {
212212
while(1) {
213213
__try {
214214
} __finally {
@@ -282,7 +282,7 @@ void test_jump_out_of___finally() {
282282
}
283283
}
284284

285-
void test_typo_in_except() {
285+
void test_typo_in_except(void) {
286286
__try {
287287
} __except(undeclared_identifier) { // expected-error {{use of undeclared identifier 'undeclared_identifier'}} expected-error {{expected expression}}
288288
}

clang/test/Sema/aarch64-branch-protection-attr-err.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22

33
__attribute__((target("branch-protection=foo"))) // expected-error {{invalid or misplaced branch protection specification 'foo'}}
44
void
5-
badvalue0() {}
5+
badvalue0(void) {}
66

77
__attribute__((target("branch-protection=+bti"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
88
void
9-
badvalue1() {}
9+
badvalue1(void) {}
1010

1111
__attribute__((target("branch-protection=bti+"))) // expected-error {{invalid or misplaced branch protection specification '<empty>'}}
1212
void
13-
badvalue2() {}
13+
badvalue2(void) {}
1414

1515
__attribute__((target("branch-protection=pac-ret+bkey"))) // expected-error {{invalid or misplaced branch protection specification 'bkey'}}
1616
void
17-
badvalue3() {}
17+
badvalue3(void) {}
1818

1919
__attribute__((target("branch-protection=bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
2020
void
21-
badoption0() {}
21+
badoption0(void) {}
2222

2323
__attribute__((target("branch-protection=bti+leaf+pac-ret"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
2424
void
25-
badorder0() {}
25+
badorder0(void) {}
2626

2727
__attribute__((target("branch-protection=pac-ret+bti+leaf"))) // expected-error {{invalid or misplaced branch protection specification 'leaf'}}
2828
void
29-
badorder1() {}
29+
badorder1(void) {}

clang/test/Sema/aarch64-special-register.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ void wsr64_1(unsigned long v) {
1616
__builtin_arm_wsr64("sysreg", v);
1717
}
1818

19-
unsigned rsr_1() {
19+
unsigned rsr_1(void) {
2020
return __builtin_arm_rsr("sysreg");
2121
}
2222

23-
void *rsrp_1() {
23+
void *rsrp_1(void) {
2424
return __builtin_arm_rsrp("sysreg");
2525
}
2626

27-
unsigned long rsr64_1() {
27+
unsigned long rsr64_1(void) {
2828
return __builtin_arm_rsr64("sysreg");
2929
}
3030

@@ -40,15 +40,15 @@ void wsr64_2(unsigned long v) {
4040
__builtin_arm_wsr64("0:1:2:3:4", v);
4141
}
4242

43-
unsigned rsr_2() {
43+
unsigned rsr_2(void) {
4444
return __builtin_arm_rsr("0:1:15:15:4");
4545
}
4646

47-
void *rsrp_2() {
47+
void *rsrp_2(void) {
4848
return __builtin_arm_rsrp("0:1:2:3:4");
4949
}
5050

51-
unsigned long rsr64_2() {
51+
unsigned long rsr64_2(void) {
5252
return __builtin_arm_rsr64("0:1:15:15:4");
5353
}
5454

@@ -64,38 +64,38 @@ void wsr64_3(unsigned long v) {
6464
__builtin_arm_wsr64("0:1:2", v); //expected-error {{invalid special register for builtin}}
6565
}
6666

67-
unsigned rsr_3() {
67+
unsigned rsr_3(void) {
6868
return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special register for builtin}}
6969
}
7070

71-
unsigned rsr_4() {
71+
unsigned rsr_4(void) {
7272
return __builtin_arm_rsr("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
7373
}
7474

75-
unsigned rsr_5() {
75+
unsigned rsr_5(void) {
7676
return __builtin_arm_rsr("0:8:1:2:3"); //expected-error {{invalid special register for builtin}}
7777
}
7878

79-
unsigned rsr_6() {
79+
unsigned rsr_6(void) {
8080
return __builtin_arm_rsr("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
8181
}
8282

83-
void *rsrp_3() {
83+
void *rsrp_3(void) {
8484
return __builtin_arm_rsrp("0:1:2"); //expected-error {{invalid special register for builtin}}
8585
}
8686

87-
unsigned long rsr64_3() {
87+
unsigned long rsr64_3(void) {
8888
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
8989
}
9090

91-
unsigned long rsr64_4() {
91+
unsigned long rsr64_4(void) {
9292
return __builtin_arm_rsr64("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
9393
}
9494

95-
unsigned long rsr64_5() {
95+
unsigned long rsr64_5(void) {
9696
return __builtin_arm_rsr64("0:8:2:3:4"); //expected-error {{invalid special register for builtin}}
9797
}
9898

99-
unsigned long rsr64_6() {
99+
unsigned long rsr64_6(void) {
100100
return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
101101
}

clang/test/Sema/aarch64-sve-types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve,+bf16 -fsyntax-only -verify
22

3-
void f() {
3+
void f(void) {
44
int size_s8[sizeof(__SVInt8_t) == 0 ? 1 : -1]; // expected-error {{invalid application of 'sizeof' to sizeless type '__SVInt8_t'}}
55
int align_s8[__alignof__(__SVInt8_t) == 16 ? 1 : -1]; // expected-error {{invalid application of '__alignof' to sizeless type '__SVInt8_t'}}
66

clang/test/Sema/aarch64-tme-errors.c

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

33
#include "arm_acle.h"
44

5-
void test_no_tme_funcs() {
5+
void test_no_tme_funcs(void) {
66
__tstart(); // expected-warning{{implicit declaration of function '__tstart'}}
77
__builtin_tstart(); // expected-error{{use of unknown builtin '__builtin_tstart'}}
88
}

clang/test/Sema/aarch64-tme-tcancel-errors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ void t_cancel_const(unsigned short u) {
44
}
55

66
// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +tme -verify %s
7-
void t_cancel_range() {
7+
void t_cancel_range(void) {
88
__builtin_arm_tcancel(0x12345u); // expected-error{{argument value 74565 is outside the valid range [0, 65535]}}
99
}

0 commit comments

Comments
 (0)