1 // RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s
2
3 // C DR #316, PR 3626.
f0(a,b,c,d)4 void f0(a, b, c, d) int a,b,c,d; {}
t0(void)5 void t0(void) {
6 f0(1); // expected-warning{{too few arguments}}
7 }
8
f1(a,b)9 void f1(a, b) int a, b; {}
t1(void)10 void t1(void) {
11 f1(1, 2, 3); // expected-warning{{too many arguments}}
12 }
13
14 void f2(float); // expected-note{{previous declaration is here}}
f2(x)15 void f2(x) float x; { } // expected-warning{{promoted type 'double' of K&R function parameter is not compatible with the parameter type 'float' declared in a previous prototype}}
16
17 typedef void (*f3)(void);
t3(int b)18 f3 t3(int b) { return b? f0 : f1; } // okay
19
20 // <rdar://problem/8193107>
f4()21 void f4() {
22 char *rindex();
23 }
24
rindex(s,c)25 char *rindex(s, c)
26 register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'const char *' declared in a previous prototype}}
27 {
28 return 0;
29 }
30
31 // PR8314
32 void proto(int);
proto(x)33 void proto(x)
34 int x;
35 {
36 }
37
use_proto()38 void use_proto() {
39 proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
40 (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
41 }
42