1*67e74705SXin Li // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
2*67e74705SXin Li
3*67e74705SXin Li // PR3588
4*67e74705SXin Li void g0(int, int);
5*67e74705SXin Li void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
6*67e74705SXin Li
f0()7*67e74705SXin Li void f0() {
8*67e74705SXin Li g0(1, 2, 3); // expected-error{{too many arguments to function call}}
9*67e74705SXin Li }
10*67e74705SXin Li
11*67e74705SXin Li void g0(int); // expected-error{{conflicting types for 'g0'}}
12*67e74705SXin Li
13*67e74705SXin Li int g1(int, int);
14*67e74705SXin Li
15*67e74705SXin Li typedef int INT;
16*67e74705SXin Li
g1(x,y)17*67e74705SXin Li INT g1(x, y)
18*67e74705SXin Li int x;
19*67e74705SXin Li int y;
20*67e74705SXin Li {
21*67e74705SXin Li return x + y;
22*67e74705SXin Li }
23*67e74705SXin Li
24*67e74705SXin Li int g2(int, int); // expected-note{{previous declaration is here}}
25*67e74705SXin Li
g2(x)26*67e74705SXin Li INT g2(x) // expected-error{{conflicting types for 'g2'}}
27*67e74705SXin Li int x;
28*67e74705SXin Li {
29*67e74705SXin Li return x;
30*67e74705SXin Li }
31*67e74705SXin Li
test()32*67e74705SXin Li void test() {
33*67e74705SXin Li int f1;
34*67e74705SXin Li {
35*67e74705SXin Li void f1(double);
36*67e74705SXin Li {
37*67e74705SXin Li void f1(double); // expected-note{{previous declaration is here}}
38*67e74705SXin Li {
39*67e74705SXin Li int f1(int); // expected-error{{conflicting types for 'f1'}}
40*67e74705SXin Li }
41*67e74705SXin Li }
42*67e74705SXin Li }
43*67e74705SXin Li }
44*67e74705SXin Li
45*67e74705SXin Li extern void g3(int); // expected-note{{previous declaration is here}}
g3(int x)46*67e74705SXin Li static void g3(int x) { } // expected-error{{static declaration of 'g3' follows non-static declaration}}
47*67e74705SXin Li
test2()48*67e74705SXin Li void test2() {
49*67e74705SXin Li extern int f2; // expected-note 2 {{previous definition is here}}
50*67e74705SXin Li {
51*67e74705SXin Li void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
52*67e74705SXin Li }
53*67e74705SXin Li
54*67e74705SXin Li {
55*67e74705SXin Li int f2;
56*67e74705SXin Li {
57*67e74705SXin Li void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
58*67e74705SXin Li }
59*67e74705SXin Li }
60*67e74705SXin Li }
61*67e74705SXin Li
62*67e74705SXin Li // <rdar://problem/6127293>
63*67e74705SXin Li int outer1(int); // expected-note{{previous declaration is here}}
64*67e74705SXin Li struct outer3 { };
65*67e74705SXin Li int outer4(int); // expected-note{{previous declaration is here}}
66*67e74705SXin Li int outer5; // expected-note{{previous definition is here}}
67*67e74705SXin Li int *outer7(int);
68*67e74705SXin Li
outer_test()69*67e74705SXin Li void outer_test() {
70*67e74705SXin Li int outer1(float); // expected-error{{conflicting types for 'outer1'}}
71*67e74705SXin Li int outer2(int); // expected-note{{previous declaration is here}}
72*67e74705SXin Li int outer3(int); // expected-note{{previous declaration is here}}
73*67e74705SXin Li int outer4(int);
74*67e74705SXin Li int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
75*67e74705SXin Li int* outer6(int); // expected-note{{previous declaration is here}}
76*67e74705SXin Li int *outer7(int);
77*67e74705SXin Li int outer8(int);
78*67e74705SXin Li
79*67e74705SXin Li int *ip7 = outer7(6);
80*67e74705SXin Li }
81*67e74705SXin Li
82*67e74705SXin Li int outer2(float); // expected-error{{conflicting types for 'outer2'}}
83*67e74705SXin Li int outer3(float); // expected-error{{conflicting types for 'outer3'}}
84*67e74705SXin Li int outer4(float); // expected-error{{conflicting types for 'outer4'}}
85*67e74705SXin Li
outer_test2(int x)86*67e74705SXin Li void outer_test2(int x) {
87*67e74705SXin Li int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}}
88*67e74705SXin Li int *ip2 = outer7(x);
89*67e74705SXin Li }
90*67e74705SXin Li
outer_test3()91*67e74705SXin Li void outer_test3() {
92*67e74705SXin Li int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
93*67e74705SXin Li }
94*67e74705SXin Li
95*67e74705SXin Li enum e { e1, e2 };
96*67e74705SXin Li
97*67e74705SXin Li // GNU extension: prototypes and K&R function definitions
98*67e74705SXin Li int isroot(short x, // expected-note{{previous declaration is here}}
99*67e74705SXin Li enum e);
100*67e74705SXin Li
isroot(x,y)101*67e74705SXin Li int isroot(x, y)
102*67e74705SXin Li 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}}
103*67e74705SXin Li unsigned int y;
104*67e74705SXin Li {
105*67e74705SXin Li return x == 1;
106*67e74705SXin Li }
107*67e74705SXin Li
108*67e74705SXin Li // PR3817
109*67e74705SXin Li void *h0(unsigned a0, ...);
110*67e74705SXin Li extern __typeof (h0) h1 __attribute__((__sentinel__));
111*67e74705SXin Li extern __typeof (h1) h1 __attribute__((__sentinel__));
112*67e74705SXin Li
113*67e74705SXin Li // PR3840
114*67e74705SXin Li void i0 (unsigned short a0);
115*67e74705SXin Li extern __typeof (i0) i1;
116*67e74705SXin Li extern __typeof (i1) i1;
117*67e74705SXin Li
118*67e74705SXin Li typedef int a();
119*67e74705SXin Li typedef int a2(int*);
120*67e74705SXin Li a x;
121*67e74705SXin Li a2 x2; // expected-note{{passing argument to parameter here}}
test_x()122*67e74705SXin Li void test_x() {
123*67e74705SXin Li x(5);
124*67e74705SXin Li x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
125*67e74705SXin Li }
126*67e74705SXin Li
127*67e74705SXin Li enum e0 {one};
128*67e74705SXin Li void f3();
f3(enum e0 x)129*67e74705SXin Li void f3(enum e0 x) {}
130*67e74705SXin Li
131*67e74705SXin Li enum incomplete_enum;
132*67e74705SXin Li void f4(); // expected-note {{previous declaration is here}}
133*67e74705SXin Li void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}}
134