xref: /llvm-project/clang/test/Sema/prototype-redecls.c (revision 4c02ab8c9742f6c32b17f49a306b3b072486f5c5)
1 // RUN: %clang_cc1 -fsyntax-only -Wno-strict-prototypes -verify %s
2 
3 void blapp(int); // expected-note {{previous}}
blapp()4 void blapp() { } // expected-error {{conflicting types for 'blapp'}}
5 
6 void yarp(int, ...); // expected-note {{previous}}
7 void yarp();         // expected-error {{conflicting types for 'yarp'}}
8 
9 void blarg(int, ...); // expected-note {{previous}}
blarg()10 void blarg() {}       // expected-error {{conflicting types for 'blarg'}}
11 
12 void blerp(short);      // expected-note {{previous}}
blerp(x)13 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
14 
15 void foo(int); // expected-note {{previous}}
16 void foo();
foo()17 void foo() {} // expected-error {{conflicting types for 'foo'}}
18 
19 void glerp(int);
glerp(x)20 void glerp(x) short x; {} // Okay, promoted type is fine
21 
22 // All these cases are okay
23 void derp(int);
derp(x)24 void derp(x) int x; {}
25 
26 void garp(int);
27 void garp();
garp(x)28 void garp(x) int x; {}
29 
30 // Ensure redeclarations that conflict with a builtin use a note which makes it
31 // clear that the previous declaration was a builtin.
rintf()32 float rintf() { // expected-warning {{incompatible redeclaration of library function 'rintf'}} \
33                    expected-note {{'rintf' is a builtin with type 'float (float)'}}
34   return 1.0f;
35 }
36