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