[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / warn-strict-prototypes.c
blob50b0f7d060f2eb11f704682fdebc82f9e43bbdff
1 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
2 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
4 // function definition with 0 params, no prototype, no preceding declaration.
5 void foo0() {} // expected-warning {{this old-style function definition is not preceded by a prototype}}
7 // function declaration with unspecified params
8 void foo1(); // expected-warning {{this function declaration is not a prototype}}
9 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:"void"
10 // function declaration with 0 params
11 void foo2(void);
13 // function definition with 0 params, no prototype.
14 void foo1() {} // expected-warning {{this old-style function definition is not preceded by a prototype}}
15 // function definition with 0 params, prototype.
16 void foo2(void) {}
18 // function type typedef unspecified params
19 typedef void foo3(); // expected-warning {{this function declaration is not a prototype}}
20 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:19}:"void"
22 // global fp unspecified params
23 void (*foo4)(); // expected-warning {{this function declaration is not a prototype}}
24 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"void"
26 // struct member fp unspecified params
27 struct { void (*foo5)(); } s; // expected-warning {{this function declaration is not a prototype}}
28 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:23-[[@LINE-1]]:23}:"void"
30 // param fp unspecified params
31 void bar2(void (*foo6)()) { // expected-warning {{this function declaration is not a prototype}}
32 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:24-[[@LINE-1]]:24}:"void"
33 // local fp unspecified params
34 void (*foo7)() = 0; // expected-warning {{this function declaration is not a prototype}}
35 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"void"
36 // array fp unspecified params
37 void (*foo8[2])() = {0}; // expected-warning {{this function declaration is not a prototype}}
38 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:19}:"void"
41 // function type cast using using an anonymous function declaration
42 void bar3(void) {
43 // casting function w/out prototype to unspecified params function type
44 (void)(void(*)()) foo1; // expected-warning {{this function declaration is not a prototype}}
45 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:18}:"void"
46 // .. specified params
47 (void)(void(*)(void)) foo1;
50 // K&R function definition not preceded by full prototype
51 int foo9(a, b) // expected-warning {{old-style function definition is not preceded by a prototype}}
52 int a, b;
54 return a + b;
57 // Function declaration with no types
58 void foo10(); // expected-warning {{this function declaration is not a prototype}}
59 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:12-[[@LINE-1]]:12}:"void"
60 // K&R function definition with incomplete param list declared
61 void foo10(p, p2) void *p; {} // expected-warning {{old-style function definition is not preceded by a prototype}}
63 // K&R function definition with previous prototype declared is not diagnosed.
64 void foo11(int p, int p2);
65 void foo11(p, p2) int p; int p2; {}
67 // PR31020
68 void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
69 short d;
72 // No warnings for variadic functions. Overloadable attribute is required
73 // to avoid err_ellipsis_first_param error.
74 // rdar://problem/33251668
75 void foo13(...) __attribute__((overloadable));
76 void foo13(...) __attribute__((overloadable)) {}
78 // We should not generate a strict-prototype warning for an implicit
79 // declaration. Leave that up to the implicit-function-declaration warning.
80 void foo14(void) {
81 foo14_call(); // no-warning