blob: f41275d1e61840e641330e2ed70880ad32fc3b8b [file] [log] [blame]
Chandler Carrutha5b93322011-02-17 11:05:49 +00001// RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s
Douglas Gregor2224f842009-02-25 16:33:18 +00002
3// C DR #316, PR 3626.
4void f0(a, b, c, d) int a,b,c,d; {}
Douglas Gregor74734d52009-04-02 15:37:10 +00005void t0(void) {
6 f0(1); // expected-warning{{too few arguments}}
7}
Douglas Gregor2224f842009-02-25 16:33:18 +00008
9void f1(a, b) int a, b; {}
Douglas Gregor74734d52009-04-02 15:37:10 +000010void t1(void) {
11 f1(1, 2, 3); // expected-warning{{too many arguments}}
12}
Douglas Gregor2224f842009-02-25 16:33:18 +000013
14void f2(float); // expected-note{{previous declaration is here}}
Douglas Gregorc8376562009-03-06 22:43:54 +000015void 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}}
Douglas Gregor2224f842009-02-25 16:33:18 +000016
17typedef void (*f3)(void);
18f3 t3(int b) { return b? f0 : f1; } // okay
Douglas Gregor447234d2010-07-29 15:18:02 +000019
20// <rdar://problem/8193107>
21void f4() {
22 char *rindex();
23}
24
25char *rindex(s, c)
Chris Lattner58f9e132010-09-05 00:04:01 +000026 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}}
Douglas Gregor447234d2010-07-29 15:18:02 +000027{
28 return 0;
29}
Douglas Gregor46542412010-10-25 20:39:23 +000030
31// PR8314
32void proto(int);
33void proto(x)
34 int x;
35{
36}
37
38void use_proto() {
Matt Beaumont-Gay9ce63772011-10-14 15:36:25 +000039 proto(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
40 (&proto)(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
Douglas Gregor46542412010-10-25 20:39:23 +000041}