[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / function-redecl.c
blob3aeef00733d1f4faba6bf0d328f01b8efce24004
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wno-strict-prototypes -verify %s
3 // PR3588
4 void g0(int, int);
5 void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
7 void f0(void) {
8 g0(1, 2, 3); // expected-error{{too many arguments to function call}}
11 void g0(int); // expected-error{{conflicting types for 'g0'}}
13 int g1(int, int);
15 typedef int INT;
17 INT g1(x, y)
18 int x;
19 int y;
21 return x + y;
24 int g2(int, int); // expected-note{{previous declaration is here}}
26 INT g2(x) // expected-error{{conflicting types for 'g2'}}
27 int x;
29 return x;
32 void test(void) {
33 int f1;
35 void f1(double);
37 void f1(double); // expected-note{{previous declaration is here}}
39 int f1(int); // expected-error{{conflicting types for 'f1'}}
45 extern void g3(int); // expected-note{{previous declaration is here}}
46 static void g3(int x) { } // expected-error{{static declaration of 'g3' follows non-static declaration}}
48 void test2(void) {
49 extern int f2; // expected-note 2 {{previous definition is here}}
51 void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
55 int f2;
57 void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
62 int outer1(int); // expected-note{{previous declaration is here}}
63 struct outer3 { };
64 int outer4(int); // expected-note{{previous declaration is here}}
65 int outer5; // expected-note{{previous definition is here}}
66 int *outer7(int);
68 void outer_test(void) {
69 int outer1(float); // expected-error{{conflicting types for 'outer1'}}
70 int outer2(int); // expected-note{{previous declaration is here}}
71 int outer3(int); // expected-note{{previous declaration is here}}
72 int outer4(int);
73 int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
74 int* outer6(int); // expected-note{{previous declaration is here}}
75 int *outer7(int);
76 int outer8(int);
78 int *ip7 = outer7(6);
81 int outer2(float); // expected-error{{conflicting types for 'outer2'}}
82 int outer3(float); // expected-error{{conflicting types for 'outer3'}}
83 int outer4(float); // expected-error{{conflicting types for 'outer4'}}
85 void outer_test2(int x) {
86 int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}}
87 int *ip2 = outer7(x);
90 void outer_test3(void) {
91 int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
94 enum e { e1, e2 };
96 // GNU extension: prototypes and K&R function definitions
97 int isroot(short x, // expected-note{{previous declaration is here}}
98 enum e);
100 int isroot(x, y)
101 short x; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
102 unsigned int y;
104 return x == 1;
107 // PR3817
108 void *h0(unsigned a0, ...);
109 extern __typeof (h0) h1 __attribute__((__sentinel__));
110 extern __typeof (h1) h1 __attribute__((__sentinel__));
112 // PR3840
113 void i0 (unsigned short a0);
114 extern __typeof (i0) i1;
115 extern __typeof (i1) i1;
117 typedef int a();
118 typedef int a2(int*);
119 a x;
120 a2 x2; // expected-note{{passing argument to parameter here}}
121 void test_x(void) {
122 x(5);
123 x2(5); // expected-error{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
126 enum e0 {one};
127 void f3();
128 void f3(enum e0 x) {}
130 enum incomplete_enum;
131 void f4(); // expected-note {{previous declaration is here}}
132 void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}}