function.c
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
// PR1892, PR11354
void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
int foo (__const char *__path);
int foo(__const char *__restrict __file);
void func(const char*); // expected-note {{previous declaration is here}}
void func(char*); // expected-error{{conflicting types for 'func'}}
void g(int (*)(const void **, const void **));
void g(int (*compar)()) {
}
void h(); // expected-note {{previous declaration is here}}
void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
// PR1965
int t5(b); // expected-error {{parameter list without types}}
int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
int t8(, int a); // expected-error {{expected parameter declarator}}
int t9(int a, ); // expected-error {{expected parameter declarator}}
// PR2042
void t10(){}
void t11(){t10(1);} // expected-warning{{too many arguments}}
// PR3208
void t12(int) {} // expected-error{{parameter name omitted}}
// PR2790
void t13() {
return 0; // expected-error {{void function 't13' should not return a value}}
}
int t14() {
return; // expected-error {{non-void function 't14' should return a value}}
}
// <rdar://problem/6097326>
y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
// expected-warning{{type specifier missing, defaults to 'int'}}
// PR3137, <rdar://problem/6127293>
extern int g0_3137(void);
void f0_3137() {
int g0_3137(void);
}
void f1_3137() {
int (*fp)(void) = g0_3137;
}
void f1static() {
static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
register void f2register(int); // expected-error{{illegal storage class on function}}
}
struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
// expected-note{{forward declaration of 'struct incomplete_test'}}
extern __inline
__attribute__((__gnu_inline__))
void gnu_inline1() {}
void
__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
gnu_inline2() {}
// rdar://6802350
inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
}
typedef void fn_t(void);
fn_t t17;
// PR4049
unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}}
}
unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}
P = P+1; // no warning.
}
// missing ',' before '...'
void t20(int i...) { } // expected-error {{requires a comma}}
int n;
void t21(int n, int (*array)[n]);
int func_e(int x) {
int func_n(int y) { // expected-error {{function definition is not allowed here}}
if (y > 22) {
return y+2;
} else {
return y-2;
}
}
return x + 3;
}
void decays(int a[3][3]); // expected-note {{passing argument to parameter 'a' here}}
void no_decay(int (*a)[3]); // expected-note {{passing argument to parameter 'a' here}}
void t22(int *ptr, int (*array)[3]) {
decays(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
no_decay(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
decays(array);
no_decay(array);
}
void const Bar (void); // ok on decl
// PR 20146
void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}
{
}