1a5b9332418f25338f118358e27303cd510d54107Chandler Carruth// RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s 22224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregor 32224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregor// C DR #316, PR 3626. 42224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregorvoid f0(a, b, c, d) int a,b,c,d; {} 574734d576b1dd082f623abb76ab204d69970dadbDouglas Gregorvoid t0(void) { 674734d576b1dd082f623abb76ab204d69970dadbDouglas Gregor f0(1); // expected-warning{{too few arguments}} 774734d576b1dd082f623abb76ab204d69970dadbDouglas Gregor} 82224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregor 92224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregorvoid f1(a, b) int a, b; {} 1074734d576b1dd082f623abb76ab204d69970dadbDouglas Gregorvoid t1(void) { 1174734d576b1dd082f623abb76ab204d69970dadbDouglas Gregor f1(1, 2, 3); // expected-warning{{too many arguments}} 1274734d576b1dd082f623abb76ab204d69970dadbDouglas Gregor} 132224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregor 142224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregorvoid f2(float); // expected-note{{previous declaration is here}} 15c837656ca6d2a5b434923d7e2fd11d3a3c3bfa74Douglas Gregorvoid 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}} 162224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregor 172224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregortypedef void (*f3)(void); 182224f84658fb9b3725a31f2680edb64ae73bf705Douglas Gregorf3 t3(int b) { return b? f0 : f1; } // okay 19447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor 20447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor// <rdar://problem/8193107> 21447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregorvoid f4() { 22447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor char *rindex(); 23447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor} 24447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor 25447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregorchar *rindex(s, c) 2658f9e13e87e57236fee4b914eea9be6f92a1c345Chris Lattner 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}} 27447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor{ 28447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor return 0; 29447234dd459a00a5ed9b7c3e066162cd7a75bf2dDouglas Gregor} 304654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor 314654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor// PR8314 324654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregorvoid proto(int); 334654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregorvoid proto(x) 344654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor int x; 354654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor{ 364654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor} 374654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor 384654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregorvoid use_proto() { 39be0ee875d8a91c031a085cbbd73ad9e8dc1aa8ffDavid Blaikie proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} 40be0ee875d8a91c031a085cbbd73ad9e8dc1aa8ffDavid Blaikie (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} 414654241866c91fa312d7b26d5eb4afd070b5c602Douglas Gregor} 42