Chandler Carruth | a5b9332 | 2011-02-17 11:05:49 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s |
Douglas Gregor | 2224f84 | 2009-02-25 16:33:18 +0000 | [diff] [blame] | 2 | |
| 3 | // C DR #316, PR 3626. |
| 4 | void f0(a, b, c, d) int a,b,c,d; {} |
Douglas Gregor | 74734d5 | 2009-04-02 15:37:10 +0000 | [diff] [blame] | 5 | void t0(void) { |
| 6 | f0(1); // expected-warning{{too few arguments}} |
| 7 | } |
Douglas Gregor | 2224f84 | 2009-02-25 16:33:18 +0000 | [diff] [blame] | 8 | |
| 9 | void f1(a, b) int a, b; {} |
Douglas Gregor | 74734d5 | 2009-04-02 15:37:10 +0000 | [diff] [blame] | 10 | void t1(void) { |
| 11 | f1(1, 2, 3); // expected-warning{{too many arguments}} |
| 12 | } |
Douglas Gregor | 2224f84 | 2009-02-25 16:33:18 +0000 | [diff] [blame] | 13 | |
| 14 | void f2(float); // expected-note{{previous declaration is here}} |
Douglas Gregor | c837656 | 2009-03-06 22:43:54 +0000 | [diff] [blame] | 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}} |
Douglas Gregor | 2224f84 | 2009-02-25 16:33:18 +0000 | [diff] [blame] | 16 | |
| 17 | typedef void (*f3)(void); |
| 18 | f3 t3(int b) { return b? f0 : f1; } // okay |
Douglas Gregor | 447234d | 2010-07-29 15:18:02 +0000 | [diff] [blame] | 19 | |
| 20 | // <rdar://problem/8193107> |
| 21 | void f4() { |
| 22 | char *rindex(); |
| 23 | } |
| 24 | |
| 25 | char *rindex(s, c) |
Chris Lattner | 58f9e13 | 2010-09-05 00:04:01 +0000 | [diff] [blame] | 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}} |
Douglas Gregor | 447234d | 2010-07-29 15:18:02 +0000 | [diff] [blame] | 27 | { |
| 28 | return 0; |
| 29 | } |
Douglas Gregor | 4654241 | 2010-10-25 20:39:23 +0000 | [diff] [blame] | 30 | |
| 31 | // PR8314 |
| 32 | void proto(int); |
| 33 | void proto(x) |
| 34 | int x; |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | void use_proto() { |
Matt Beaumont-Gay | 9ce6377 | 2011-10-14 15:36:25 +0000 | [diff] [blame] | 39 | 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 Gregor | 4654241 | 2010-10-25 20:39:23 +0000 | [diff] [blame] | 41 | } |